code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE :Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :Dict = { 'k...
55
import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class SCREAMING_SNAKE_CASE ( lowerCAmelCase , unittest.Tes...
62
0
'''simple docstring''' from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class a ( snake_case__ ): '...
424
'''simple docstring''' UpperCAmelCase_ : Union[str, Any] = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio from .feat...
424
1
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoToke...
132
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'studio-ousia/luke-large': 'https://huggingface...
132
1
'''simple docstring''' from collections.abc import Iterable from typing import Generic, TypeVar lowerCAmelCase : Optional[Any] = TypeVar("""_T""") class _UpperCamelCase ( Generic[_T]): '''simple docstring''' def __init__( self , a_ = None ) -> ...
425
'''simple docstring''' import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import classes f...
425
1
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import is_flaky, 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 i...
523
'''simple docstring''' from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMix...
523
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCA...
648
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) lowerCAmelCase__ = { """sample_size""": 3_2, """in_channels""": 3, """out_channels""": 3, """layers_per_block""": 2, """num_class_embeds""...
648
1
'''simple docstring''' import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, requ...
51
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchau...
292
0
"""simple docstring""" import unittest import numpy as np from transformers import RobertaConfig, 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_...
197
"""simple docstring""" import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, ...
197
1
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class _UpperCAmelCase ( __low...
145
def _lowercase ( __lowerCamelCase : Optional[int] ,__lowerCamelCase : Dict ,__lowerCamelCase : str ,__lowerCamelCase : Optional[int] ) -> List[str]: '''simple docstring''' global f # a global dp table for knapsack if f[i][j] < 0...
344
0
'''simple docstring''' def lowercase_ ( __A : str , __A : Dict ) -> int: """simple docstring""" return number | (1 << position) def lowercase_ ( __A : Union[str, Any] , __A : List[Any] ) -> int: """sim...
717
'''simple docstring''' from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ...
8
0
import argparse import os import re import packaging.version SCREAMING_SNAKE_CASE :Optional[Any] = """examples/""" SCREAMING_SNAKE_CASE :Dict = { """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), ...
628
import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE :Optional[Any] = { """facebook/mask2former-swin-small-coco-instance""": ( """https://huggingf...
628
1
"""simple docstring""" from __future__ import annotations def __a ( A , A , A ): '''simple docstring''' lowercase__ = list(range(len(A ) ) ) lowercase__ = [v / w for v, w in zip(A , A )] index.sort(key=lambda A ...
715
"""simple docstring""" import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import Flax...
668
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 = logging.get_logger(__name__) __A = { "facebook/data...
325
def lowerCAmelCase ( UpperCAmelCase ) ->str: """simple docstring""" return " ".join( ''''''.join(word[::-1] ) if len(UpperCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest do...
154
0
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational i...
721
'''simple docstring''' import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import comput...
502
0
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging SCREAMING_SNAKE_CASE :Tuple = logging.get_logger(__name__) def UpperCAmelCase ( a_...
55
import os def UpperCAmelCase ( ) -> Any: """simple docstring""" __A = os.path.dirname(os.path.realpath(a_ ) ) __A = os.path.join(a_ , "triangle.txt" ) with open(a_ ) as f: __A = f.readlines() __A = [] f...
55
1
import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging lowercase__ : str = logging.get_logger(__name__) def A_ ( ...
706
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
451
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 from transformer...
50
'''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...
50
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """andreasmadsen/efficient_mlm_m0...
706
'''simple docstring''' from math import log from scipy.constants import Boltzmann, physical_constants _lowercase = 300 # TEMPERATURE (unit = K) def A (__lowerCamelCase :float , __lowerCamelCase :float , __lowerCamelCase :float , ): if donor_conc <= 0: raise V...
162
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transf...
602
"""simple docstring""" from __future__ import annotations from collections import deque class _a : """simple docstring""" def __init__( self : int , __UpperCamelCase : list[str] )->Dict: _UpperCAmelCase = [] self.adlist.append( ...
602
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging logg...
701
import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput ...
224
0
'''simple docstring''' def _snake_case ( A_ : int ): """simple docstring""" if number > 0: raise ValueError("""input must be a negative integer""" ) a_ : str = len(bin(_snake_case )[3:] ) a_ : str = bin(abs(_snake_case ) - (1 << binary_num...
577
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A : int = get_logger(__name__) A : Dict = r'\n Args:\n input_ids (`jnp....
516
0
import string from math import logaa def SCREAMING_SNAKE_CASE( __UpperCamelCase , __UpperCamelCase ) -> int: a__ : str = document.translate( str.maketrans("" , "" , string.punctuation ) ).replace("\n" , "" ) a__ : int = docum...
720
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse("""3.8"""): import importlib_metadata else: import importlib.metadata as importlib_metadata lowerCamelCase = ...
207
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_squeezebert import SqueezeBertTokenizer SCREAMING_SNAKE_CASE = logging.g...
554
'''simple docstring''' from queue import PriorityQueue from typing import Any import numpy as np def UpperCAmelCase ( A : dict , A : str , A : set , A : set , A : dict , A : dict , A : PriorityQueue , A : dict...
527
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel...
590
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass UpperCAmelCase_ : Dict = (3, 9, -11, 0, 7, 5, 1, -1) UpperCAmelCase_ : Optional[Any] = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class _SCREAMING_SNAKE_CASE : s...
590
1
# 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 # # Unless required by a...
312
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enabl...
312
1
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, requ...
180
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import (...
180
1
from __future__ import annotations import os from typing import Any import requests UpperCamelCase__ ='''https://api.github.com''' # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user UpperCamelCase__ =BASE_URL + '''/user''' # https://github.com/settings/t...
249
import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp fr...
445
0
'''simple docstring''' import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase : Union[str, Any] = logging.get_logger(__name__) lowercase : Any = { '''vocab_file''':...
721
def lowerCAmelCase__ ( _a : str , _a : int ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) snake_case_ : Optional[Any] = (boundary[1] - boundary[0]) / steps snake_case_ : str = boundary[0] snake_case_ ...
114
0
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_p...
432
'''simple docstring''' def UpperCamelCase ( a , a ) -> float: '''simple docstring''' return price * (1 + tax_rate) if __name__ == "__main__": print(F'''{price_plus_tax(100, 0.25) = }''') print(F'''{price_plus_tax(125.50, 0.05) = }''')
432
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky...
569
import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def __lowerCamelCase ( snake_case__ ,snake_case__ ,snake_case__ ,snake_case__ ,sn...
569
1
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class UpperCAmelCase__( yaml.SafeLoader ): '''simple docstring''' def UpperCAmelCase ( self : str , lowerCAmelCase : Any) -> Optional[Any]: ...
622
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if not is_torch_available(): raise ...
486
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 A__ : List[str] = logging.get_logger(__name__) A__ : Optional[Any] = { ...
671
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration A__ : Dict = 50_00_00 A__ , A__ : str = os.path.split(__file__) A__ : Optional[Any] = os.path.join(RESULTS_BASEPATH, 'res...
671
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __a :int = {'configuration_swin': ['SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SwinConfig', 'SwinOnnxConfig']} try: if not is_torch_available(): ...
86
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a_ : Tuple = {'configuration_unispeech': ['UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP', 'UniSpeechConfig']} ...
623
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 = {'vocab_file': 'spiece.model'} _sn...
567
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def _a ( ) -> Tuple: """simple docstring""" __UpperCamelCase , __UpperCamelCase = 9, 14 # noqa: F841 __UpperCamelCase = [ ...
567
1
from __future__ import annotations _lowerCamelCase : Any = [True] * 1_000_001 _lowerCamelCase : Any = 2 while i * i <= 1_000_000: if seive[i]: for j in range(i * i, 1_000_001, i): _lowerCamelCase : Optional[int] = False i += 1 def ...
352
from datetime import datetime import matplotlib.pyplot as plt import torch def __a ( __lowerCAmelCase ) -> int: for param in module.parameters(): SCREAMING_SNAKE_CASE : List[Any] = False def __a ( ) -> List[str]: SCREAMIN...
352
1
"""simple docstring""" from __future__ import annotations __lowerCamelCase :int = 1.6_021e-19 # units = C def snake_case ( UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float , ) -> tuple[str, float]: if ...
706
"""simple docstring""" import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __lowerCamelCase :str = get_tests_dir...
42
0
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar lowercase_: Tuple = TypeVar('T') class lowercase__ (Generic[T] ): """simple docstring""" __UpperCamelCase : deque[T] # Cache...
648
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration lowercase_: Tuple = { 'tiny.en': 'https://openaipublic.azureedge.net/main/wh...
648
1
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class UpperCamelCase ( lowercase__ ): ...
441
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def Uppe...
441
1
def _SCREAMING_SNAKE_CASE ( ) -> Tuple: """simple docstring""" __A = [] __A = 1 while len(UpperCamelCase__ ) < 1E6: constant.append(str(UpperCamelCase__ ) ) i += 1 __A = """""".join(UpperCamelCase__ ) ...
637
'''simple docstring''' 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 ImageProcessingSavin...
407
0
'''simple docstring''' from functools import reduce a_ : Any = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "1254069874715852386305071569329096...
532
'''simple docstring''' import datasets a_ : List[Any] = "\\n@InProceedings{conneau2018xnli,\n author = \"Conneau, Alexis\n and Rinott, Ruty\n and Lample, Guillaume\n and Williams, Adina\n and Bowman, Samuel R.\n ...
532
1
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _lowerCamelCase : Optional[Any] = get_tests_dir("""fixtures/test_sentencep...
87
'''simple docstring''' import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py A__ : Optional[int] ='''.''' if __name__ == "__main__": A__ : int =os.path.join(...
207
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def _lowerCamelCase ( _a ): """simple docstring""" _lowerCamelCase = prime_factors(_a ) if is_square_free(_a ): return -1 if len(_a ) % 2 else 1 return 0 if __name__ ==...
715
from __future__ import annotations from collections.abc import MutableSequence class __magic_name__ : """simple docstring""" def __init__( self , a__ , a__ ): if len(a__ ) != degree + 1: raise ValueError( '''The number of coefficients should be equal to the degree + 1....
297
0
'''simple docstring''' import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_...
444
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase : Any = { """configuration_canine""": ["""CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """C...
444
1
"""simple docstring""" from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizatio...
710
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : Dic...
176
0
"""simple docstring""" import functools def UpperCamelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): # Validation if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) or not all(isinstance(SCREAMING_SNAKE_CASE , SCREAM...
102
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e im...
259
0
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class _UpperCAmelCase ( lowercase ): lowerCamelCase_ : Union[str, Any] = """EncodecFeatureExtractor""" lowerCamelCase_ : Any = ("""T5Tokenizer""",...
140
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, ) SCREAMING_SNAKE_CASE__ = { "configuration_albert": ["ALBERT_PRE...
140
1
'''simple docstring''' import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class lowercase_ ( unittest.TestCase , _UpperCamelCase ): """simple docstring""" def __UpperCAmelCase ( self : List[str] ) -> Union[s...
107
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEA...
542
0
'''simple docstring''' import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoToken...
714
'''simple docstring''' import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset fro...
11
0
import requests UpperCAmelCase = '''''' # <-- Put your OpenWeatherMap appid here! UpperCAmelCase = '''https://api.openweathermap.org/data/2.5/''' def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE = "Chicago" , __SCREAMING_SNAKE_CASE = APPID ): return requests.get(URL_BASE ...
84
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class _SCREAMING_SNAKE_CASE : lowerCAmelCase__ = 42 # [batch_size x 3] lowerCAmelCase__ = 42 # [batch_size x 3] lowerCAmelCase__ = 42 # [batch_size x 3] lowerCAmelCase__ = 42...
463
0
class lowercase__ : def __init__( self : List[Any] , _lowercase : Dict , _lowercase : Dict , _lowercase : str ): """simple docstring""" UpperCAmelCase__ = name UpperCAmelC...
716
from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance A = 6378137.0 A = 6356752.314245 A = 637_8137 def __UpperCAmelCase ( __A , __A , __A , __A ) -> float: '''simple docstring''' ...
277
0
"""simple docstring""" import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...tes...
169
"""simple docstring""" from math import log from scipy.constants import Boltzmann, physical_constants a = 3_0_0 # TEMPERATURE (unit = K) def lowercase (snake_case__ : float , snake_case__ : float , snake_case__ : float , ) -> float: '''simple docstr...
169
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCamelCase = { '''configuration_bridgetower''': [ '''BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BridgeTowerConfig''', '''Bri...
478
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase = { '''configuration_pegasus_x''': ['''PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusXConfig'''], } try: if not is_torch_available(): ...
478
1
'''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 # ...
92
'''simple docstring''' import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def _a (__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE=1024 ): """simple docstring""" _UpperCa...
404
0
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() _UpperCamelCase : Tuple =logging.get_logger(__name__) def a__ (__lowercase :Optio...
332
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record _UpperCamelCase : Union[str, Any] ='\\n@article{wang2019superglue,\n title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems},...
332
1
'''simple docstring''' import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker fro...
378
'''simple docstring''' from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concaten...
229
0
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger __a = get_logger(__name__) class __lowercase ( enum.Enum ): UpperCamelCase = '''all_checks''' UpperCamelCase = ...
627
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __lowercase ( unittest.TestCase ): def _lowercase ( self : ...
627
1
'''simple docstring''' import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A_ : Dict = logging.get_logger(__name__) A_ : Union[str, Any] = { "vocab_file": "vocab....
38
import math snake_case__ = 10 snake_case__ = 7 snake_case__ = BALLS_PER_COLOUR * NUM_COLOURS def lowerCamelCase__ ( a : int = 20 ) -> str: """simple docstring""" a__ :List[str] = math.comb(a , a ) a__ :Optional[int] ...
395
0
"""simple docstring""" import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class snake_case : def __init__(self , SCREAMING_SNAKE_CASE_ ): """simple docstring""" ...
708
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def ...
628
0
"""simple docstring""" from __future__ import annotations def UpperCamelCase__ ( lowercase__ : list[float] ): snake_case : Optional[Any] = 0.00 snake_case : Any = 0 for resistor in resistors: if resistor <= 0: snake_case : List[str...
134
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch...
134
1
'''simple docstring''' # Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def _SCREAMING_SNAKE_CASE ( A : Union[str, Any] , A : Any , A : Tuple ) -> Any: """simple docstring""" __snake_case ...
61
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( A : list ) -> list: """simple docstring""" __snake_case : Tuple = False while is_sorted is False: # Until all the indices are traversed keep looping __snake_case : ...
61
1
from collections import defaultdict from math import ceil, sqrt def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ = 1000000 , SCREAMING_SNAKE_CASE__ = 10 ): snake_case_ = defaultdict(SCREAMING_SNAKE_CASE__ ) for outer_width in range(3 , (t_limit // 4) + 2 ): ...
39
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE__ ( lowercase ): """simple docstring""" a : int ="Speech2TextFeatureExtractor" a : int ="Speech...
645
0
"""simple docstring""" import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def A ( snake_case__ , snake_case__ , snake_case__ ): ...
719
"""simple docstring""" import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging A_ : Un...
616
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: ...
693
import argparse import json from tqdm import tqdm def _A ( ) -> Optional[int]: """simple docstring""" __SCREAMING_SNAKE_CASE = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=__snake_case , defau...
693
1
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokeni...
600
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( __UpperCAmelCase ): if n == 1 or not isinstance(__UpperCAmelCase , __UpperCAmelCase ): return 0 elif n == 2: return 1 else: _lowercase : int = [0, 1] for i in range(2 , n + 1 ): ...
600
1
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetYaagf, Re...
23
"""simple docstring""" from collections.abc import Callable class a__ : def __init__( self :Tuple , _lowerCamelCase :Callable | None = None ): '''simple docstring''' UpperCamelCase_ : list =[] # Stores indexes of each item for supporting u...
357
0
from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ChannelDimension, ImageInput, ...
161
from math import ceil def UpperCamelCase( lowercase_ , lowercase_ ) -> Any: '''simple docstring''' snake_case_ = list(range(0 , lowercase_ ) ) snake_case_ = [item for sublist in list(device_map.values() ) for item in sublist] # D...
161
1
from math import ceil def __a ( A__ : str , A__ : Optional[Any] ): SCREAMING_SNAKE_CASE = list(range(0 , A__ ) ) SCREAMING_SNAKE_CASE = [item for sublist in list(device_map.values() ) for item in sublist] # Duplicate c...
16
def UpperCAmelCase ( lowercase , lowercase ): """simple docstring""" __lowercase = word.split() def justify(lowercase , lowercase , lowercase ) -> str: __lowercase = max_width - width __lowercase = len(lo...
534
0
import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available from ...
705
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = [ ["""attention""", """attn"""], ["""encoder_at...
648
0
from abc import ABC, abstractmethod from argparse import ArgumentParser class _lowerCAmelCase ( UpperCAmelCase_ ): '''simple docstring''' @staticmethod @abstractmethod def UpperCamelCase_ ( UpperCamelCase : ArgumentParser ): '''simple docstring''' ...
411
def lowerCamelCase_ ( lowerCAmelCase: str )-> str: _snake_case : str = 0 # if input_string is "aba" than new_input_string become "a|b|a" _snake_case : List[Any] = '' _snake_case : Dict = '' # append each character + "|" in new_strin...
411
1
"""simple docstring""" import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( Alber...
719
"""simple docstring""" from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_conf...
215
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : int = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): ...
49
import requests _SCREAMING_SNAKE_CASE : Optional[int] = "" # <-- Put your OpenWeatherMap appid here! _SCREAMING_SNAKE_CASE : Optional[Any] = "https://api.openweathermap.org/data/2.5/" def UpperCAmelCase__ (UpperCamelCase_ = "Chicago" ,UpperCamelCase_ = APPID ...
550
0
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class _UpperCamelCase ( lowerCAmelCase ): UpperCAmelCase_ ...
717
import math def lowerCAmelCase ( _lowerCAmelCase : int ): """simple docstring""" UpperCAmelCase__ = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(_lowerCAmelCase ) def lowerCAmelCase ( _lowerCAmelCase : float = 1...
364
0
'''simple docstring''' from __future__ import annotations from random import random class lowerCAmelCase : def __init__( self , __SCREAMING_SNAKE_CASE = None ) -> Any: '''simple docstring''' __snake_case = value __snake_case ...
24
import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTe...
149
0
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 : Tuple = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" snake_case : Optional[int] = [file for ...
706
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case : Dict = logging.get_logger(__name__) snake_case : Any = {name: getattr(transformers, name + '''Fast''') for na...
657
0
"""simple docstring""" from __future__ import annotations A : str = 'Muhammad Umer Farooq' A : Dict = 'MIT' A : Optional[Any] = '1.0.0' A : Optional[int] = 'Muhammad Umer Farooq' A : Tuple = 'contact@muhammadumerfaroo...
516
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -...
516
1
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=UpperCamelCase ) class UpperCAmelCase__ ( UpperCamelCase ): lowerCAmelC...
109
"""simple docstring""" from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def lowerCAmelCase__ ( ) -> Optional[Any]: import os as original_os from os import path as original_path from os import rename as original_rename ...
109
1
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : int ) -> str: '''simple docstring''' if isinstance(__lowercase , __lowercase ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(__lowercase , __lower...
236
'''simple docstring''' import os import unittest from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
236
1
'''simple docstring''' import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def _lowerCamelCase ( lowercase : str , lowercase : i...
521
'''simple docstring''' import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def _lowerCamelCase ( lowercase : str , lowercase : i...
521
1
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=_A ): """simple docstring""" A = ['''torch'''] def __init__( self , *_lowerCAmelCase , **_lowerCAmelCase ): '''simple docstring''' requires_...
145
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class _UpperCAmelCase ( _A ): """simple docstring""" A = '''EncodecFeatureExtractor''' A = ('''T5Tokenizer''', '''T5TokenizerFas...
145
1
def lowerCamelCase__ ( _lowercase = 1000 ): '''simple docstring''' return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
300
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tens...
300
1
"""simple docstring""" 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 .....
19
"""simple docstring""" from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_comm...
599
0
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : Dict = logging.get_logger(__name__) snake_case_ : List[Any] = { """asapp/sew-tiny-100k""": """https://huggingface.co/as...
292
"""simple docstring""" def lowercase_ ( _lowercase : int , _lowercase : int ): '''simple docstring''' return int(input_a == input_a == 0 ) def lowercase_ ( ): '''simple docstring''' print("Truth Table of NOR Gate:" ) print("| I...
292
1
'''simple docstring''' from itertools import product def lowerCamelCase ( lowerCAmelCase : int , lowerCAmelCase : int ): """simple docstring""" __magic_name__ : Any = sides_number __magic_name__ : List[str] = max_face_numbe...
561
'''simple docstring''' import os lowerCAmelCase :Dict = {'''I''': 1, '''V''': 5, '''X''': 1_0, '''L''': 5_0, '''C''': 1_0_0, '''D''': 5_0_0, '''M''': 1_0_0_0} def lowerCamelCase ( lowerCAmelCase : str ): """simple docstring""" __magic_name__ : str ...
561
1
"""simple docstring""" import operator def lowerCAmelCase ( UpperCamelCase_: list , UpperCamelCase_: bool = False , UpperCamelCase_: list | None = None ) -> list: '''simple docstring''' _a = operator.lt if reverse else operat...
719
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowerCAmelCase ( UpperCamelCase_: ndarray ) -> float: '''simple docstring''' return np.dot(UpperCamelCase_ , Uppe...
612
0
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProcessing cla...
670
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def snake_case ( A__ ): UpperCAmelCase_ : int = int(number**0.5 ) return number == sq * sq def snake_case ( A__ ,A__ ,A__ ,A__ ,A__ ,A...
95
0
from collections.abc import Callable class lowerCamelCase__ : def __init__(self : Tuple , _snake_case : Callable | None = None ) -> None: """simple docstring""" lowerCamelCase_ : list = [] # Stores indexes of each...
702
import argparse import collections import json import os import re import string import sys import numpy as np UpperCamelCase = re.compile(r'''\b(a|an|the)\b''', re.UNICODE) UpperCamelCase = None def _a ( ) -> Tuple: lowerCamelCase_ : Optional[int] = ar...
144
0
'''simple docstring''' import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class __UpperCamelCase ( unittest.TestCase ): def __UpperCAmelCase ( self ): '''simple docstring''' ...
476
'''simple docstring''' from queue import PriorityQueue from typing import Any import numpy as np def lowerCamelCase (_SCREAMING_SNAKE_CASE : dict , _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : set , _SCREAMING_SNAKE_CASE : set , _SCREAMING_SNAKE_CASE : dict , _SCREAMING_SNAKE_CASE...
476
1
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert_switc...
321
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...
321
1
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import...
308
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_common import TokenizerTe...
457
0
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __lowercase( __lowercase ): '''simple...
705
"""simple docstring""" from cva import destroyAllWindows, imread, imshow, waitKey def UpperCAmelCase ( A__: Tuple ) -> Union[str, Any]: # getting number of pixels in the image __lowerCamelCase , __lowerCamelCase : Optional[Any] = img.shape[0], img.shape[1]...
263
0
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_available(): impo...
439
import re from filelock import FileLock try: import nltk a_ : Optional[Any] = True except (ImportError, ModuleNotFoundError): a_ : Union[str, Any] = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True) def ...
439
1
'''simple docstring''' import torch from diffusers import DiffusionPipeline class a ( snake_case__ ): '''simple docstring''' def __init__( self , lowerCamelCase_ , lowerCamelCase_ ) -> Tuple: super().__init__() self.register_modules(unet=lowerCamelCase_ , ...
701
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : Optional[int] = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } ...
424
0
from ...processing_utils import ProcessorMixin class _lowerCAmelCase ( __magic_name__ ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[int] ="SpeechT5FeatureExtractor" SCREAMING_SNAKE_CASE_ : Optional[Any] ="SpeechT5Tokenizer" def __init__( ...
282
import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPR_CONT...
282
1
"""simple docstring""" def __lowercase ( a : int ) -> bool: if not isinstance(a , a ): raise ValueError('''check_bouncy() accepts only integer arguments''' ) __snake_case : List[str] =str(a ) __snake_case : Optional[int] ='''...
497
"""simple docstring""" def __lowercase ( a : str , a : str ) -> str: __snake_case : int =len(a ) __snake_case : int =len(a ) __snake_case : int =( first_str_length if first_str_length > second_str_length else sec...
497
1
from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_allow_in_g...
268
# Copyright 2021 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 # # Unless required ...
268
1
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
328
from typing import 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 ....file_utils import...
328
1
"""simple docstring""" import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __A = logging.get_logger(__name__) class UpperCAmelCase (a__ ): """simple docstring""" _UpperCA...
586
"""simple docstring""" import inspect import unittest from transformers import ConvNextConfig 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 Backbo...
646
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor __lowercase = logging.get_logger(__name__) class _lowercase ( _A ): """simple docstring""" def __init__( se...
717
"""simple docstring""" from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor ...
296
0
'''simple docstring''' import math from datetime import datetime, timedelta def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" lowerCAmelCase__ : Optional[Any] = year % 19 lowerCAmelCase__ : Tuple = year % 4 lowerCAmelCase__ : ...
565
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.uti...
283
0
'''simple docstring''' from __future__ import annotations from fractions import Fraction def _lowerCamelCase ( lowerCamelCase_ : int , lowerCamelCase_ : int ): """simple docstring""" return ( num != den and num % 10 == den // 10 and (num // 10) /...
701
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __...
389
0