code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
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 fr...
489
from __future__ import annotations from typing import Any class __UpperCamelCase : '''simple docstring''' def __init__( self , lowerCamelCase__ ): UpperCAmelCase__: Optional[int] = num_of_nodes UpperCAmelCase__: list[list[int]] = [] UpperCAmel...
113
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase : Dict = { """andr...
214
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accelera...
113
0
"""simple docstring""" import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset __SCREAMING_SNAKE_CASE = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2...
388
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase : Union[str, Any] ={ """configuration_clap""": [ """CLAP_PRETRAINED_MODEL_ARCHIVE_LIST""", """ClapAudioConfig""", """ClapConfig""", """C...
113
0
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": lowercase_ = """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: "...
235
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features import Arr...
113
0
"""simple docstring""" import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp f...
103
import fire from utils import calculate_rouge, save_json def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE=None ,**SCREAMING_SNAKE_CASE ): UpperCAmelCase__: Tuple = [x.strip() for x in open(SCREAMING_SNAKE_CASE ).readlines()] UpperCAmelCase__: Dict = [x....
113
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__ = {"""configuration_vit_msn""": ["""VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ViTMSNConfig"""]} try: if not is_torch_available(): ...
232
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __UpperCamelCase ( _a ,_a ): '''simple docstring''' @register_to_config def __init__( self , *, lowerCamelCase__ = 4 ...
113
0
import math def lowercase__ ( _UpperCamelCase = 1_00) -> str: """simple docstring""" UpperCamelCase = sum(i * i for i in range(1 , n + 1)) UpperCamelCase = int(math.pow(sum(range(1 , n + 1)) , 2)) return squ...
280
from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class __UpperCamelCase ( _a ): '''simple do...
113
0
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 our t...
2
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def _A ( SCREAMING_SNAKE_CASE ): return input_array.reshape((input_array.size, 1) ) def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SC...
113
0
'''simple docstring''' def UpperCamelCase_ ( ) -> Optional[int]: """simple docstring""" _UpperCAmelCase : List[str] = 0 for i in range(1 , 1_001 ): total += i**i return str(_UpperCAmelCase )[-10:] if __name...
244
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py _lowerCAmelCase : int ="""src/transformers""" # This is to make sure the ...
113
0
import unittest from transformers import DonutProcessor lowerCAmelCase_ = """naver-clova-ix/donut-base""" class A (unittest.TestCase ): def __a ( self ) -> Optional[int]: '''simple docstring''' _snake_case : Any = DonutProce...
326
def _A ( SCREAMING_SNAKE_CASE ): UpperCAmelCase__ , UpperCAmelCase__: int = [], [] while len(SCREAMING_SNAKE_CASE ) > 1: UpperCAmelCase__ , UpperCAmelCase__: str = min(SCREAMING_SNAKE_CASE ), max(SCREAMING_SNAKE_CASE ) start.append(SCREAMING_SNAK...
113
0
__lowerCAmelCase : Tuple = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ __lowerCAmelCase ...
529
def _A ( SCREAMING_SNAKE_CASE ): # noqa: E741 UpperCAmelCase__: int = len(SCREAMING_SNAKE_CASE ) UpperCAmelCase__: Dict = 0 UpperCAmelCase__: Optional[int] = [0] * n UpperCAmelCase__: List[str] = [False] * n UpperCAmelCase__: List[str] = [False] * n de...
113
0
'''simple docstring''' from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class UpperCamelCase__ ( yaml.SafeLoader ): def __a ( self : Union[str, Any] , lowerCamelCase : Tuple ): ...
489
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_a...
113
0
import functools from typing import Any def _lowercase ( __UpperCamelCase : str , __UpperCamelCase : List[Any] ): # Validation if not isinstance(__UpperCamelCase , __UpperCamelCase ) or len(__UpperCamelCase ) == 0: raise ValueError("""the string should b...
214
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCAmelCase : Tuple ={ """configuration_mobilenet_v2""": [ """MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileNetV2Config""", "...
113
0
"""simple docstring""" import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobert...
388
_lowerCAmelCase : int =""" # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/huggingface/transformers.g...
113
0
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils i...
235
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, AutoT...
113
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case = logging.get_logger(__name__) snake_case = { """xl...
103
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken log...
113
0
"""simple docstring""" from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES __magic_name__ = logging.get_logger(__name__) __magic_name__ = ...
232
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EX...
113
0
import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def lowercase__ ( ) -> int: """simple docstring""" print('Making key files...') make_key_files('rsa' , 10...
280
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def _A ( SCREAMING_SNAKE_CASE ): # A local function to see if a dot lands in the circle. def is_in_circle(SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ) -> bool: UpperCAmelCase...
113
0
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging UpperCAmelCase...
2
def _A ( SCREAMING_SNAKE_CASE ): stooge(SCREAMING_SNAKE_CASE ,0 ,len(SCREAMING_SNAKE_CASE ) - 1 ) return arr def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ): if i >= h: return # If first element is smaller than the last then swap them if arr[i...
113
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_...
244
def _A ( SCREAMING_SNAKE_CASE ): UpperCAmelCase__: Tuple = int(SCREAMING_SNAKE_CASE ) if decimal in (0, 1): # Exit cases for the recursion return str(SCREAMING_SNAKE_CASE ) UpperCAmelCase__ , UpperCAmelCase__: Union[str, Any] = divmod(SCREAMING_SNAKE_CASE ,2 ...
113
0
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline lowerCAmelCase_ = datasets.utils.logging.get_logger(__nam...
326
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput _lowerCAmelCase : int ="""scheduler_config.json""" class __UpperCamelCase ( _a ): '''simple docstring''' ...
113
0
def a__ ( A_ ): '''simple docstring''' __magic_name__ = [1] __magic_name__ = 0, 0, 0 __magic_name__ = ugly_nums[ia] * 2 __magic_name__ = ugly_nums[ia] * 3 __magic_name__ = ugly_nums[ia] * 5 for _ in range(1, A_ ): ...
529
import unittest from transformers import DonutProcessor _lowerCAmelCase : str ="""naver-clova-ix/donut-base""" class __UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def _UpperCAmelCase ( self ): UpperCAmelCase__: Any = DonutProcessor.f...
113
0
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmb...
489
from __future__ import annotations from typing import Any class __UpperCamelCase : '''simple docstring''' def __init__( self , lowerCamelCase__ ): UpperCAmelCase__: Optional[int] = num_of_nodes UpperCAmelCase__: list[list[int]] = [] UpperCAmel...
113
0
from bisect import bisect from itertools import accumulate def _lowercase ( __UpperCamelCase : Union[str, Any] , __UpperCamelCase : Optional[Any] , __UpperCamelCase : List[str] , __UpperCamelCase : List[str] ): snake_case__ = sorted(zip(__UpperCamelCase , ...
214
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accelera...
113
0
"""simple docstring""" import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_visi...
388
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase : Union[str, Any] ={ """configuration_clap""": [ """CLAP_PRETRAINED_MODEL_ARCHIVE_LIST""", """ClapAudioConfig""", """ClapConfig""", """C...
113
0
import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor lowercase_ = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE (_a ): def __init__( self : List[Any] , *a : List[Any] , **a ...
235
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features import Arr...
113
0
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, Musi...
103
import fire from utils import calculate_rouge, save_json def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE=None ,**SCREAMING_SNAKE_CASE ): UpperCAmelCase__: Tuple = [x.strip() for x in open(SCREAMING_SNAKE_CASE ).readlines()] UpperCAmelCase__: Dict = [x....
113
0
"""simple docstring""" from pathlib import Path import fire from tqdm import tqdm def _lowerCamelCase ( UpperCAmelCase__="ro",UpperCAmelCase__="en",UpperCAmelCase__="wmt16",UpperCAmelCase__=None ) -> List[str]: '''simple docstring''' try: import datasets except (ModuleNotFound...
232
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __UpperCamelCase ( _a ,_a ): '''simple docstring''' @register_to_config def __init__( self , *, lowerCamelCase__ = 4 ...
113
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_image, l...
280
from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class __UpperCamelCase ( _a ): '''simple do...
113
0
from jiwer import compute_measures import datasets UpperCAmelCase_ = """\ @inproceedings{inproceedings, author = {Morris, Andrew and Maier, Viktoria and Green, Phil}, year = {2004}, month = {01}, pages = {}, title = {From WER and RIL to MER and WIL: improved evaluation measures...
2
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def _A ( SCREAMING_SNAKE_CASE ): return input_array.reshape((input_array.size, 1) ) def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SC...
113
0
'''simple docstring''' from __future__ import annotations class lowerCamelCase_ : '''simple docstring''' def __init__( self : int , A : Optional[Any]=None ): _UpperCAmelCase : Union[str, Any] = data _UpperCAmelCase : List[str] ...
244
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py _lowerCAmelCase : int ="""src/transformers""" # This is to make sure the ...
113
0
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class A (_a ): _SCREAMING_SNAKE_CASE = (CMStochasticIterativeScheduler,) _SCREAMING_SNAKE_CASE = 10 def __a ( self , **lowercase_ ...
326
def _A ( SCREAMING_SNAKE_CASE ): UpperCAmelCase__ , UpperCAmelCase__: int = [], [] while len(SCREAMING_SNAKE_CASE ) > 1: UpperCAmelCase__ , UpperCAmelCase__: str = min(SCREAMING_SNAKE_CASE ), max(SCREAMING_SNAKE_CASE ) start.append(SCREAMING_SNAK...
113
0
import math def a__ ( A_, A_ ): '''simple docstring''' if ( not isinstance(A_, (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("""power_factor must be a valid float value between -1 and 1.""" ) return apparent_pow...
529
def _A ( SCREAMING_SNAKE_CASE ): # noqa: E741 UpperCAmelCase__: int = len(SCREAMING_SNAKE_CASE ) UpperCAmelCase__: Dict = 0 UpperCAmelCase__: Optional[int] = [0] * n UpperCAmelCase__: List[str] = [False] * n UpperCAmelCase__: List[str] = [False] * n de...
113
0
'''simple docstring''' import os from math import logaa def _lowerCamelCase (__lowerCamelCase : Optional[int] = "base_exp.txt" ) -> Tuple: a__ = 0 a__ = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(__lowerCamelCase ) , __lowerCamelCase ) ...
489
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_a...
113
0
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format='''%(message)s''') def _lowercase ( __UpperCamelCase : Any ): return input_array.reshape((input_array.size, 1) ) def _lowercase ( __UpperCamelCas...
214
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCAmelCase : Tuple ={ """configuration_mobilenet_v2""": [ """MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileNetV2Config""", "...
113
0
"""simple docstring""" import collections import os import re from pathlib import Path __SCREAMING_SNAKE_CASE = """src/transformers""" # Matches is_xxx_available() __SCREAMING_SNAKE_CASE = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} __SCREAMING...
388
_lowerCAmelCase : int =""" # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/huggingface/transformers.g...
113
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase_ = { """configuration_chinese_clip""": [ """CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ChineseCLIPConfig""",...
235
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, AutoT...
113
0
"""simple docstring""" import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore snake_case = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" snake_case ...
103
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken log...
113
0
"""simple docstring""" import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not ...
232
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EX...
113
0
def lowercase__ ( _UpperCamelCase) -> List[Any]: """simple docstring""" UpperCamelCase = hex_num.strip() if not hex_num: raise ValueError('No value was passed to the function') UpperCamelCase = hex_num[0] == "-" if is_nega...
280
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def _A ( SCREAMING_SNAKE_CASE ): # A local function to see if a dot lands in the circle. def is_in_circle(SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ) -> bool: UpperCAmelCase...
113
0
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar UpperCAmelCase_ = TypeVar("""T""") class lowerCamelCase__ ( Generic[T]): """simple docstring""" a__ : Any = 42 # Cache store of keys a__ : Any = 42 ...
2
def _A ( SCREAMING_SNAKE_CASE ): stooge(SCREAMING_SNAKE_CASE ,0 ,len(SCREAMING_SNAKE_CASE ) - 1 ) return arr def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ): if i >= h: return # If first element is smaller than the last then swap them if arr[i...
113
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, loggin...
244
def _A ( SCREAMING_SNAKE_CASE ): UpperCAmelCase__: Tuple = int(SCREAMING_SNAKE_CASE ) if decimal in (0, 1): # Exit cases for the recursion return str(SCREAMING_SNAKE_CASE ) UpperCAmelCase__ , UpperCAmelCase__: Union[str, Any] = divmod(SCREAMING_SNAKE_CASE ,2 ...
113
0
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def A_ ( lowercase_ , lowercase_ ) -> Any: _snake_case : Optional[int] = f'''{sampling_rate}''' _snake_case : Optional[Any] = "1" ...
326
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput _lowerCAmelCase : int ="""scheduler_config.json""" class __UpperCamelCase ( _a ): '''simple docstring''' ...
113
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase : Dict = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: if not is_tor...
529
import unittest from transformers import DonutProcessor _lowerCAmelCase : str ="""naver-clova-ix/donut-base""" class __UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def _UpperCAmelCase ( self ): UpperCAmelCase__: Any = DonutProcessor.f...
113
0
'''simple docstring''' # Copyright 2021 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/li...
489
from __future__ import annotations from typing import Any class __UpperCamelCase : '''simple docstring''' def __init__( self , lowerCamelCase__ ): UpperCAmelCase__: Optional[int] = num_of_nodes UpperCAmelCase__: list[list[int]] = [] UpperCAmel...
113
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase : Any = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], """tokenizati...
214
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accelera...
113
0
"""simple docstring""" from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class __snake_case : """simple docstring""" lowerCAmelCase_ : Any = 42 lowerCAmelCase_ : Optional[int] = None low...
388
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase : Union[str, Any] ={ """configuration_clap""": [ """CLAP_PRETRAINED_MODEL_ARCHIVE_LIST""", """ClapAudioConfig""", """ClapConfig""", """C...
113
0
import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAK...
235
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features import Arr...
113
0
"""simple docstring""" import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class UpperCAmelCase ( _a ): A__ : Dict = (IPNDMScheduler,) A__ : List[Any] = (('''num_inference_steps'''...
103
import fire from utils import calculate_rouge, save_json def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE=None ,**SCREAMING_SNAKE_CASE ): UpperCAmelCase__: Tuple = [x.strip() for x in open(SCREAMING_SNAKE_CASE ).readlines()] UpperCAmelCase__: Dict = [x....
113
0
"""simple docstring""" def _lowerCamelCase ( ) -> Optional[Any]: '''simple docstring''' a__ = [] a__ = 1 while len(UpperCAmelCase__ ) < 1e6: constant.append(str(UpperCAmelCase__ ) ) i += 1 a__ = "".join(UpperCAmelCase__ ) retu...
232
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __UpperCamelCase ( _a ,_a ): '''simple docstring''' @register_to_config def __init__( self , *, lowerCamelCase__ = 4 ...
113
0
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def lowercase__ ( _UpperCamelCase , _UpperCamelCase) -> Union[str, Any]: """simple docstring""" UpperC...
280
from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class __UpperCamelCase ( _a ): '''simple do...
113
0
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 UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { """fac...
2
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def _A ( SCREAMING_SNAKE_CASE ): return input_array.reshape((input_array.size, 1) ) def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SC...
113
0
'''simple docstring''' from math import pi def UpperCamelCase_ ( _UpperCAmelCase : str , _UpperCAmelCase : str ) -> Union[str, Any]: """simple docstring""" return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 1...
244
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py _lowerCAmelCase : int ="""src/transformers""" # This is to make sure the ...
113
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase_ = {"""configuration_glpn""": ["""GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GLPNConfig"""]} try: if not is_vision_available(): raise OptionalDep...
326
def _A ( SCREAMING_SNAKE_CASE ): UpperCAmelCase__ , UpperCAmelCase__: int = [], [] while len(SCREAMING_SNAKE_CASE ) > 1: UpperCAmelCase__ , UpperCAmelCase__: str = min(SCREAMING_SNAKE_CASE ), max(SCREAMING_SNAKE_CASE ) start.append(SCREAMING_SNAK...
113
0
from __future__ import annotations from typing import Any class UpperCAmelCase_ : '''simple docstring''' def __init__( self : Any , UpperCamelCase__ : Any ) -> List[Any]: """simple docstring""" __m...
529
def _A ( SCREAMING_SNAKE_CASE ): # noqa: E741 UpperCAmelCase__: int = len(SCREAMING_SNAKE_CASE ) UpperCAmelCase__: Dict = 0 UpperCAmelCase__: Optional[int] = [0] * n UpperCAmelCase__: List[str] = [False] * n UpperCAmelCase__: List[str] = [False] * n de...
113
0
'''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/li...
489
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_a...
113
0
# 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 switching between checkout...
214
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCAmelCase : Tuple ={ """configuration_mobilenet_v2""": [ """MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileNetV2Config""", "...
113
0
"""simple docstring""" from __future__ import annotations from math import pi, sqrt def __a ( a, a ): """simple docstring""" if inductance <= 0: raise ValueError("Inductance cannot be 0 or negative" ) elif capacitance <= 0: rais...
388
_lowerCAmelCase : int =""" # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/huggingface/transformers.g...
113
0
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def __UpperCamelCase () -> Dict: lowercase__ = { "repo_name": ["test_repo1", "test_repo2", "test_repo3"], "path"...
235
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, AutoT...
113
0
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version snake_case = { """<""": operator.lt, """<=""": operator.le, """==""": operator.eq, """!=""": operator.ne, ""...
103
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken log...
113
0
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging _low...
114
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor _lowerCamelCase = transfo...
114
1
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'google/umt5-small': 'https://huggingface.co/google/umt5-...
114
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase = { 'configuration_clipseg': [ 'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CLIPSegConfig', 'CLIPSegTextConfig', 'CLIPSegVisionCon...
114
1
import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_t...
114
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common import To...
114
1
import random class __A : """simple docstring""" @staticmethod def __snake_case ( a__): """simple docstring""" _lowerCamelCase : str = [ord(a__) for i in text] _lowerCamelCase : List[Any] =...
114
def __UpperCAmelCase( lowercase_ , lowercase_ ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) _lowerCamelCase : int = (boundary[1] - boundary[0]) / steps _lowerCamelCase : Any = boundary[0] _lowerCamelCase : Tuple ...
114
1
from __future__ import annotations def __UpperCAmelCase( lowercase_ , lowercase_ , lowercase_ , lowercase_ ): if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and array[indexa] < array[indexa] ): _lowerCamelCase, _lowerCame...
114
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import...
114
1
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.utils import patch_envi...
114
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def __UpperCAmelCase( lowercase_ ): # vision encoder if "img_encoder.pos_embed" in name: _lowerCamelCase : Tuple = name.replace(...
114
1
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if i...
114
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 PreTrainedTokenizer from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCame...
114
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import TensorTy...
114
import os def __UpperCAmelCase( ): with open(os.path.dirname(lowercase_ ) + '''/p022_names.txt''' ) as file: _lowerCamelCase : Optional[int] = str(file.readlines()[0] ) _lowerCamelCase : List[Any] = names.replace('''"''' , '''''' ).split(...
114
1
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import...
114
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Config...
114
1
from __future__ import annotations def __UpperCAmelCase( lowercase_ , lowercase_ ): if partitions <= 0: raise ValueError('''partitions must be a positive number!''' ) if partitions > number_of_bytes: raise ValueError('''partitions can not > number_of_byte...
114
import mpmath # for roots of unity import numpy as np class __A : """simple docstring""" def __init__( self , a__=None , a__=None): """simple docstring""" _lowerCamelCase : List[str] = list(poly_a or [0])[:] ...
114
1
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import Fla...
114
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging _lowerCamelCase = '\\n\n' _lowerCamelCase = '\nPerplexity (PPL) is one of the most common metrics for eval...
114
1
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class __A ( tf.keras.optimizers.schedules.LearningRateSchedule ): ...
114
from __future__ import annotations from scipy.special import comb # type: ignore class __A : """simple docstring""" def __init__( self , a__): """simple docstring""" _lowerCamelCase : str = list_of_points # ...
114
1
_lowerCamelCase = [ (1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'), (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'), (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I'), ] def __UpperCAmelCase( lowercase_ ): _lowerCamelCase : L...
114
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor _lowerCamelCase = logging.get_logger(__name__) class __A ( lowerCamelCase__ ): """simple docstring""" def __init__( self , *a__ , **a__): ...
114
1
from __future__ import annotations from random import random class __A : """simple docstring""" def __init__( self , a__ = None): """simple docstring""" _lowerCamelCase : Any = value _lowerCamelCase : Lis...
114
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import TensorTy...
114
1
_lowerCamelCase = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} _lowerCamelCase = ['a', 'b', 'c', 'd', 'e'] def __UpperCAmelCase( lowercase_ , lowercase_ , lowercase_ ): _lowerCamelCase : Optional[int] = start # add current t...
114
import doctest from collections import deque import numpy as np class __A : """simple docstring""" def __init__( self): """simple docstring""" _lowerCamelCase : Any = [2, 1, 2, -1] _lowerCamelCase : Optional[i...
114
1
import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings _lowerCamelCase = logging.getLogger...
114
from __future__ import annotations def __UpperCAmelCase( lowercase_ , lowercase_ = None , lowercase_ = None , lowercase_ = False , ): _lowerCamelCase : Tuple = cipher_alphabet or [chr(lowercase_ ) for i in range(97 , 1_23 )] # If the argument is No...
114
1
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 LearnedClassifierFreeSam...
114
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json', # See all ViT MSN models at...
114
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowerCamelCase = { 'configuration_rag': ['RagConfig'], 'retrieval_rag': ['RagRetriever'], 'tokenization_rag': ['RagTokenizer'], } try: if not...
114
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, ...
114
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'xlm-roberta-base': 'https://hugging...
114
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __A ( lowerCamelCase__ )...
114
1
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_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to include /home/n...
114
import copy import random from transformers import CLIPTokenizer class __A ( lowerCamelCase__ ): """simple docstring""" def __init__( self , *a__ , **a__): """simple docstring""" super().__init__(*a__ , **a__) ...
114
1
from __future__ import annotations from typing import Any def __UpperCAmelCase( lowercase_ ): if not postfix_notation: return 0 _lowerCamelCase : Any = {'''+''', '''-''', '''*''', '''/'''} _lowerCamelCase : list[Any] = [] for token in postf...
114
import unittest import numpy as np import requests 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_available...
114
1
from typing import Any class __A : """simple docstring""" def __init__( self , a__): """simple docstring""" _lowerCamelCase : int = data _lowerCamelCase : Optional[Any] = None def __repr__( ...
114
import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": _lowerCamelCase = argparse.ArgumentParser( description=( 'Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for Transfer Le...
114
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'BAAI/AltCLIP': 'https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json', ...
114
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor _lowerCamelCase = transfo...
114
1
import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert import BertConfig from...
114
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase = { 'configuration_clipseg': [ 'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CLIPSegConfig', 'CLIPSegTextConfig', 'CLIPSegVisionCon...
114
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase = { 'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvBertConfig', '...
114
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common import To...
114
1
from __future__ import annotations def __UpperCAmelCase( lowercase_ , lowercase_ ): _lowerCamelCase : List[str] = get_failure_array(lowercase_ ) # 2) Step through text searching for pattern _lowerCamelCase, _lowerCamelCase : Dict = 0, 0 # index into text...
114
def __UpperCAmelCase( lowercase_ , lowercase_ ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) _lowerCamelCase : int = (boundary[1] - boundary[0]) / steps _lowerCamelCase : Any = boundary[0] _lowerCamelCase : Tuple ...
114
1
import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig from transformers.models....
114
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import...
114
1
import doctest from collections import deque import numpy as np class __A : """simple docstring""" def __init__( self): """simple docstring""" _lowerCamelCase : Any = [2, 1, 2, -1] _lowerCamelCase : Optional[i...
114
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def __UpperCAmelCase( lowercase_ ): # vision encoder if "img_encoder.pos_embed" in name: _lowerCamelCase : Tuple = name.replace(...
114
1
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test...
114
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 PreTrainedTokenizer from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCame...
114
1
import argparse from collections import defaultdict import yaml _lowerCamelCase = 'docs/source/en/_toctree.yml' def __UpperCAmelCase( lowercase_ ): _lowerCamelCase : int = defaultdict(lowercase_ ) _lowerCamelCase : str = [] _lowerCamelCase : ...
114
import os def __UpperCAmelCase( ): with open(os.path.dirname(lowercase_ ) + '''/p022_names.txt''' ) as file: _lowerCamelCase : Optional[int] = str(file.readlines()[0] ) _lowerCamelCase : List[Any] = names.replace('''"''' , '''''' ).split(...
114
1
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import...
114
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Config...
114
1
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_KEYS lo...
114
import mpmath # for roots of unity import numpy as np class __A : """simple docstring""" def __init__( self , a__=None , a__=None): """simple docstring""" _lowerCamelCase : List[str] = list(poly_a or [0])[:] ...
114
1
import copy import random from transformers import CLIPTokenizer class __A ( lowerCamelCase__ ): """simple docstring""" def __init__( self , *a__ , **a__): """simple docstring""" super().__init__(*a__ , **a__) ...
114
import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging _lowerCamelCase = '\\n\n' _lowerCamelCase = '\nPerplexity (PPL) is one of the most common metrics for eval...
114
1
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...
114
from __future__ import annotations from scipy.special import comb # type: ignore class __A : """simple docstring""" def __init__( self , a__): """simple docstring""" _lowerCamelCase : str = list_of_points # ...
114
1
from typing import List from .keymap import KEYMAP, get_character def __UpperCAmelCase( lowercase_ ): def decorator(lowercase_ ): _lowerCamelCase : Tuple = getattr(lowercase_ , '''handle_key''' , [] ) handle += [key] setattr(low...
114
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor _lowerCamelCase = logging.get_logger(__name__) class __A ( lowerCamelCase__ ): """simple docstring""" def __init__( self , *a__ , **a__): ...
114
1
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def __UpperCAmelCase( lowercase_ , lowercase_ , lowercase_ ): # Initialise PyTorch model _lowerCa...
114
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import TensorTy...
114
1
import os import sys import unittest _lowerCamelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get_model_to_test_mapping, ...
114
import doctest from collections import deque import numpy as np class __A : """simple docstring""" def __init__( self): """simple docstring""" _lowerCamelCase : Any = [2, 1, 2, -1] _lowerCamelCase : Optional[i...
114
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase = { 'configuration_clipseg': [ 'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CLIPSegConfig', 'CLIPSegTextConfig', 'CLIPSegVisionCon...
114
from __future__ import annotations def __UpperCAmelCase( lowercase_ , lowercase_ = None , lowercase_ = None , lowercase_ = False , ): _lowerCamelCase : Tuple = cipher_alphabet or [chr(lowercase_ ) for i in range(97 , 1_23 )] # If the argument is No...
114
1
import re def __UpperCAmelCase( lowercase_ ): return [char.split() for char in re.split(r'''[^ a-z A-Z 0-9 \s]''' , str_ )] def __UpperCAmelCase( lowercase_ ): _lowerCamelCase : Any = split_input(str_ ) return "".join( [''''''.join([char.capita...
114
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json', # See all ViT MSN models at...
114
1
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def __UpperCAmelCase(...
114
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, ...
114
1