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
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch ...
49
import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_availabl...
345
0
"""simple docstring""" import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO, ) _...
370
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase: Dict = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_av...
53
0
"""simple docstring""" import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer __A : List[Any] = logging.getLogger(__name__) def lowercase ( ): '''simple docstring''' ...
260
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_see...
260
1
'''simple docstring''' from __future__ import annotations UpperCAmelCase = tuple[int, int, int] UpperCAmelCase = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase UpperCAmelCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # -------------------------- defau...
350
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) class __snake_case( _lowerCAmelCase ): '''simple docstring''' UpperCAmelCase : Optional[int] = "ti...
187
0
import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transformers.mod...
92
from random import randint from tempfile import TemporaryFile import numpy as np def _a ( SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : List[str] ): __lowerCAmelCase = 0 if start < end:...
92
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available()...
347
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_transforme...
347
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase_ = { '''configuration_convnext''': ['''CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ConvNextC...
8
"""simple docstring""" import argparse import collections import json import os import re import string import sys import numpy as np _UpperCamelCase : Any = re.compile(r"\b(a|an|the)\b", re.UNICODE) _UpperCamelCase : Union[str, Any] = None def a_ ( ): ...
77
0
from ...configuration_utils import PretrainedConfig from ...utils import logging A : List[Any] = logging.get_logger(__name__) A : int = { "microsoft/trocr-base-handwritten": ( "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json" ...
371
import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( "The `image_to_image.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionImg2ImgPipeline` instead." )
305
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Tuple = logging.get_logger(__name__) a_ : Dict = { """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json""", } ...
55
"""simple docstring""" 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 from .tokenization_gpta import GPTaTokeniz...
316
0
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline lowerCamelCase_ = logging.get_logger(__name__) # pylint: disable=invalid-name class __A( __lowerCamelCase ): ""...
178
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCamelCase_ = { '''configuration_canine''': ['''CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CanineConfig'''], '''tokenization_canine''': ['''Canine...
178
1
"""simple docstring""" from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets __A : List[Any] = '''\ @inproceedings{wang2019glue, title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Und...
33
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowercase ( __snake_case : str , __snake_case : str , __snake_case : Optional[str] = None ): if version.par...
33
1
'''simple docstring''' from __future__ import annotations def _lowerCamelCase ( lowerCamelCase_ : Optional[Any] ): """simple docstring""" UpperCAmelCase_ : Optional[Any] = [True] * limit UpperCAmelCase_ : int = False UpperCAmelC...
361
'''simple docstring''' def _lowerCamelCase ( lowerCamelCase_ : str , lowerCamelCase_ : str = " " ): """simple docstring""" UpperCAmelCase_ : str = [] UpperCAmelCase_ : List[Any] = 0 for index, char in enumerate(lowe...
274
0
import requests def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): A_ : List[str] = {'''Content-Type''': '''application/json'''} A_ : Union[str, Any] = requests.post(SCREAMING_SNAKE_CASE , json={'''text''': message_body} , headers=SCREAM...
186
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaXLForSequenceClas...
186
1
def A__ ( lowerCamelCase ) -> bool: if num < 0: return False UpperCamelCase_: int = num UpperCamelCase_: int = 0 while num > 0: UpperCamelCase_: int = rev_num * 10 + (num % 10) num //= 10 return num_copy == rev_num if __name__ == "__m...
223
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class _UpperCamelCase ( unittest.TestCase ): '''simple docstring''' @r...
223
1
'''simple docstring''' def lowerCamelCase ( __lowerCamelCase : str ) ->list: return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__lowerCamelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("""doctest""").testmo...
58
"""simple docstring""" def __lowerCAmelCase ( lowercase : list ) -> int: """simple docstring""" if not grid or not grid[0]: raise TypeError("The grid does not contain the appropriate information" ) for cell_n in range(1 , len(grid[0] ) ): grid[0][c...
203
0
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBench...
356
'''simple docstring''' import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, ...
240
0
from __future__ import annotations __UpperCAmelCase = list[list[int]] # assigning initial values to the grid __UpperCAmelCase = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], [0...
299
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging a__ : Any ...
53
0
import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UNCONDITIONAL_IM...
137
class lowerCamelCase : def __init__(self : List[Any] , _A : str ) -> Any: # we need a list not a string, so do something to change the type snake_case = arr.split("," ) def UpperCAmelCase(self : str ) ...
137
1
"""simple docstring""" from torch import nn def __lowercase ( snake_case_ : str ) ->str: '''simple docstring''' if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GEL...
179
from __future__ import annotations def lowerCamelCase__ ( _A ): '''simple docstring''' snake_case_ = str(_A ) return len(_A ) == 9 and set(_A ) == set("123456789" ) def lowerCamelCase__ ( ): '''s...
187
0
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def lowerCamelCase__ ( A__ : Optional[int] ): '''simple docstring''' __lowerCamelCase = {} ...
29
import requests from bsa import BeautifulSoup def lowerCamelCase__ ( A__ : str = "https://www.worldometers.info/coronavirus" ): '''simple docstring''' __lowerCamelCase = BeautifulSoup(requests.get(A__ ).text , """html.parser""" ) __lowerCamelCase ...
29
1
'''simple docstring''' lowercase__ : Optional[int] = { '''meter''': '''m''', '''kilometer''': '''km''', '''megametre''': '''Mm''', '''gigametre''': '''Gm''', '''terametre''': '''Tm''', '''petametre''': '''Pm''', '''exametre''': '''Em''', '''zettametre''': '''Zm''',...
324
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 must be checked before tokenizers lower...
329
0
from __future__ import annotations from collections.abc import Callable def SCREAMING_SNAKE_CASE ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 1_00 , ) -> float: a = x_start a = fnc(__UpperCamelCase) a = 0.0 for _ ...
180
def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> int: return 1 if digit in (0, 1) else (digit * factorial(digit - 1)) def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> bool: a = 0 a = number while duplicate > 0: a , a = ...
180
1
"""simple docstring""" def __lowercase ( _a , _a , _a , _a ): snake_case_ : Optional[Any] = [False] * len(_a ) snake_case_ : Tuple = [] queue.append(_a ) snake_case_ : List[Any] = True while queue: snake_case_ : str = queue.pop(0 ...
264
import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transfor...
305
0
"""simple docstring""" from string import ascii_lowercase, ascii_uppercase def _snake_case ( _snake_case : Optional[int] ) -> Union[str, Any]: '''simple docstring''' if not sentence: return "" _A = dict(zip(_A , _A ) ...
353
"""simple docstring""" import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_availa...
271
0
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common impo...
178
from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase = {"processing_wav2vec2_with_lm": ["Wav2Vec2ProcessorWithLM"]} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys lowercase = _LazyModule(__name__, globals...
178
1
'''simple docstring''' from collections.abc import Sequence def lowerCAmelCase__ ( lowerCamelCase : Sequence[int] | None = None ): if nums is None or not nums: raise ValueError('Input sequence should not be empty' ) _A : Any = nums[0] ...
227
'''simple docstring''' from dataclasses import dataclass, field from typing import Optional @dataclass class __lowerCamelCase : """simple docstring""" a = field( default="codeparrot/codeparrot" , metadata={"help": "Model name or path of model to be trained."} ) a ...
227
1
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging lowercase_...
45
class A (SCREAMING_SNAKE_CASE ): '''simple docstring''' pass class A (SCREAMING_SNAKE_CASE ): '''simple docstring''' pass class A : '''simple docstring''' def __init__( self : List[Any] ) -> str: """simp...
274
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.optim import Ada...
299
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ = {'''configuration_mmbt''': ['''MMBTConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except...
299
1
'''simple docstring''' from __future__ import annotations def UpperCAmelCase_ ( __lowerCamelCase : list[int] ): lowercase_ :Tuple = len(__lowerCamelCase ) // 2 # choose the middle 3 elements lowercase_ :int = lst[m - 1 : m + 2] # if middle eleme...
223
'''simple docstring''' import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def UpperCAmelCase_ ( __lowerCamelCase : List[str] ): monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings" ,set() ) @pytest....
223
1
"""simple docstring""" import os from collections.abc import Iterator def SCREAMING_SNAKE_CASE_ ( snake_case : str = "." )-> Iterator[str]: for dir_path, dir_names, filenames in os.walk(snake_case_ ): _lowerCamelCase = [d for d in dir_names if d != 'scripts' and ...
367
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : list )-> list: def merge(snake_case : list , snake_case : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0...
80
0
import math def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : float , _lowerCamelCase : float) -> List[Any]: '''simple docstring''' if initial_intensity < 0: raise ValueError("The value of intensity cannot be negative") # ...
232
from argparse import ArgumentParser from .env import EnvironmentCommand def __lowercase ( ): a__ = ArgumentParser('Diffusers CLI tool' , usage='diffusers-cli <command> [<args>]' ) a__ = parser.add_subparsers(help='diffusers-cli command helpers' ...
240
0
"""simple docstring""" import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( """split_dict""" , [ SplitDict(), SplitDict({"""train""": SplitInfo(name="""train""" , num_bytes=1337 , num_examples=...
365
"""simple docstring""" from math import isqrt def __UpperCAmelCase ( snake_case_ : int ) -> list[int]: """simple docstring""" _lowerCAmelCase = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: ...
317
0
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_torch_available(): import torch ...
137
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 a_ : Optional[Any] = logging.get_logger(__n...
137
1
import math from collections.abc import Callable def __lowercase ( _A : Callable[[float], float] , _A : float , _A : float ) ->float: """simple docstring""" lowerCamelCase_ =xa lowerCamelCase_ =xa while True: ...
350
import numpy as np import qiskit def __UpperCamelCase ( _A : int = 8 , _A : int | None = None ) ->str: """simple docstring""" lowerCamelCase_ =np.random.default_rng(seed=_A ) # Roughly 25% of the qubits will contribute to the key. ...
49
0
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, ...
29
import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor __UpperCAmelCase = logging.get_logger(__name__) class lowerCamelCase (_snake_case ): '''simple docstring''' def __init__( self ...
29
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import DistilBertConfig, 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_te...
357
'''simple docstring''' from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class __SCREAMING_SNAKE_CASE : """simple docstring""" __a =42 # [batch_size x 3] __a =42 # [batch_size x 3] __a =42 # [batc...
346
0
def snake_case ( snake_case__ :int) -> int: return 1 if digit in (0, 1) else (digit * factorial(digit - 1)) def snake_case ( snake_case__ :int) -> bool: _A = 0 _A = number while duplicate > 0: _A , _A ...
180
import math import sys def snake_case ( snake_case__ :int) -> int: if number != int(snake_case__): raise ValueError("""the value of input must be a natural number""") if number < 0: raise ValueError("""the value of input must not be a negative...
180
1
"""simple docstring""" import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_...
369
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : list[list[float]] ): lowerCAmelCase = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation on...
309
0
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_b...
37
'''simple docstring''' import os 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 __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmel...
271
0
from __future__ import annotations from PIL import Image # Define glider example lowerCAmelCase__ :str = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0...
185
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_MEAN, I...
185
1
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class _lowercase : """simple docstring""" __A = 42 __A = None # ...
227
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils import Conf...
227
1
'''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...
43
'''simple docstring''' import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, exec...
43
1
"""simple docstring""" 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 imp...
91
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase :Union[str, Any] = { '''configuration_vision_encoder_decoder''': ['''VisionEncode...
331
0
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging _A : int = logging.get_logger(__name__) # TODO Update this _A : List[Any] = { 'facebook/esm-1b': 'https://huggingface.co/facebook/esm-1b/reso...
358
from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging _A : List[str] = lo...
265
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ = { '''configuration_roberta''': ['''ROBERTA_PR...
104
'''simple docstring''' import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def _UpperCamelCase ...
80
0
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME __snake_case = ['''small''', '''medium''', '''large'''] __snake_case = '''lm_head.decoder.weight''' __snake_case = '''lm_head.weight''' def a ( __a ...
219
'''simple docstring''' from math import ceil def a ( __a , __a ) -> Any: '''simple docstring''' UpperCamelCase__ :str = list(range(0 , __a ) ) UpperCamelCase__ :Optional[int] = [item for sublist in list(device_map.value...
219
1
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets __lowerCamelCase = """ @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translation for Text Simplification}, autho...
59
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
317
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : str = { '''configuration_biogpt''': ['''BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BioGptConfig'''], '...
367
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def a_ ( __lowercase : Optional[Any] , __lowe...
130
0
UpperCamelCase__ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def lowerCAmelCase_ ( ) -> None: '''simple docstring''' UpperCAmelCase__ = input("Enter message: " ) UpperCAmelCase__ = input("Enter key [alphanumeric]: " ) Uppe...
65
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class _A : UpperCamelCase__ : Optional[Union[str, Path]] = None UpperCamelCase__ : bool = False UpperCamelCase__ : bool...
49
0
from __future__ import annotations class a__ : def __init__( self , _A ): """simple docstring""" __lowerCAmelCase = TypeError( "Matrices must be formed from a list of zero or more lists containing at " "least ...
102
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a__ ( unittest.TestCase ): @prop...
102
1
from __future__ import annotations UpperCAmelCase__ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def UpperCAmelCase_ ( __snake_case , __snake_case , __snake_case , __snake_case , __snake_case , ) -> t...
5
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTe...
319
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _snake_case : Union[str, Any] = { 'configuration_swinv2': ['SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Swinv2Config'], } try: if ...
353
'''simple docstring''' 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 A ( _a ): ...
179
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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_feat...
85
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer UpperCamelCase_ = logging.get_logger(__name__) Uppe...
309
0
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ...
369
from __future__ import annotations import unittest from transformers import DebertaVaConfig, 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, random_attention_mask f...
290
0
'''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 ...
185
'''simple docstring''' import unittest from knapsack import knapsack as k class UpperCAmelCase_ (unittest.TestCase ): """simple docstring""" def lowercase_ ( self ) -> Optional[Any]: __lowerCamelCase : int = 0 __lowerCamelCase : Uni...
185
1
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git i...
220
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available A__ : int ={'''tokenization_herbert''': ['''HerbertTokenizer''']} try: if not is_tokenizers_available(): ...
220
1
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOutputWithP...
43
import random def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase :Optional[Any] = a[left_index] __UpperCamelCase :Any = left_index + 1 for j in range(left_index + 1 , SCREAMING_SNAKE_C...
43
1
"""simple docstring""" import math from typing import Dict, Iterable, List, Optional, Tuple, 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 from ...image_util...
352
"""simple docstring""" from __future__ import annotations def __lowerCAmelCase (_UpperCamelCase ): __lowerCAmelCase : List[str] = str(_UpperCamelCase ) return len(_UpperCamelCase ) == 9 and set(_UpperCamelCase ) == set('123456789' ) def __lowerCAmelCase (): for base_n...
182
0
_UpperCAmelCase : List[Any] =frozenset( [ """prompt""", """height""", """width""", """guidance_scale""", """negative_prompt""", """prompt_embeds""", """negative_prompt_embeds""", """cross_attention_kwargs""", ] ) _UpperCAmelCase : Tup...
262
'''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...
265
0
def __lowerCamelCase ( snake_case__ = 1_00 ) -> int: """simple docstring""" _SCREAMING_SNAKE_CASE = n * (n + 1) * (2 * n + 1) / 6 _SCREAMING_SNAKE_CASE = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if _...
350
def __lowerCamelCase ( snake_case__ ) -> List[Any]: """simple docstring""" _SCREAMING_SNAKE_CASE = len(snake_case__ ) for i in range(length - 1 ): _SCREAMING_SNAKE_CASE = i for k in range(i + 1 ,snake_c...
125
0
def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : int = 50_00_00_00 ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE__ = set() SCREAMING_SNAKE_CASE__ = int((limit - 24) ** (1 / 2) ) SCREAMING_SNAKE_CASE__ = set(r...
219
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class __snake_case ( lowerCamelCase_ ...
219
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a : int = {'configuration_opt': ['OPT_PRETRAINED_CONFIG_ARCHIVE...
356
'''simple docstring''' from math import loga def __lowerCamelCase ( _lowercase ) -> int: if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(_lowercase , _lowercase ): raise TypeError("""Input value must be...
338
0
'''simple docstring''' import copy import re class UpperCamelCase__ : """simple docstring""" SCREAMING_SNAKE_CASE__ : Tuple = "hp" SCREAMING_SNAKE_CASE__ : Dict = {} SCREAMING_SNAKE_CASE__ : Dict = None @classmethod def A_ ( cls , snake_ca...
311
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers import AutoTokenizer, TFAutoModelForSeqaSeqLM @...
130
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE ( a_ ): """simple docstring""" lowerCamelCase : List[str] ="timm_backbone" def _...
139
__UpperCAmelCase = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ __UpperCAmelCase = [{""...
139
1
"""simple docstring""" import numpy as np def lowercase ( _snake_case : int , _snake_case : Optional[Any] , _snake_case : Optional[int] , _snake_case : int , _snake_case : Union[str, Any] ) ->Dict: """simple docstrin...
102
"""simple docstring""" import math def lowercase ( _snake_case : int ) ->bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 ar...
102
1
from collections.abc import Generator def _lowerCAmelCase ( ): __SCREAMING_SNAKE_CASE = 0, 1 while True: __SCREAMING_SNAKE_CASE = b, a + b yield b def _lowerCAmelCase ( UpperCamelCase_ = 1000 ): __SCREAMING_SNAKE_CASE = 1 __SCREAMING_SNAKE_CASE ...
367
"""simple docstring""" import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) __magic_name__ = { ...
255
0
from __future__ import annotations def a__ ( _UpperCamelCase : list[int] ): if not nums: return 0 __lowerCamelCase = nums[0] __lowerCamelCase = 0 for num in nums[1:]: __lowerCamelCase = ( max_excluding + num, ...
330
"""simple docstring""" # 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 .sched...
179
0
'''simple docstring''' def _A (lowerCAmelCase__ :list ) -> int: '''simple docstring''' if not grid or not grid[0]: raise TypeError('The grid does not contain the appropriate information' ) for cell_n in range(1 , len(grid[0] ...
104
'''simple docstring''' import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor a_ : Optional[Any] = logging.get_logger(__name__) class a ( _SCREAMING_SNAKE_CASE ): def __init__( self , *__magic_name__ ...
104
1
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) __A = ...
164
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common import Seque...
290
0
import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokenizati...
14
def lowerCamelCase ( a_ ) -> bool: lowerCAmelCase_ = set() # To detect a back edge, keep track of vertices currently in the recursion stack lowerCAmelCase_ = set() return any( node not in visited and depth_first_s...
14
1
"""simple docstring""" import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets _UpperCamelCase : Any = datasets.logging.get_logger(__name__) _UpperCamelCase : str = '\\n@InProceedi...
220
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase : Dict = { 'configuration_roberta': ['ROBERTA_PR...
220
1
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_ax...
239
"""simple docstring""" import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_inf...
239
1
"""simple docstring""" import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets lowerCamelCase__ = """\ @article{hendrycksmath2021, title={Measuring Mathematical Problem Solving With the MATH Dataset}, author={Dan Hendrycks and Collin Burns and Saurav Kad...
86
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments ...
182
0
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva lowerCamelCase = """""" lowerCamelCase = """""" lowerCamelCase = """""" lowerCamelCase = 1 # (0 is vertical, 1 is horizontal) de...
241
"""simple docstring""" import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, req...
241
1
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCAmelCase__ : def __init__( self : Union[str, Any] , SCREAMING_SNAKE_CASE__ : Dict=2 , SCREAMING_SNAKE_CASE__ : Dict=3 ...
270
'''simple docstring''' from ...processing_utils import ProcessorMixin class __a (lowerCamelCase ): __a : Dict = "SpeechT5FeatureExtractor" __a : Any = "SpeechT5Tokenizer" def __init__( self : Any , __magic_name__ : Union...
125
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
369
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node __lowerCamelCase : int = 4 __lowerCamelCase : Dict = 3 ...
204
0
import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def __lowerCamelCase ( UpperCAmelCase_ : ndarray ): """simple docstring""" return np.dot(UpperCAmelCase_ , UpperCAmelCase_ ) class _snake_case : def...
94
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...tes...
338
0
from ..utils import DummyObject, requires_backends class lowercase__ ( metaclass=__lowerCamelCase ): '''simple docstring''' a : List[Any] = ["torch", "transformers", "onnx"] def __init__( self, *__magic_name__, **__magic_name__ )...
355
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
247
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ = {"configuration_mmbt": ["MMBTConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDe...
139
'''simple docstring''' def A_ ( snake_case = 100 ): SCREAMING_SNAKE_CASE:Optional[Any] = set() SCREAMING_SNAKE_CASE:int = 0 SCREAMING_SNAKE_CASE:Optional[Any] = n + 1 # maximum limit for a in range(2 , snake_case ): for b in ra...
139
1
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__) ...
369
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers...
232
0
"""simple docstring""" from collections.abc import Callable class UpperCAmelCase_ : def __init__( self , a = None ) -> None: # Stores actual heap items. lowercase__ : list = [] # Stores indexes of each item for supporting updates a...
77
"""simple docstring""" def lowercase__ ( _UpperCAmelCase , _UpperCAmelCase ) -> Dict: '''simple docstring''' _enforce_args(_UpperCAmelCase , _UpperCAmelCase ) if n == 0: return 0 lowercase : Tuple = float('-inf' ...
255
0
"""simple docstring""" def UpperCAmelCase ( UpperCAmelCase ) -> str: if isinstance(UpperCAmelCase , UpperCAmelCase ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(UpperCAmelCase , UpperCAmelCase ): raise TypeError('\'str\' ob...
312
"""simple docstring""" import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_i...
312
1
'''simple docstring''' from __future__ import annotations class lowercase_ : """simple docstring""" def __init__( self : Optional[int] ,lowercase__ : str ,lowercase__ : str ): __lowercase , __lowercase = text, pattern __lowercase , __lowercas...
104
'''simple docstring''' from __future__ import annotations def _A ( A__ ): """simple docstring""" __lowercase = len(A__ ) # We need to create solution object to save path. __lowercase = [[0 for _ in range(A__ )] for _ in range(A__ )] __lowercase ...
104
1
from math import factorial lowerCAmelCase = {str(d): factorial(d) for d in range(1_0)} def _lowerCamelCase( lowercase__ ) -> int: '''simple docstring''' return sum(DIGIT_FACTORIAL[d] for d in str(snake_case__ ) ) def _lowerCamelCase( ) -> int: ...
365
from math import factorial, radians def _lowerCamelCase( lowercase__ , lowercase__ = 1_8 , lowercase__ = 1_0 ) -> float: '''simple docstring''' __lowercase= angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Converting from degrees to radians __l...
304
0
import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokenization_common import...
14
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , lowercase_ , lowercase_ ) -> List[Any]: """simple docstring""" A__ ...
14
1
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ = 1000 ) -> int: '''simple docstring''' snake_case : Optional[Any] = 3 snake_case : Union[str, Any] = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15...
362
'''simple docstring''' import os def _UpperCamelCase ( ) -> List[Any]: '''simple docstring''' snake_case : int = os.path.join(os.path.dirname(SCREAMING_SNAKE_CASE__ ) , '''num.txt''' ) with open(SCREAMING_SNAKE_CASE__ ) as file_hand: return str(sum(int(...
83
0
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class __magic_name__ ( _UpperCAmelCase): UpperCamelCase__ = (DDPMScheduler,) def SCREAMING_SNAKE_CASE_ ( self : Dict , **lowercase_ : Un...
239
'''simple docstring''' import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ra...
239
1
"""simple docstring""" import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_...
233
"""simple docstring""" import math class __A : '''simple docstring''' def __init__( self : List[str] , UpperCAmelCase_ : Tuple=0 ) ->Optional[int]: # a graph with Node 0,1,...,N-1 """simple docstring""" snake_case_ ...
233
1
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_com...
241
"""simple docstring""" 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`""")
241
1
"""simple docstring""" import argparse import os import re _A = """src/diffusers""" # Pattern that looks at the indentation in a line. _A = re.compile(R"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. _A = re.compile(R"""^\s*\"([^\"]+)\":""") # Pa...
166
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .token...
166
1
from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def UpperCAmelCase ( a_ , a...
15
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def _SCREAMING_SNAKE_CASE ( lowercase : Union[dict, list, tuple, torch...
204
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, requi...
202
"""simple docstring""" import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ......
202
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class UpperCAmelCase_ ( unittest.TestCase ): """simple ...
259
"""simple docstring""" import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , **lowercase_ ) -> List[Any]: A__ = AutoConfig.from_pretrained(lowercase_ , **lowercase_ ) A__ ...
247
0
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> int: A_ = abs(UpperCAmelCase__ ) A_ = 0 while n > 0: res += n % 10 n //= 10 return res def UpperCAmelCase__ ( UpperCAmelCase__ ) -> int: A...
101
'''simple docstring''' from __future__ import annotations from typing import Any def UpperCAmelCase__ ( UpperCAmelCase__ ) -> int: if not postfix_notation: return 0 A_ = {"""+""", """-""", """*""", """/"""} A_ = [] for token in postfix_notati...
101
1
def UpperCamelCase ( lowerCAmelCase__ = 1000 ): '''simple docstring''' lowercase = -1 lowercase = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c lowercase = (n * n - 2 * a *...
101
class lowerCamelCase__ : '''simple docstring''' def __init__( self :Union[str, Any] ) -> None: __UpperCamelCase : dict[str, TrieNode] = {} # Mapping from char to TrieNode __UpperCamelCase : List[str] = False def _lowerCa...
232
0
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils import Con...
158
import logging import os import threading import time try: import warnings except ImportError: _UpperCAmelCase : List[str] = None try: import msvcrt except ImportError: _UpperCAmelCase : Tuple = None try: import fcntl except ImportError: _UpperCAmelCase : ...
158
1
def __snake_case ( __UpperCamelCase : int ): """simple docstring""" if isinstance(__UpperCamelCase ,__UpperCamelCase ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(__UpperCamelCase ,__UpperCamelCase ):...
312
import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib import Pa...
312
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaProcessor, BlipImageProcesso...
20
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = "▁" lowercase_ = {"vocab_fi...
20
1
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging a_ = logging.get_logger(__name__) def a__ ( _UpperCamelCase : Optional[int]=None ,_UpperCamelCase : str=Non...
330
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch a_ = logging.get...
330
1
'''simple docstring''' __a: Optional[Any] = [ """DownloadConfig""", """DownloadManager""", """DownloadMode""", """StreamingDownloadManager""", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager impor...
214
'''simple docstring''' def __UpperCamelCase ( ): lowercase__ : Any = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] lowercase__ : Any = 6 lowercase__ : Optional[Any] = 1 lowercase__ : int = 1901 lowercase__ : List[str] = 0 while year < 2001: da...
214
1