code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from tr...
309
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer UpperCamelCase_ = logging.get_logger(__name__) Uppe...
309
1
'''simple docstring''' from __future__ import annotations import math def _UpperCAmelCase ( _lowerCamelCase : float , _lowerCamelCase : int ) -> float: _lowerCAmelCase : Optional[Any] = u for i in range(1 , _lowerCamelCase ): _lowerCAmelCase : ...
309
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a_ : def __init__( self ): _lowerCAmelCase : Any = """""" _lowerCAmelCase : List[Any] = """""" _lowerCAmelCase ...
309
1
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { """BridgeTower/bridgetower-base""": """https://huggingface.co/BridgeTower/bridge...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """...
309
1
'''simple docstring''' import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.tr...
309
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean UpperCamelCase_ = 0 UpperCamelCase_ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0,...
309
1
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_...
309
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : list[int] , _lowerCamelCase : str ) -> list[int]: _lowerCAmelCase : List[Any] = int(_lowerCamelCase ) # Initialize Result _lowerCAmelCase : Any = [] # Traverse through all denomi...
309
1
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import Learn...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {"""configuration_encoder_decoder""": ["""EncoderDecoderConfig"""]} try: if not is_...
309
1
'''simple docstring''' import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand UpperCamelCase_ = ( """4S 3H 2C 7S 5H""", """9D 8H 2C 6S 7H""", """2D 6D 9D TH 7D""", """TC 8C 2S JH 6C""", """JH 8S TH AH QH""", """TS KS 5S 9S...
309
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_...
309
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_t...
309
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_lo...
309
1
'''simple docstring''' import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ......
309
'''simple docstring''' from collections.abc import Callable import numpy as np def _UpperCAmelCase ( _lowerCamelCase : Callable , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float ) -> np.ndarray: ...
309
1
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMi...
309
'''simple docstring''' from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def _UpperCAmelCase ( _lowerCamelCase : Dict , _lowerCamelCase : Optional[int] ) -> Union[str, Any]: # =====...
309
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class a_ (_a ): def __init__( self , *snake_case_ , **snake_case_ ): warnings.war...
309
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Config...
309
1
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepInv...
309
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
309
1
'''simple docstring''' from __future__ import annotations from fractions import Fraction def _UpperCAmelCase ( _lowerCamelCase : int , _lowerCamelCase : int ) -> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def _UpperCAm...
309
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers im...
309
1
'''simple docstring''' import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def _UpperCAmelCase ( ) ...
309
'''simple docstring''' import argparse import os import re UpperCamelCase_ = """src/diffusers""" # Pattern that looks at the indentation in a line. UpperCamelCase_ = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. UpperCamelCase_ = re.compile(r"""^\s*\"([^\"...
309
1
'''simple docstring''' from timeit import timeit UpperCamelCase_ = { """MALAYALAM""": True, """String""": False, """rotor""": True, """level""": True, """A""": True, """BB""": True, """ABC""": False, """amanaplanacanalpanama""": True, # "a man a plan a canal panama" } # Ensure ...
309
'''simple docstring''' import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig UpperCamelCase_ = logging.get_logger(__name__) class a_ : def __init__( self ...
309
1
'''simple docstring''' import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class a_ (_a ): __lowerCAmelCase : Any = (KDPMaDiscreteScheduler,) __lowerCAmelCase : Tuple = 1_0 ...
309
'''simple docstring''' # Algorithm for the pigeonhole sorting def _UpperCAmelCase ( _lowerCamelCase : Union[str, Any] ) -> List[Any]: _lowerCAmelCase : List[Any] = min(_lowerCamelCase ) # min() finds the minimum value _lowerCAmelCase : Tuple = max(_lower...
309
1
'''simple docstring''' from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow ...
309
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : int = 1_00 ) -> int: _lowerCAmelCase : Optional[Any] = (n * (n + 1) // 2) ** 2 _lowerCAmelCase : str = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": ...
309
1
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : int , _lowerCamelCase : int ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def _UpperCAmelCase ( ) -> None: assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) == ...
309
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: ...
309
1
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = """▁""" Up...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable UpperCamelCase_ = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DPTConfi...
309
1
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_uti...
309
'''simple docstring''' from __future__ import annotations import numpy as np def _UpperCAmelCase ( _lowerCamelCase : list[float] ) -> Dict: return np.maximum(0 , _lowerCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
309
1
'''simple docstring''' import os import sys UpperCamelCase_ = os.path.join(os.path.dirname(__file__), """src""") sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoModelForSequenceCl...
309
'''simple docstring''' import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class a_ (_a ): def __init__( self , *snake_case_ , **snake_case_ ): warnings.w...
309
1
'''simple docstring''' # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from ...
309
'''simple docstring''' import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class a_ (_a ): __lowerCAmelCase : Dict = ...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = { """configuration_megatron_bert""": ["""MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MegatronBertConfig"""], } try: if not is_torch_a...
309
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer UpperCamelCase_ = logging.get_logger(__name__) Uppe...
309
1
'''simple docstring''' from PIL import Image def _UpperCAmelCase ( _lowerCamelCase : Image , _lowerCamelCase : float ) -> Image: def brightness(_lowerCamelCase : int ) -> float: return 1_28 + level + (c - 1_28) if not -255.0 <= level <= 255.0: raise ValueError(""...
309
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a_ : def __init__( self ): _lowerCAmelCase : Any = """""" _lowerCAmelCase : List[Any] = """""" _lowerCAmelCase ...
309
1
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_d...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """...
309
1
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device UpperCamelCase_ = False class a_ (unittest.TestCase ):...
309
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean UpperCamelCase_ = 0 UpperCamelCase_ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0,...
309
1
'''simple docstring''' from manim import * class a_ (_a ): def __UpperCamelCase ( self ): _lowerCAmelCase : Dict = Rectangle(height=0.5 , width=0.5 ) _lowerCAmelCase : List[str] = Rectangle(height=0.46 , ...
309
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : list[int] , _lowerCamelCase : str ) -> list[int]: _lowerCAmelCase : List[Any] = int(_lowerCamelCase ) # Initialize Result _lowerCAmelCase : Any = [] # Traverse through all denomi...
309
1
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class a_ (unittest.TestCase ): def ...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {"""configuration_encoder_decoder""": ["""EncoderDecoderConfig"""]} try: if not is_...
309
1
'''simple docstring''' import pprint import requests UpperCamelCase_ = """https://zenquotes.io/api""" def _UpperCAmelCase ( ) -> list: return requests.get(API_ENDPOINT_URL + """/today""" ).json() def _UpperCAmelCase ( ) -> list: return requests.get(API_ENDPOINT_URL + """/random"...
309
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = {"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]} try: if not is_torch_availabl...
309
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_lo...
309
1
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : list , _lowerCamelCase : list , _lowerCamelCase : int ) -> list: _lowerCAmelCase : int = len(_lowerCamelCase ) _lowerCAmelCase : Union[str, Any] = [[0] * n for i in range(_...
309
'''simple docstring''' from collections.abc import Callable import numpy as np def _UpperCAmelCase ( _lowerCamelCase : Callable , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float ) -> np.ndarray: ...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {"""configuration_encoder_decoder""": ["""EncoderDecoderConfig"""]} try: if not is_...
309
'''simple docstring''' from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def _UpperCAmelCase ( _lowerCamelCase : Dict , _lowerCamelCase : Optional[int] ) -> Union[str, Any]: # =====...
309
1
'''simple docstring''' import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = """▁""" Up...
309
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Config...
309
1
'''simple docstring''' from math import loga def _UpperCAmelCase ( _lowerCamelCase : int ) -> int: if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(_lowerCamelCase , _lowerCamelCase ): raise TypeError("""Input value must be a '...
309
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
309
1
'''simple docstring''' import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class a_ (_a ): def __init__( self , snake_...
309
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers im...
309
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class a_ (_a ): def __init__( self , *snake_case_ , **snake_case_ ): warnings.w...
309
'''simple docstring''' import argparse import os import re UpperCamelCase_ = """src/diffusers""" # Pattern that looks at the indentation in a line. UpperCamelCase_ = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. UpperCamelCase_ = re.compile(r"""^\s*\"([^\"...
309
1
'''simple docstring''' import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backb...
309
'''simple docstring''' import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig UpperCamelCase_ = logging.get_logger(__name__) class a_ : def __init__( self ...
309
1
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
309
'''simple docstring''' # Algorithm for the pigeonhole sorting def _UpperCAmelCase ( _lowerCamelCase : Union[str, Any] ) -> List[Any]: _lowerCAmelCase : List[Any] = min(_lowerCamelCase ) # min() finds the minimum value _lowerCAmelCase : Tuple = max(_lower...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = { """configuration_clipseg""": [ """CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CLIPSegConfig""", """CLIPSegTextConfig"""...
309
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : int = 1_00 ) -> int: _lowerCAmelCase : Optional[Any] = (n * (n + 1) // 2) ** 2 _lowerCAmelCase : str = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": ...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = { """configuration_x_clip""": [ """XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XCLIPConfig""", """XCLIPTextConfig""", ...
309
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: ...
309
1
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : Optional[int] , _lowerCamelCase : List[str] ) -> Optional[Any]: _lowerCAmelCase : Dict = [0 for i in range(r + 1 )] # nc0 = 1 _lowerCAmelCase : str = 1 for i in range(1 , n...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable UpperCamelCase_ = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DPTConfi...
309
1
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers im...
309
'''simple docstring''' from __future__ import annotations import numpy as np def _UpperCAmelCase ( _lowerCamelCase : list[float] ) -> Dict: return np.maximum(0 , _lowerCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
309
1
'''simple docstring''' import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelera...
309
'''simple docstring''' import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class a_ (_a ): def __init__( self , *snake_case_ , **snake_case_ ): warnings.w...
309
1
'''simple docstring''' UpperCamelCase_ = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def _UpperCAmelCase ( _lowerCamelCase : Dict , _lowerCamelCase : Union[str, Any] , _l...
309
'''simple docstring''' import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class a_ (_a ): __lowerCAmelCase : Dict = ...
309
1
'''simple docstring''' from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class a_ : __lowerCAmelCase : int __lowerCAmelCase : TreeNode | None = None __lowerCAmelCase : TreeNode | None = None UpperCam...
309
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer UpperCamelCase_ = logging.get_logger(__name__) Uppe...
309
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTokeniz...
309
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a_ : def __init__( self ): _lowerCAmelCase : Any = """""" _lowerCAmelCase : List[Any] = """""" _lowerCAmelCase ...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import _LazyModule UpperCamelCase_ = {"""tokenization_tapex""": ["""TapexTokenizer"""]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys UpperCamelCase_ = _LazyModule(__name__, gl...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """...
309
1
'''simple docstring''' from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, ...
309
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean UpperCamelCase_ = 0 UpperCamelCase_ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0,...
309
1
'''simple docstring''' import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class a_ (_a ): __lowerCAmelCase : Dict = ...
309
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : list[int] , _lowerCamelCase : str ) -> list[int]: _lowerCAmelCase : List[Any] = int(_lowerCamelCase ) # Initialize Result _lowerCAmelCase : Any = [] # Traverse through all denomi...
309
1
'''simple docstring''' from __future__ import annotations import math def _UpperCAmelCase ( _lowerCamelCase : list , _lowerCamelCase : list ) -> list: if len(_lowerCamelCase ) != 2 or len(a[0] ) != 2 or len(_lowerCamelCase ) != 2 or len(b[0] ) != 2: raise Exc...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {"""configuration_encoder_decoder""": ["""EncoderDecoderConfig"""]} try: if not is_...
309
1
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np UpperCamelCase_ = re.compile(r"""\b(a|an|the)\b""", re.UNICODE) UpperCamelCase_ = None def _UpperCAmelCase ( ) -> Tuple: _lowerCAmelCase : List[str]...
309
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_...
309
1
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME UpperCamelCase_ = ["""small""", """medium""", """large"""] UpperCamelCase_ = """lm_head.decoder.weight""" UpperCamelCase_ = """lm_head.weight""" def _UpperCAmelCase ( _lowerCamelCas...
309
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_lo...
309
1
'''simple docstring''' from __future__ import annotations UpperCamelCase_ = """#""" class a_ : def __init__( self ): _lowerCAmelCase : dict = {} def __UpperCamelCase ( self , snake_case_ ): _lowerCAmelCase : ...
309
'''simple docstring''' from collections.abc import Callable import numpy as np def _UpperCAmelCase ( _lowerCamelCase : Callable , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float ) -> np.ndarray: ...
309
1
'''simple docstring''' import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib im...
309
'''simple docstring''' from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def _UpperCAmelCase ( _lowerCamelCase : Dict , _lowerCamelCase : Optional[int] ) -> Union[str, Any]: # =====...
309
1
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake UpperCamelCase_ = numpy.array([0, 0]) UpperCamelCase_ = numpy.array([0.5, 0.8_6_6_0_2_5_4]) UpperCamelCase_ = numpy.array([1, 0]) UpperCamelCa...
309
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Config...
309
1
'''simple docstring''' import argparse import os import re UpperCamelCase_ = """src/diffusers""" # Pattern that looks at the indentation in a line. UpperCamelCase_ = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. UpperCamelCase_ = re.compile(r"""^\s*\"([^\"...
309
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
309
1
'''simple docstring''' import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import C...
309
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers im...
309
1
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when swi...
309
'''simple docstring''' import argparse import os import re UpperCamelCase_ = """src/diffusers""" # Pattern that looks at the indentation in a line. UpperCamelCase_ = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. UpperCamelCase_ = re.compile(r"""^\s*\"([^\"...
309
1
'''simple docstring''' import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) UpperCamelCase_ = logging.getLogger() def...
309
'''simple docstring''' import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig UpperCamelCase_ = logging.get_logger(__name__) class a_ : def __init__( self ...
309
1
'''simple docstring''' from __future__ import annotations import numpy as np def _UpperCAmelCase ( _lowerCamelCase : list[float] ) -> Dict: return np.maximum(0 , _lowerCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
309
'''simple docstring''' # Algorithm for the pigeonhole sorting def _UpperCAmelCase ( _lowerCamelCase : Union[str, Any] ) -> List[Any]: _lowerCAmelCase : List[Any] = min(_lowerCamelCase ) # min() finds the minimum value _lowerCAmelCase : Tuple = max(_lower...
309
1
'''simple docstring''' import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_util...
309
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : int = 1_00 ) -> int: _lowerCAmelCase : Optional[Any] = (n * (n + 1) // 2) ** 2 _lowerCAmelCase : str = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": ...
309
1
'''simple docstring''' import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class a_ (_a ): __lowerCAmelCase : Tuple = """MCTCTFeatureExtractor""" __lowerCAmelCase : str = """AutoTokenizer""" def __init__( self ...
309
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: ...
309
1
'''simple docstring''' from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging UpperCamelCase_ = logging.get_logger(__name__) def _UpperCAmelCase ( _lowe...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable UpperCamelCase_ = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DPTConfi...
309
1
'''simple docstring''' # Algorithm for the pigeonhole sorting def _UpperCAmelCase ( _lowerCamelCase : Union[str, Any] ) -> List[Any]: _lowerCAmelCase : List[Any] = min(_lowerCamelCase ) # min() finds the minimum value _lowerCAmelCase : Tuple = max(_lower...
309
'''simple docstring''' from __future__ import annotations import numpy as np def _UpperCAmelCase ( _lowerCamelCase : list[float] ) -> Dict: return np.maximum(0 , _lowerCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase_ = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], """tokeni...
309
'''simple docstring''' import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class a_ (_a ): def __init__( self , *snake_case_ , **snake_case_ ): warnings.w...
309
1
'''simple docstring''' import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling...
309
'''simple docstring''' import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class a_ (_a ): __lowerCAmelCase : Dict = ...
309
1
'''simple docstring''' from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. UpperCamelCase_ = 10 def _UpperCAmelCase ( _lowerCamelCase : int , _lowerCamelCase : i...
309
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer UpperCamelCase_ = logging.get_logger(__name__) Uppe...
309
1
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example UpperCamelCase_ = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0...
309
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a_ : def __init__( self ): _lowerCAmelCase : Any = """""" _lowerCAmelCase : List[Any] = """""" _lowerCAmelCase ...
309
1
'''simple docstring''' import argparse import math import traceback import dateutil.parser as date_parser import requests def _UpperCAmelCase ( _lowerCamelCase : Optional[int] ) -> Dict: _lowerCAmelCase : Optional[int] = {} _lowerCAmelCase : str = job["""start...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """...
309
1
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( ...
309
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean UpperCamelCase_ = 0 UpperCamelCase_ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0,...
309
1
'''simple docstring''' import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_com...
309
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : list[int] , _lowerCamelCase : str ) -> list[int]: _lowerCAmelCase : List[Any] = int(_lowerCamelCase ) # Initialize Result _lowerCAmelCase : Any = [] # Traverse through all denomi...
309
1
'''simple docstring''' import functools def _UpperCAmelCase ( _lowerCamelCase : list[int] , _lowerCamelCase : list[int] ) -> int: # Validation if not isinstance(_lowerCamelCase , _lowerCamelCase ) or not all(isinstance(_lowerCamelCase , _lowerCamelCase ) ...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {"""configuration_encoder_decoder""": ["""EncoderDecoderConfig"""]} try: if not is_...
309
1
'''simple docstring''' import re def _UpperCAmelCase ( _lowerCamelCase : str ) -> str: if len(re.findall("""[ATCG]""" , _lowerCamelCase ) ) != len(_lowerCamelCase ): raise ValueError("""Invalid Strand""" ) return dna.translate(dna.maketrans("""ATCG""" , ...
309
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_...
309
1
'''simple docstring''' import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class a_ (_a ): # to overwrite at feature extractactor specific tests ...
309
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_lo...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MCTCTFeature...
309
'''simple docstring''' from collections.abc import Callable import numpy as np def _UpperCAmelCase ( _lowerCamelCase : Callable , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float ) -> np.ndarray: ...
309
1
'''simple docstring''' import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_dete...
309
'''simple docstring''' from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def _UpperCAmelCase ( _lowerCamelCase : Dict , _lowerCamelCase : Optional[int] ) -> Union[str, Any]: # =====...
309
1
'''simple docstring''' from __future__ import annotations def _UpperCAmelCase ( _lowerCamelCase : str , _lowerCamelCase : list[str] | None = None ) -> list[list[str]]: _lowerCAmelCase : List[Any] = word_bank or [] # create a table _lowerCAmelCase : int ...
309
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Config...
309
1
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: UpperCamelCase_ = None try: import msvcrt except ImportError: UpperCamelCase_ = None try: import fcntl except ImportError: UpperCamelCase_ = None ...
309
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
309
1
'''simple docstring''' # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pi...
309
'''simple docstring''' import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers im...
309
1
'''simple docstring''' from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def _UpperCAmelCase ( _lowerCamelCase : Dict , _lowerCamelCase : Optional[int] ) -> Union[str, Any]: # =====...
309
'''simple docstring''' import argparse import os import re UpperCamelCase_ = """src/diffusers""" # Pattern that looks at the indentation in a line. UpperCamelCase_ = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. UpperCamelCase_ = re.compile(r"""^\s*\"([^\"...
309
1
'''simple docstring''' import os from typing import Dict, List, Tuple, TypeVar, Union UpperCamelCase_ = TypeVar("""T""") UpperCamelCase_ = Union[List[T], Tuple[T, ...]] UpperCamelCase_ = Union[T, List[T], Dict[str, T]] UpperCamelCase_ = Union[str, bytes, os.PathLike]
309
'''simple docstring''' import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig UpperCamelCase_ = logging.get_logger(__name__) class a_ : def __init__( self ...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase_ = { """configuration_chinese_clip""": [ """CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ChineseCLIPConfig"...
309
'''simple docstring''' # Algorithm for the pigeonhole sorting def _UpperCAmelCase ( _lowerCamelCase : Union[str, Any] ) -> List[Any]: _lowerCAmelCase : List[Any] = min(_lowerCamelCase ) # min() finds the minimum value _lowerCAmelCase : Tuple = max(_lower...
309
1
'''simple docstring''' import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class a_ (_a ): __lowerCAmelCase : Dict = (IPNDMScheduler,) __lowerCAmelCase : Tuple = (("""num_inference_steps""", 5_0),) ...
309
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : int = 1_00 ) -> int: _lowerCAmelCase : Optional[Any] = (n * (n + 1) // 2) ** 2 _lowerCAmelCase : str = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": ...
309
1
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_uti...
309
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: ...
309
1
'''simple docstring''' import collections import importlib.util import os import re from pathlib import Path UpperCamelCase_ = """src/transformers""" # Matches is_xxx_available() UpperCamelCase_ = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} UpperCamelCase_ ...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable UpperCamelCase_ = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DPTConfi...
309
1
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : int , _lowerCamelCase : int ) -> str: if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) _lowerCAmelCase : Optional[Any] = str(bin(_lowerCamelCase ) )[...
309
'''simple docstring''' from __future__ import annotations import numpy as np def _UpperCAmelCase ( _lowerCamelCase : list[float] ) -> Dict: return np.maximum(0 , _lowerCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
309
1
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_availa...
309
'''simple docstring''' import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class a_ (_a ): def __init__( self , *snake_case_ , **snake_case_ ): warnings.w...
309
1
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class a_ (_a ): __lowerCAmelCase : int = ["""image_processor""", """tokenizer"""] __lowerCAmelCase : str = """CLIPImageProcessor""" ...
309
'''simple docstring''' import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class a_ (_a ): __lowerCAmelCase : Dict = ...
309
1
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def _UpperCAmelCase ( _lowerCamelCase : list[list[float]] ) -> list[list[float]]: _lowerCAmelCase : Optional[Any] = Decimal # Check if the provided matrix has 2 rows...
309
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer UpperCamelCase_ = logging.get_logger(__name__) Uppe...
309
1
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer UpperCamelCase_ = logging.get_logger(__name__) Uppe...
309
'''simple docstring''' import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a_ : def __init__( self ): _lowerCAmelCase : Any = """""" _lowerCAmelCase : List[Any] = """""" _lowerCAmelCase ...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase_ = { """configuration_bridgetower""": [ """BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BridgeTowerConfig"""...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """...
309
1
'''simple docstring''' from collections.abc import Sequence from queue import Queue class a_ : def __init__( self , snake_case_ , snake_case_ , snake_case_ , snake_case_=None , snake_case_=None ): _lowerCAmelCase : int ...
309
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean UpperCamelCase_ = 0 UpperCamelCase_ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0,...
309
1
'''simple docstring''' import math def _UpperCAmelCase ( _lowerCamelCase : int ) -> list[int]: _lowerCAmelCase : Dict = [] _lowerCAmelCase : int = 2 _lowerCAmelCase : Dict = int(math.sqrt(_lowerCamelCase ) ) # Size of every segment ...
309
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : list[int] , _lowerCamelCase : str ) -> list[int]: _lowerCAmelCase : List[Any] = int(_lowerCamelCase ) # Initialize Result _lowerCAmelCase : Any = [] # Traverse through all denomi...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable UpperCamelCase_ = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DPTConfi...
309
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase_ = {"""configuration_encoder_decoder""": ["""EncoderDecoderConfig"""]} try: if not is_...
309
1
'''simple docstring''' def _UpperCAmelCase ( _lowerCamelCase : int = 10_00 ) -> int: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
309
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_...
309
1
'''simple docstring''' from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def _UpperCAmelCase ( _lowerCamelCase : str , _lowerCamelCase : complex , _lowerCamelCase : str = "x" , _lowerCamelCase : float = 10**-10 , _lowerCamelCa...
309
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_lo...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """...
309
'''simple docstring''' from collections.abc import Callable import numpy as np def _UpperCAmelCase ( _lowerCamelCase : Callable , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float ) -> np.ndarray: ...
309
1
'''simple docstring''' # Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position UpperCamelCase_ = """2.13.1""" import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse("""...
309
'''simple docstring''' from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def _UpperCAmelCase ( _lowerCamelCase : Dict , _lowerCamelCase : Optional[int] ) -> Union[str, Any]: # =====...
309
1
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...model...
309
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Config...
309
1
'''simple docstring''' import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class a_ : def __init__( self , snake_case_ ): if isinstance(snake_case_ , ...
309
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
309
1