code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase_ = { '''configuration_jukebox''': [ '''JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''JukeboxConfig''', '''Ju...
79
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule, get_constant_sche...
329
0
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf _SCREAMING_SNAKE_CASE : ...
361
'''simple docstring''' import logging import os from .state import PartialState class _snake_case ( logging.LoggerAdapter ): @staticmethod def lowerCAmelCase__ ( a__ ) -> Optional[Any]: '''simple docstring''' snake_case_ = Par...
92
0
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataStructureLi...
7
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json", } class A ( _UpperCAmelCase ): ...
7
1
import torch def lowerCamelCase__ ( ) -> Tuple: if torch.cuda.is_available(): _A: Optional[int] = torch.cuda.device_count() else: _A: int = 0 print(f"""Successfully ran on {num_gpus} GPUs""" ) if __name__ == "__main__": main()
301
def lowerCamelCase__ ( a = 10**9 ) -> int: _A: Dict = 1 _A: Union[str, Any] = 2 _A: List[str] = 0 _A: List[Any] = 0 _A: int = 0 while perimeter <= max_perimeter: perimeters_sum += perimeter prev_value += 2 * value value +...
301
1
from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE_ ...
343
'''simple docstring''' def _A ( lowercase__ = 1000000 ): lowercase__ = [i - 1 for i in range(limit + 1 )] for i in range(2 , limit + 1 ): if phi[i] == i - 1: for j in range(2 * i , limit + 1 , lowercase__ ...
164
0
'''simple docstring''' import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch....
351
'''simple docstring''' import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, Robe...
4
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 : Dict = logging.get_logger(__name__) _UpperCAmelCase : Dict ...
50
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenizerFast, XLMRo...
50
1
'''simple docstring''' import random class __UpperCamelCase : @staticmethod def lowercase__ ( lowerCAmelCase ): """simple docstring""" lowerCamelCase_ =[ord(lowerCAmelCase ) for i in text] lowerCamelCase_ =...
371
'''simple docstring''' import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class ...
6
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils imp...
56
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(""">=""", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint....
92
0
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def __A ( a_ :list[list[float]]) -> list[list[float]]: __a : List[Any] = Decimal # Check if the provided matrix has 2 rows and 2 c...
188
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowercase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [''...
188
1
"""simple docstring""" from __future__ import annotations class lowerCAmelCase_ : '''simple docstring''' def __init__( self , snake_case_ ) -> None: __lowerCAmelCase = order # a_{0} ... a_{k} __lowerCAm...
301
"""simple docstring""" def lowercase (_lowerCAmelCase = 100_0000 ): __lowerCAmelCase = 1 __lowerCAmelCase = 1 __lowerCAmelCase = {1: 1} for inputa in range(2 , _lowerCAmelCase ): __lowerCAmelCase = 0 __lowerCA...
301
1
"""simple docstring""" import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel lowerCamelCase__ = ...
182
"""simple docstring""" import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu,...
182
1
import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, Bert...
88
'''simple docstring''' from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class UpperCAmelCase_ ( __lowercase ): def __lt__( self : Optional[int] , UpperCAmelCa...
4
0
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class lowercase ( a ): lowercase__ : int = (PNDMScheduler,) lowercase__ : int = (("""num_inference_steps""", 50),) ...
206
def __lowerCamelCase (UpperCAmelCase__ : str , UpperCAmelCase__ : str = " " ): SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = 0 for index, char in enumerate(UpperCAmelCase__ ): if char == separator: split_...
206
1
from __future__ import annotations def lowerCAmelCase_ ( A_ ,A_): UpperCamelCase__: str = [] create_all_state(1 ,a__ ,a__ ,[] ,a__) return result def lowerCAmelCase_ ( A_ ,A_ ,A_ ,A_ ,A_ ,): if level == 0: to...
149
def __lowerCAmelCase ( a__ , a__ ) -> float: def get_matched_characters(a__ , a__ ) -> str: __a = [] __a = min(len(_stra ) , len(_stra ) ) // 2 for i, l in enumerate(_stra ): __a = int(max(0 ,...
6
0
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __UpperCAmelCase = collections.namedtuple('''_Datasets''', ['''train'''...
355
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 = { '''google...
42
0
def UpperCAmelCase__ ( _A : Dict ): '''simple docstring''' a__, a__ =[], [] while len(_A ) > 1: a__, a__ =min(_A ), max(_A ) start.append(_A ) end.append(_A ) collection.remove(_A ) collection.remove(_A ) ...
188
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ......
188
1
import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"): SCREAMING_SNAKE_CASE : Tuple = { "linear": PIL.Image.Resampling.BILINEAR, "bilinear": PIL....
352
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Dict = { "bigcode/gpt_bigcode-santacoder": "https://huggingface.co/bigcode/gpt_bigcode-santa...
252
0
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class lowercase__ ( UpperCamelCase_): Up...
182
import itertools import string from collections.abc import Generator, Iterable def A ( _lowercase , _lowercase ): SCREAMING_SNAKE_CASE : Union[str, Any] = iter(_lowercase ) while True: SCREAMING_SNAKE_CASE : Optional[Any] = tup...
182
1
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf A : List[Any] = logging.get_logger(__name...
360
from __future__ import annotations import collections import pprint from pathlib import Path def a__ ( __UpperCamelCase ): return "".join(sorted(__UpperCamelCase ) ) def a__ ( __UpperCamelCase ): return word_by_signature[signature(__UpperCamelCase )] A : st...
305
0
'''simple docstring''' lowerCamelCase :Union[str, Any] = [ [0, 1_6, 1_3, 0, 0, 0], [0, 0, 1_0, 1_2, 0, 0], [0, 4, 0, 0, 1_4, 0], [0, 0, 9, 0, 0, 2_0], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def a ( lowerCamelCase__ , lowerCamelCase__ , lowerC...
206
'''simple docstring''' from math import pow def a ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , ): '''simple docstring''' if current_sum == needed_sum: # If the sum of the powers is equal ...
206
1
import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils import assert_arrow_...
370
def _a ( UpperCAmelCase , UpperCAmelCase ) -> Dict: """simple docstring""" if b == 0: return 1 if (b % 2) == 0: return actual_power(UpperCAmelCase , int(b / 2 ) ) * actual_power(UpperCAmelCase , int(b / 2 ) ) else: return a *...
265
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLNetC...
317
'''simple docstring''' from collections import defaultdict from math import gcd def SCREAMING_SNAKE_CASE__ ( __A = 1_500_000 ) -> int: _snake_case = defaultdict(__A ) _snake_case = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: for euclid_n in range((euclid_m % 2) + 1 ...
42
0
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :Optional[Any] ) -> Any: # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection __lowerCAmelCase : Any = len(SCREAMING_SNAKE_CASE ) __lowerCAmelCase : Unio...
232
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast 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 TokenizerTesterMixin _Uppe...
232
1
"""simple docstring""" from __future__ import annotations def _snake_case ( lowercase__ : str , lowercase__ : str ) -> bool: '''simple docstring''' lowerCAmelCase_ :int = get_failure_array(lowercase__ ) # 2) Step through t...
84
import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --host <host> --key_path <...
252
0
"""simple docstring""" import math def _snake_case ( lowercase__ : int ) -> list: '''simple docstring''' lowerCAmelCase_ :Any = [True] * n lowerCAmelCase_ :Any = False lowerCAmelCase_ :Dict = False low...
369
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __UpperCAmelCase = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Squ...
1
0
"""simple docstring""" import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger UpperCAmelCase_ : Union[str, Any] = """<<<<<<< This should probably be modified because it men...
91
import requests from bsa import BeautifulSoup def UpperCamelCase ( __magic_name__ : str = "AAPL" ) -> str: """simple docstring""" lowercase__ = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' lowercase__ = BeautifulSoup(requests.ge...
305
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise Optional...
350
"""simple docstring""" import sys from collections import defaultdict class a : """simple docstring""" def __init__( self: Union[str, Any] ): """simple docstring""" A__ = [] def UpperCamelCase ( sel...
69
0
import re def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' if len(re.findall('''[ATCG]''' , lowerCAmelCase__ ) ) != len(lowerCAmelCase__ ): raise ValueError('''Invalid Strand''' ) return dna.translate(dna.maketrans('''ATCG''' , '''TAGC''' ) ) if...
101
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils imp...
265
0
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder _A = '''__DUMMY_TRANSFORMERS_USER__''' _A = '''Dummy User''' _A = '''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''' _A = '''https://h...
261
from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('''To use the rich extension, install rich with `pip install rich`''')
261
1
import argparse import datetime def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : str) -> str: '''simple docstring''' __UpperCamelCase : str = { "0": "Sunday", "1": "Monday", "2": "Tuesday", "3": "Wed...
232
from __future__ import annotations import math lowercase : Any = '2020.9.26' lowercase : Union[str, Any] = 'xcodz-dot, cclaus, dhruvmanila' def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCas...
232
1
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils i...
368
# Lint as: python3 import itertools import os import re _UpperCAmelCase : str = re.compile(R"""([A-Z]+)([A-Z][a-z])""") _UpperCAmelCase : Dict = re.compile(R"""([a-z\d])([A-Z])""") _UpperCAmelCase : Dict = re.compile(R"""(?<!_)_(?!_)""") _UpperCAmelCase : Tupl...
200
0
"""simple docstring""" import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class lowercase: '''simple docstring''' def __init__( self: Union[str, Any], a_: Optional[Any], a_: int, a_: int ): '''sim...
64
'''simple docstring''' 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 __A ( UpperCame...
1
0
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 ( BnbQuantizationConfig, Compu...
367
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from diffusers...
139
0
'''simple docstring''' import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = {'vocab_f...
145
"""simple docstring""" from math import factorial def UpperCAmelCase ( UpperCAmelCase = 20 ) -> int: snake_case_ = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... snake_case_ = n // 2 return int(fa...
69
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json", "microsoft/markuplm-large": "https://huggingface.co/mic...
366
"""simple docstring""" import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor __A = logging.get_logger(__name__) class UpperCAmelCase (_UpperCAmelCase ): """simple docstring""" def __init__( self , *_UpperCAme...
2
0
"""simple docstring""" import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_uti...
261
"""simple docstring""" import random def _lowerCamelCase( a , a , a ): __a = a[left_index] __a = left_index + 1 for j in range(left_index + 1 , a ): if a[j] < pivot: __a , __a = a[i], a[j] ...
261
1
"""simple docstring""" def __lowerCamelCase ( __a :float , __a :float ) -> float: """simple docstring""" return price * (1 + tax_rate) if __name__ == "__main__": print(F'''{price_plus_tax(1_0_0, 0.25) = }''') print(F'''{price...
367
def __lowerCamelCase ( __a :int = 3 , __a :int = 7 , __a :int = 1_0_0_0_0_0_0 ) -> int: """simple docstring""" A__ = 0 A__ = 1 for current_denominator in range(1 , limit + 1 ): A__ = cu...
276
0
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torc...
80
'''simple docstring''' from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def snake_case_ ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" _SCREAMING_SNAKE_CASE : Tuple ...
200
0
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCamelCase__ (): _SCREAMING_SNAKE_CASE : List[str] = [randint(-1000, 1000 ) for i in range(10 )] _SCREAMING_SNAKE_CASE : Union[str...
359
from timeit import timeit def lowerCamelCase__ (__lowerCamelCase ): if number < 0: raise ValueError("the value of input must not be negative" ) _SCREAMING_SNAKE_CASE : str = 0 while number: number &= number - 1 result += 1 return...
325
0
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class UpperCamelCase_ ( UpperCAmelCase__ ): '''simple docstring''' UpperCAmelCase__ = (DDPMScheduler,) def SCREAMING_SNAKE_CASE ( self : Optional[in...
14
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "t5-small": "https://huggingface.co/t5-small/resolve/ma...
139
0
'''simple docstring''' def UpperCamelCase_ ( A__ : Optional[Any] ): '''simple docstring''' lowerCAmelCase_ : Dict = [int(__lowerCAmelCase ) for i in ip_va_address.split(""".""" ) if i.isdigit()] return len(__lowerCAmelCase ) == 4 and all(0 <= int...
350
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __snake_case ( unittest.TestCase): """simple docstring""" def __lowercase ( self : Tuple ) -> Dict: ...
89
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor A =logging.get_logger(__name__) class _a ( lowercase_ ): def __init__( self : str , *lowercase : List[str] , **lowercase : Union[str,...
34
'''simple docstring''' class __lowerCAmelCase : # Public class to implement a graph '''simple docstring''' def __init__(self : int , UpperCamelCase : int , UpperCamelCase : int , UpperCamelCase : list[list[bool]] ): '''simple ...
2
0
import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor __snake_case = logging.get_logger(__name__) class lowercase__ ( _UpperCAmelCase ): def __init__( self : List[Any] , *UpperCAmelCase_ : str , **U...
169
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class lowercase__ ( _UpperCAmelCase ): A__ : Any =(CMStochasticIterativeScheduler,) A__ : Optional[int] =1_0 def A_ ( self : Dict , ...
169
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase : List[str] = {'''configuration_speech_encoder_decoder''': ['''SpeechEncoderDecoderConfig''']} try: if not is_torch_available(): ...
124
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A__: List[str] = { '''configuration_chinese_clip''': [ '''CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_M...
276
0
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def A ( ): SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE : Any = 9, 14 # noqa: F841 SCREAMING_SNAKE_CASE : Dict = [ [0, 1, 4]...
258
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.con...
258
1
"""simple docstring""" from pathlib import Path import fire from tqdm import tqdm def __UpperCAmelCase ( lowercase="ro" ,lowercase="en" ,lowercase="wmt16" ,lowercase=None ): """simple docstring""" try: import datasets except (ModuleNotFoundError, ImportError): rai...
289
from math import isqrt, loga def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : int ) -> list[int]: __lowercase = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , ...
325
0
"""simple docstring""" import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm...
365
"""simple docstring""" import logging from transformers.configuration_utils import PretrainedConfig _lowerCAmelCase : Optional[Any] = logging.getLogger(__name__) class A_ ( _a ): lowerCAmelCase__ = 'masked_bert' def __init__( self: Union[str, Any] ,__lowerCAmel...
340
0
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def SCREAMING_SNAKE_CASE__ ( __A ) -> Dict: # picklab...
42
'''simple docstring''' import copy 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 from ..auto import CONFIG_MAPPING __lowerCAmelCase = logging....
89
0
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar SCREAMING_SNAKE_CASE : int = TypeVar("T") class _lowerCamelCase( Generic[T] ): lowercase_ : deque[T] # Cache store of keys lowercase_ : set[T] # R...
84
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE : str = logging.getLogger() def ...
84
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : List[str] = logging.get_logger(__name__) _lowerCAmelCase : Optional[Any] = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json"...
169
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _UpperCamelCase ( lowerCAmelCase ): UpperCAmelCa...
169
1
# 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 by app...
355
_UpperCAmelCase = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} _UpperCAmelCase = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :dict[int, list[int]] , SCREAMING_SNAKE_CASE :int , SCREAMING_SNAKE_CAS...
232
0
'''simple docstring''' import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class __UpperCAm...
258
'''simple docstring''' from __future__ import annotations def __a ( UpperCAmelCase , UpperCAmelCase ) ->Tuple: """simple docstring""" if len(UpperCAmelCase ) <= 1 or n <= 1: return insert_next(UpperCAmelCase , n - 1 ) rec_insertion_sort(UpperCAmelCase , n - ...
258
1
"""simple docstring""" import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class _lowerCAmelCase ( tf.keras.layers.Layer ): d...
355
"""simple docstring""" import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow __snake_case = logging.getLogger() @unittest.skip('''Temporarily...
112
0
from manim import * class __lowerCAmelCase ( UpperCamelCase__): def _lowercase ( self ) -> List[str]: '''simple docstring''' a__ : List[Any] =Rectangle(height=0.5 , width=0.5 ) ...
95
import warnings 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 lowercase__ ( _UpperCAmelCase ): a_ ...
340
0
import numpy as np def lowerCAmelCase( __lowerCamelCase , __lowerCamelCase ): return np.where(vector > 0 , __lowerCamelCase , (alpha * (np.exp(__lowerCamelCase ) - 1)) ) if __name__ == "__main__": import doctest doctest.testmod()
197
from math import sqrt def lowerCAmelCase( __lowerCamelCase ): __a = 0 for i in range(1 , int(sqrt(__lowerCamelCase ) + 1 ) ): if n % i == 0 and i != sqrt(__lowerCamelCase ): total += i + n // i elif i == sqrt(__lowerCam...
197
1
"""simple docstring""" import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = {name: getattr(tra...
84
"""simple docstring""" import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _SCREAMING_SNAKE_C...
84
1
'''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_ = '.' if __name__ == "__main__": a_ = os.path.join(REPO_PATH, 'utils/documentation_tests.txt') a_ ...
222
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', 'InstructBlip...
222
1
'''simple docstring''' import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mode...
258
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : List[Any] = logging.get_logger(__name__) lowercase : Any = { 'google/pegasus-large': 'https://huggingface.co/google/pegasus-large/resolve/main/config.json', # S...
232
0
from collections.abc import Iterable from typing import Generic, TypeVar UpperCAmelCase_ : int = TypeVar('''_T''') class _SCREAMING_SNAKE_CASE ( Generic[_T] ): def __init__( self : Dict , __lowerCamelCase : Iterable[_T] | None = None ): UpperCamelCase :list[_T...
62
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ : Union[str, Any] = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not...
62
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ : List[Any] = {'''configuration_ibert''': ['''IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''IBertConfig''', '''IBertOnnxConfig''']} try: if ...
324
'''simple docstring''' import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DP...
112
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, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_for...
137
from ..utils import DummyObject, requires_backends class lowerCamelCase ( metaclass=A_ ): UpperCAmelCase__ : Union[str, Any] = ["onnx"] def __init__(self : Tuple , *_A : Optional[int] , **_A : Any ) -> Dict: ...
137
1
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licens...
197
"""simple docstring""" from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class _A : def A__ ( self , __lowerCAmelCase ): """simple docstri...
197
1
'''simple docstring''' def __lowerCAmelCase ( UpperCamelCase__ = 1_00_00_00 ) -> int: __lowerCamelCase = 1 __lowerCamelCase = 1 __lowerCamelCase = {1: 1} for inputa in range(2 , UpperCamelCase__ ): __lowerCamelCase = 0 ...
237
'''simple docstring''' def __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> float: if principal <= 0: raise Exception('''Principal borrowed must be > 0''' ) if rate_per_annum < 0: raise Exception('''Rate of interest must be >= 0''' ...
237
1
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase ( _SCREAMING_SNAKE_CASE ): __lowercase ...
222
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPAIN...
222
1
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class __SCREAMING_SNAKE_CASE ( unitte...
361
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration __a = 50_00_00 __a , __a = os.path.split(__file__) __a = os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json''')) @get...
173
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer _A = logging.get_logger(__name__) _A = {'vocab_fi...
62
from __future__ import annotations import math class UpperCAmelCase__ : """simple docstring""" def __init__( self , A_ ) -> None: __UpperCamelCase =size # approximate the overall size of segment tree with given value __UpperCame...
62
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : List[str] = logging.get_logger(__name__) lowerCamelCase_ : str = { """facebook/s2t-wav2vec2-large-en-de""": ( """https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/conf...
223
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mvp import MvpTokenizer lowerCamelCa...
223
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanoramaPipeline, ...
137
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _snake_case ( A__ ): _lowercase : int = '''Speech2TextFeatureExtractor''' _lowercase : List[Any] = '''Speech2TextTokenizer''' def __init__( ...
137
1
"""simple docstring""" class UpperCamelCase : # Public class to implement a graph """simple docstring""" def __init__( self ,UpperCAmelCase_ ,UpperCAmelCase_ ,UpperCAmelCase_ ): _lowercase : Any = row _lowercase : Union[str, Any] ...
369
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( __UpperCAmelCase ): return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
336
0
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @r...
237
'''simple docstring''' import functools def UpperCamelCase ( _lowerCamelCase : str , _lowerCamelCase : str ): A__ = len(_lowerCamelCase ) A__ = len(_lowerCamelCase ) @functools.cache def min_distance(_lowerCamelCase :...
237
1
"""simple docstring""" 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 lowerCAmelCase__ ( __magic_name__ ,...
364
"""simple docstring""" 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_inp...
298
0
import numpy class UpperCAmelCase : '''simple docstring''' def __init__( self : Optional[Any] , lowerCAmelCase_ : numpy.ndarray , lowerCAmelCase_ : numpy.ndarray ): """simple docstring""" _A: Dict = input_array # Random i...
121
"""simple docstring""" import datasets from .evaluate import evaluate _UpperCAmelCase = """\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={EMN...
173
0
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_commo...
350
def __lowerCamelCase ( UpperCAmelCase_ : str ): """simple docstring""" if n_term == "": return [] a :list = [] for temp in range(int(UpperCAmelCase_ ) ): series.append(F'''1/{temp + 1}''' if series else '''1''' ...
281
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .toke...
223
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : int = 10_00 ): lowercase_ , lowercase_ :str = 1, 1 lowercase_ :Any = 2 while True: lowercase_ :str = 0 lowercase_ :Tuple = fa + fa lowercase_ ,...
223
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @require...
42
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = { '''configuration_blip_2''': [ '''BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Blip2Config''', '''Blip2QFormerConfig''', '''Blip...
42
1
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
77
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def a__ ( ) -> tuple[list[int], int]: UpperCAmelCase : str = [randint(-1_000 , 1_000 ) for i in range(10 )] UpperCAmelCase : Any = randint(-5_...
336
0
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class a__ ( lowerCamelCase_ ): _SCREAMING_SNAKE_CASE : Optional[int] = ['image_processor', 'tokenizer'] _SCREAMING_SNAKE_CASE : Tupl...
199
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { 'weiweishi/roc-bert-base-zh': 'https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json', } class a__ ...
199
1
import argparse import logging import pickle from collections import Counter logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) __snake_case : Dict = logging.getLogger(__name__) if __name__ == "__ma...
248
'''simple docstring''' import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_c...
298
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.json', ...
351
'''simple docstring''' import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase=1_024 , __lowerCAmelCase=1_024...
322
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = {} class A ( __UpperCAmelCase ): __snake_case = 'llama' __snake_case = ['past_key_values'] def __init__( self, UpperCamelCase__=3_2000, Up...
278
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a nice m...
281
0
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( A : list[int | str] ): '''simple docstring''' create_state_space_tree(A , [] , 0 , [0 for i in range(len(A ) )] ) def lowerCamelCase__ ( A ...
354
'''simple docstring''' from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCamelCase__: __magic_name__ : int __magic_name__ : TreeNode | None = None __magic_name__ : TreeNode | None = None ...
91
0
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : int = logging.get_logger(__name__) lowercase : Union[str, Any] = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/...
42
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> str: _snake_case = 1 _snake_case = 2 while i * i <= n: _snake_case = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: n_divisors *= 2 return n_div...
42
1
import torch from torch import nn class A__ ( nn.Module ): def __init__( self : Optional[int] , a : Union[str, Any] , a : str , a : str , a : List[Any] , a : List[Any]=1 , a : Tuple=False ): ...
307
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, ids_...
307
1
def a_ ( SCREAMING_SNAKE_CASE__ : list ): '''simple docstring''' if any(not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) or x < 0 for x in sequence ): raise TypeError('Sequence must be list of non-negative integers' ) for _ ...
199
import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast 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 TokenizerTesterMixin lowerCam...
199
1
"""simple docstring""" from ..models.auto import AutoModelForSeqaSeqLM, AutoTokenizer from .base import PipelineTool class lowercase( __a ): '''simple docstring''' lowercase__ = "philschmid/bart-large-cnn-samsum" lowercase__ = ( "This is a to...
358
"""simple docstring""" import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import Pr...
132
0
from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { "huggingface/autoformer-tourism-monthly": "https://huggingface.co/huggingface/autoformer-tourism-monthly/resolv...
299
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_p...
322
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = ...
357
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAM...
65
0
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCamelCase__ ( ) -> tuple[list[int], int]: __snake_case = [randint(-1000 , 1000 ) for i in range(10 ...
24
"""simple docstring""" import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class lowerCAmelCase__ ( UpperCAmelCase__ ): '''simple docstring''' __UpperCamelCase = (PNDMScheduler,) __UpperCamelCase = ...
91
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __A = R'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the model ...
356
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __A = R'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the model outputs. Read the documenta...
75
0
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_commo...
307
def a_ ( _A , _A ) -> int: """simple docstring""" return 1 if input_a == input_a else 0 def a_ ( ) -> None: """simple docstring""" assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) =...
307
1
"""simple docstring""" import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMSchedu...
168
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def a__ ( snake_case__ , snake_case__ , snake_case__ , snake_case__ , snake_case__ , snake_case__ ) -> np.ndarray: # prepare kernel # the kernel siz...
168
1
"""simple docstring""" import itertools import string from collections.abc import Generator, Iterable def UpperCamelCase ( _lowerCAmelCase : Any, _lowerCAmelCase : Optional[Any] ) -> Generator[tuple[str, ...], None, None]: _UpperCAmelCase : List[Any] = iter(__l...
246
"""simple docstring""" import itertools import string from collections.abc import Generator, Iterable def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> Generator[tuple[str, ...], None, None]: SCREAMING_SNAKE_CASE__ : List[Any] = iter(__lowerCAmelCase...
132
0
from math import factorial def __UpperCAmelCase ( __a : int ,__a : int ) -> int: """simple docstring""" if n < k or k < 0: raise ValueError('''Please enter positive integers for n and k where n >= k''' ) return factorial(__a ...
15
from __future__ import annotations def __UpperCAmelCase ( __a : list ) -> float: """simple docstring""" if not nums: raise ValueError('''List is empty''' ) return sum(__a ) / len(__a ) if __name__ == "__main__": import do...
15
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase : Optional[Any] = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise Optio...
27
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 ...
65
0
'''simple docstring''' def SCREAMING_SNAKE_CASE( __lowercase , __lowercase , __lowercase , __lowercase ) -> int: A: Any = len(__lowercase ), len(grid[0] ) if ( min(__lowercase , __lowercase ) < 0 ...
371
'''simple docstring''' import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import Tokeniz...
334
0
"""simple docstring""" from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def A_ ( _lowercase, _lowercase, _lowercase = 10**-10 ): '''simple docstring''' snake_case_ :List[str] = a while True: ...
66
'''simple docstring''' import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
75
0
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_...
221
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder UpperCamelCase = '__DUMMY_TRANSFORMERS_USER__' UpperCamelCase = 'Dummy User' UpperCamelCase = 'hf_hZEmnoOEY...
221
1
'''simple docstring''' 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 a_ : int = loggi...
168
'''simple docstring''' import os import re 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 logging a_ : Optional[Any] = log...
168
1
import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def A(__a: Optional[Any] , __a: int , __a: List[str] , __a: int=5 ): # Adapted from https://github.com/pytorch/fairseq/blob/master/fairseq/models/roberta/hub_interface.py assert masked_input.count("<mask>" ) =...
22
def A(__a: Tuple ): lowerCAmelCase_ = len(__a ) while cur > 1: # Find the maximum number in arr lowerCAmelCase_ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi lowerCAmelCase_ = arr[mi::-1] + arr[mi + 1 : len(__a )] # Reve...
22
1