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
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, ...
90
"""simple docstring""" from __future__ import annotations a_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __Up...
249
0
'''simple docstring''' import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def lowerCamelCase__ ( _A , _A=() , _A=None , _A="no" , _A="29500" ): a : ...
297
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
"""simple docstring""" def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : Optional[Any] , SCREAMING_SNAKE_CASE : Tuple ): '''simple docstring''' return int(input_a == input_a == 0 ) def UpperCAmelCase__ ( ): '''simple docst...
46
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A__: Dict = logging.get_logger(__name__) A__: int = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main...
276
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
0
def lowerCAmelCase__ ( a__: str , a__: Optional[int] ) -> str: '''simple docstring''' return 1 if input_a == input_a else 0 def lowerCAmelCase__ ( ) -> int: '''simple docstring''' assert xnor_gate(0 , 0 ) == 1 assert xnor_gat...
329
"""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/...
249
0
"""simple docstring""" from math import log from scipy.constants import Boltzmann, physical_constants UpperCAmelCase = 300 # TEMPERATURE (unit = K) def lowercase ( a__ : Union[str, Any] , a__ : str , a__ : List[str] , ) -> List[Any]: if donor_conc <= 0: raise Val...
256
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
import inspect import unittest class A__ ( unittest.TestCase ): """simple docstring""" def __lowercase ( self) -> int: '''simple docstring''' try: import diffusers # noqa: F401 except ImportError: ...
99
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
0
"""simple docstring""" import os import sys import unittest __a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_b...
66
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Any = n __lowercase : Any = [None] * self.n __lowercase : Optional[int] = 0 # index of the first...
249
0
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class A__ ( __SCREAMING_SNAKE_CASE , unittest.TestCase): _UpperCAmelCase : Dict = Tra...
287
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
0
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class __A( __lowerCamelCase ): """simple docstring""" SCREAMING_SNAKE_CASE__ = (PNDMScheduler,) SCREAMING_SNAKE_CASE__ = (("""num_inference_steps""", 50),) def ...
244
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
0
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 __snake_case = logging.get_logger(__name__) __snake_case = '''▁''' __snake_case = {'''vocab_...
348
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
0
class __lowerCAmelCase ( __magic_name__ ): """simple docstring""" pass class __lowerCAmelCase ( __magic_name__ ): """simple docstring""" pass class __lowerCAmelCase : """simple docstring""" ...
90
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin a_ = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
249
0
'''simple docstring''' import requests def lowerCamelCase__ ( _A , _A ): a : List[Any] = {'''Content-Type''': '''application/json'''} a : Optional[int] = requests.post(__UpperCamelCase , json={'text': message_body} , headers=__UpperCamelCas...
297
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class lowercase ( _UpperCAmelCase ): _SCREAMING_SNAKE_CASE = (UnCLIPScheduler,) def _snake_case ( self , **lowercase ) -...
46
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
0
'''simple docstring''' from __future__ import annotations from typing import Any class A__ : def __init__( self :int , SCREAMING_SNAKE_CASE :str = 6 ) -> None: '''simple docstring''' _a : Node |...
276
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ :Any = logging.get_logger(__name__) class __a ( UpperCAmelCase ): _a : Optional[int] = 'encoder-decoder' _a : Optional[int] = True def __init__( self , **_SCR...
329
"""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, DDIMSchedu...
249
0
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils impor...
256
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig a_ = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_p...
249
0
import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokenization_common impor...
99
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __a = { "configuration_poolformer": [ "POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "PoolFormerConfig", "PoolFormerOn...
66
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
0
import math def _a ( lowerCamelCase, lowerCamelCase ): if initial_intensity < 0: raise ValueError("""The value of intensity cannot be negative""" ) # handling of negative values of initial intensity if angle < 0 or angle > 360: raise ValueError("""In Malus Law, the angle is in th...
287
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
class __A: """simple docstring""" def __init__(self , SCREAMING_SNAKE_CASE_ ): UpperCamelCase__ = n UpperCamelCase__ = [None] * self.n UpperCamelCase__ = 0 # index of the first element UpperCamelCase__ = 0 UpperCamelCase__ = 0 ...
244
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a_ = datasets.utils.logging.get_logger(__name__) @dataclass clas...
249
0
import os import pytest from transformers.dynamic_module_utils import get_imports __snake_case = '''\nimport os\n''' __snake_case = '''\ndef foo():\n import os\n return False\n''' __snake_case = '''\ndef foo():\n def bar():\n if True:\n import os\n return Fal...
348
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
249
0
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig __A = { "susnato/ernie-m-base_pytorch": "https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json", "susnato/ernie-m-large_pytorch": "https://huggingfa...
90
"""simple docstring""" from __future__ import annotations a_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __Up...
249
0
'''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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( ...
297
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
"""simple docstring""" from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # noqa: F401 deprecate( "stable diffusion controlnet", "0.22.0", "Importing `FlaxStableDiffusionControlNetPipeline` from diffusers.pipelines.stable_diff...
46
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
0
'''simple docstring''' import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated A__: Optional[Any] = ...
276
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
0
import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, is_staging_test class __a ...
329
"""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/...
249
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependenc...
256
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
from __future__ import annotations from math import ceil, floor, sqrt def A_ ( A__ = 200_0000 ) -> Dict: a__ : list[int] = [0] a__ : int for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_numbers.append(triangle_numbers[-1] + i...
99
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
0
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, ...
66
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Any = n __lowercase : Any = [None] * self.n __lowercase : Optional[int] = 0 # index of the first...
249
0
def _a ( lowerCamelCase = "The quick brown fox jumps over the lazy dog", ): lowerCamelCase : Any = set() # Replace all the whitespace in our sentence lowerCamelCase : Any = input_str.replace(""" """, """""" ) for alpha in input_str: if "a" <= alpha.lower() <= "z": f...
287
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ ...
244
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
0
from __future__ import annotations def lowerCAmelCase_ ( __lowerCAmelCase )-> Optional[Any]: '''simple docstring''' if len(__UpperCamelCase ) == 0: return array UpperCAmelCase : Any =min(__UpperCamelCase ), max(__UpperCamelCase ) # ...
348
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
0
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("Googling.....") __A = "https://www.google.com/search?q=" + " ".join(sys.argv[1:]) __A = requests.get(url, headers={"U...
90
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin a_ = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
249
0
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase: Optional[int] = logging.get_logger(__name__) lowerCAmelCase: Any = { 'BridgeTower/bridgetower...
297
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers.testing_u...
46
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
0
'''simple docstring''' import collections import os import re from pathlib import Path A__: str = '''src/transformers''' # Matches is_xxx_available() A__: int = re.compile(R'''is\_([a-z_]*)_available()''') # Catches a one-line _import_struct = {xxx} ...
276
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIterator from tqdm impo...
329
"""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, DDIMSchedu...
249
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule UpperCAmelCase = {"""processing_wav2vec2_with_lm""": ["""Wav2Vec2ProcessorWithLM"""]} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys UpperCAmelCase = _...
256
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig a_ = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_p...
249
0
import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class A__ ( TensorFormatter[Mapping, '...
99
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
"""simple docstring""" from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, Tensor...
66
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase ={ """configuration_distilbert""": [ """DISTILBERT_PRETRAINED_CONFIG_ARCH...
287
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
def __magic_name__ ( __a : str = 4_000_000 ): '''simple docstring''' UpperCamelCase__ = [0, 1] UpperCamelCase__ = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 Upp...
244
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a_ = datasets.utils.logging.get_logger(__name__) @dataclass clas...
249
0
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline __snake_case = { '''n_samples''': 64, '''horizon''': 32, '''num_inference_steps''': 20, '''n_guide_steps''': 2, # can set to 0 for faster sampling, does not use value network '''scale_grad_b...
348
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
249
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(...
90
"""simple docstring""" from __future__ import annotations a_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __Up...
249
0
'''simple docstring''' from __future__ import annotations from math import gcd def lowerCamelCase__ ( _A , _A = 2 , _A = 1 , _A = 3 , ): # A value less than 2 can cause an infinite loop in the algorithm. if num < 2: raise ValueError('The input value cannot be less than 2' ...
297
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
"""simple docstring""" import re from filelock import FileLock try: import nltk SCREAMING_SNAKE_CASE__ = True except (ImportError, ModuleNotFoundError): SCREAMING_SNAKE_CASE__ = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("...
46
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
0
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): A__: Union[str, Any] = { '''linear''': PIL.Image.Resampli...
276
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
0
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, BertTokenizerFast, ...
329
"""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/...
249
0
"""simple docstring""" from argparse import ArgumentParser from . import BaseTransformersCLICommand def lowercase ( a__ : List[str] ) -> int: return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) class UpperCAmelCase_ ( ...
256
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
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__ ( __UpperCAmelCase ): """simple docstring""" def __init__( ...
99
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
0
"""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_...
66
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Any = n __lowercase : Any = [None] * self.n __lowercase : Optional[int] = 0 # index of the first...
249
0
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoModelForSequenceCla...
287
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
0
import collections import inspect import unittest from transformers import FocalNetConfig 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_backbone_common import BackboneTester...
244
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
0
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached_file, get_file_f...
348
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
0
import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device __A = False class __lowerCAmelCase ( unittest.TestCase ): ...
90
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin a_ = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
249
0
'''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_torc...
297
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
"""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_distilbert import DistilBertTokenizer SCREAMING_SNAKE_CASE__ = logging.get_lo...
46
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A__: int = logging.get_logger(__name__) ...
276
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
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 ( UpperCAmelCase ): _a : Optional[int] = (DPMSolverSDESchedule...
329
"""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, DDIMSchedu...
249
0
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def lowercase ( a__ : List[Any] ) ->...
256
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig a_ = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_p...
249
0
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutpu...
99
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __a = { "configuration_vision_encoder_decoder": ["VisionEncoderDecoderConfig", "VisionEncoderDecode...
66
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE) class A__ ( __SCREAMING_SNAKE_CASE): # `task` is not a ClassVar since we want it to be part of the `asdict` outp...
287
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...utils.du...
244
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a_ = datasets.utils.logging.get_logger(__name__) @dataclass clas...
249
0
import heapq def lowerCAmelCase_ ( __lowerCAmelCase )-> str: '''simple docstring''' UpperCAmelCase : list[list] =[] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like...
348
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
249
0
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class __lowerCAmelCase ( __magic_name__ ): """simple docstring""" snake_case_ = (DDIMParallelScheduler,) snake_case_ = (('''e...
90
"""simple docstring""" from __future__ import annotations a_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __Up...
249
0
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTester...
297
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) class lowercase ( _UpperCAmelCase ): def __init__( self , *lowercase ...
46
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
0
'''simple docstring''' import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin A__: Optional[int] = '''\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a ...
276
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
0
def lowerCAmelCase__ ( a__: str , a__: Tuple ) -> Any: '''simple docstring''' return price * (1 + tax_rate) if __name__ == "__main__": print(f'''{price_plus_tax(1_0_0, 0.25) = }''') print(f'''{price_plus_tax(125.50, 0.05) = }''')
329
"""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/...
249
0
"""simple docstring""" import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# UpperCAmelCase = [ # (stable-diffusion, HF Diffusers) ("""time_embed.0.weight""", """time_embedding.lin...
256
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline lowercase : List[str] = version.parse(version.p...
99
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
0
"""simple docstring""" import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): ...
66
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Any = n __lowercase : Any = [None] * self.n __lowercase : Optional[int] = 0 # index of the first...
249
0
import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union _lowerCamelCase =re.compile(R"""^(?P<major>\d+)""" R"""\.(?P<minor>\d+)""" R"""\.(?P<patch>\d+)$""") @total_ordering @dataclass class A__ : _UpperCAmelCase ...
287
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase_ = { '''configuration_gpt_neox_japanese''': ['''GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXJapaneseConfig'''], '''tokeniz...
244
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
0
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class __snake_case ( lowerCamelCase__ ): def __init__( self , snake_case__ , snake_case__ ) -> List[Any]: '''simple docstring''' UpperCAmelCase : ...
348
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
0
from __future__ import annotations from collections import Counter from random import random class __lowerCAmelCase : """simple docstring""" def __init__( self ) -> Any: '''simple docstring''' __lowerCamelCase = ...
90
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin a_ = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbo...
249
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase: Any = logging.get_logger(__name__) lowerCAmelCase: Any = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/a...
297
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase_ ( snake_case ): @staticmethod @abstractmethod def _lowerCamelCase ( UpperCamelCase_ ) -> Union[str, Any]: raise NotImplementedError() ...
249
0
"""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, DPMSolverMul...
46
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
249
0
'''simple docstring''' import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py A__: Optional[int] ...
276
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
def lowerCAmelCase__ ( a__: Optional[Any] ) -> Dict: '''simple docstring''' _UpperCAmelCase = 1 for i in range(1 , num + 1 ): fact *= i return fact def lowerCAmelCase__ ( a__: Union[str, Any] ) -> List[Any]: '...
329
"""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, DDIMSchedu...
249
0
"""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, t...
256
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig a_ = { 'susnato/ernie-m-base_pytorch': 'https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json', 'susnato/ernie-m-large_p...
249
0
def A_ ( A__ ) -> Dict: return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
99
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
"""simple docstring""" from __future__ import annotations def A_ ( _lowercase ): '''simple docstring''' if not nums: raise ValueError("""List is empty""" ) return sum(__UpperCamelCase ) / len(__UpperCamelCase ) if __name__ == "__main__": import doctest doc...
66
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Opt...
249
0
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def _a ( lowerCamelCase, lowerCamelCase, lowe...
287
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda from a...
244
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a_ = datasets.utils.logging.get_logger(__name__) @dataclass clas...
249
0
from heapq import heappop, heappush import numpy as np def lowerCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , )-> Union[str, Any]: '''simple docstring''' UpperCAmelCase : List[str] =grid...
348
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
249
0
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_toke...
90
"""simple docstring""" from __future__ import annotations a_ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __Up...
249
0
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require...
297
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : str = [1] __lowercase ,__lowercase ,__lowercase : List[str] = 0, 0, 0 __lowercase : List[str] = ugly_nums[ia] * 2 __lowerca...
249
0
"""simple docstring""" import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class lowercase : _SCREAMING_SNAKE_CASE = None def _snake_case ( self ) -> Dict: lowerCAmelCase = ...
46
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
0
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extract...
276
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch...
249
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase__ :Tuple = { '''configuration_blip''': [ '''BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''...
329
"""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/...
249
0
"""simple docstring""" import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() UpperCAmelCase = logging.get_logger("""transformers.models.speecht5""") def lowercase ( a__ : List[str] , a__ : Any...
256
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MA...
249
0
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): imp...
99
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_ac...
249
0
"""simple docstring""" def A_ ( _lowercase ): '''simple docstring''' snake_case_ :Optional[Any] = [0] * len(__UpperCamelCase ) snake_case_ :int = [] snake_case_ :List[Any] = [] snake_case_ :int = 0 for values in graph.values(): ...
66
"""simple docstring""" class UpperCAmelCase_ : def __init__( self , UpperCamelCase_ ) -> Tuple: __lowercase : Any = n __lowercase : Any = [None] * self.n __lowercase : Optional[int] = 0 # index of the first...
249
0
def _a ( lowerCamelCase ): if p < 2: raise ValueError("""p should not be less than 2!""" ) elif p == 2: return True lowerCamelCase : List[Any] = 4 lowerCamelCase : List[Any] = (1 << p) - 1 for _ in range(p - 2 ): lowerCamelCase : List[str] = ...
287
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handling of negative values of initial intensi...
249
0
import heapq as hq import math from collections.abc import Iterator class __A: """simple docstring""" def __init__(self , SCREAMING_SNAKE_CASE_ ): UpperCamelCase__ = str(id_ ) UpperCamelCase__ = None UpperCamelCase__ = None UpperCamelCase...
244
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a Clas...
249
0
from typing import Any def lowerCAmelCase_ ( __lowerCAmelCase )-> str: '''simple docstring''' if not input_list: return [] UpperCAmelCase : Dict =[input_list.count(__UpperCamelCase ) for value in input_list] UpperCAmelCase : Tup...
348
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
249
0
'''simple docstring''' # Copyright 2023 The HuggingFace 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 # # Unl...
250
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_com...
250
1