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""" import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached...
61
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __UpperCamelCase ( _A ): lowerCAmelCase_ = [ '''decoder.version''', '''decoder.output_projection.weight''', '''_floa...
278
0
'''simple docstring''' from __future__ import annotations import pandas as pd def lowercase_ ( lowerCAmelCase__ : list[int] , lowerCAmelCase__ : list[int] , lowerCAmelCase__ : int ): """simple docstring""" __UpperCAmelCase : List[str] ...
16
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, requi...
16
1
"""simple docstring""" import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def A ( snake_case__ , snake_case__ , snake_case__ , snake_case__ , snake_case__ ): '''simple docstring''' SCR...
165
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @re...
341
0
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, to...
159
def _UpperCAmelCase (UpperCamelCase_ : str , UpperCamelCase_ : str ): '''simple docstring''' _lowerCAmelCase : str = len(UpperCamelCase_ ) + 1 _lowerCAmelCase : List[Any] = len(UpperCamelCase_ ) + 1 # dp is a 2d matrix where dp[i][j] denotes w...
159
1
"""simple docstring""" import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require...
40
"""simple docstring""" from __future__ import annotations import unittest from transformers import 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, rand...
221
0
'''simple docstring''' import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...featu...
365
'''simple docstring''' import itertools import math def _lowerCAmelCase ( __snake_case : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Ne...
190
0
"""simple docstring""" 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 <us...
54
"""simple docstring""" import math import random def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ = False ): '''simple docstring''' if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value a__ : Tuple =...
54
1
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Union[str, Any] = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_M...
251
'''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/licenses/LICENSE...
251
1
from __future__ import annotations import collections import pprint from pathlib import Path def UpperCamelCase ( __lowerCamelCase : str ): return "".join(sorted(__lowerCamelCase ) ) def UpperCamelCase ( __lowerCamelCase : str ): return word_by_si...
59
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def UpperCamelCase ( __lowerCamelCase : Dataset , __lowerCamelCase : Dict[str, str] ): ...
59
1
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def A ( a_ ,a_ ,a_ = None ) -> Optional[Any]: if version.parse(hfh.__version__ ).release < version.parse('0.11.0' ).release: # old versions ...
351
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ :Union[str, Any] = {'''configuration_plbart''': ['''PLBART_PRETRAINED_CONFIG_ARCHI...
245
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a : Optional[Any] = { '''configura...
105
"""simple docstring""" from decimal import Decimal, getcontext from math import ceil, factorial def _SCREAMING_SNAKE_CASE ( _lowercase : int ) ->str: '''simple docstring''' if not isinstance(_lowercase , _lowercase ): rais...
105
1
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__=None ): __lowerCamelCase : Dict = None if token is not None: __lo...
361
import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE...
194
0
'''simple docstring''' 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 lowerCamelCase_ ( unittest.TestCase ...
181
"""simple docstring""" from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __A ( _SCREAMING_SNA...
81
0
import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifierOut...
357
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if ...
286
0
"""simple docstring""" import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class A_ (lowercase__ ,lowercase__ ): '''simple docst...
61
"""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
0
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import Tokeni...
188
"""simple docstring""" import comet # From: unbabel-comet import torch import datasets A = datasets.logging.get_logger(__name__) A = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon}, ...
188
1
from ..utils import DummyObject, requires_backends class UpperCamelCase__ (metaclass=lowerCAmelCase__ ): '''simple docstring''' lowerCamelCase_ : Optional[int] = ["torch", "scipy"] def __init__( self , *UpperCamelCase__ , **UpperC...
48
"""simple docstring""" def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' if upper_limit < 0: raise ValueError("Limit for the Catalan sequence must be ≥ 0" ) __SCREAMING_SNAKE_CASE = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1...
54
0
"""simple docstring""" from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = "T5Config" class _SCR...
239
"""simple docstring""" def __lowerCamelCase ( a_ : str ) -> list: return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(a_ ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("do...
239
1
"""simple docstring""" import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput SCREAMING_SNAKE_CASE = "scheduler_config.json" class UpperCAmelCase_ ( A_ ): lower...
247
"""simple docstring""" import qiskit def __lowerCamelCase ( a_ : int , a_ : int ) -> qiskit.result.counts.Counts: __SCREAMING_SNAKE_CASE :Tuple = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the ...
191
0
import argparse import os import re import packaging.version _lowercase : List[str] ="examples/" _lowercase : List[str] ={ "examples": (re.compile(r"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VERSION\")\n"), "init": (re.compile(r"^__vers...
266
from __future__ import annotations import math def lowerCAmelCase_ ( _lowercase : float , _lowercase : int) -> float: """simple docstring""" a__ : Union[str, Any] = u for i in range(1 , _lowercase): ...
266
1
"""simple docstring""" import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets __a = "\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Language Model...
66
"""simple docstring""" import re def A_ ( _lowercase ): '''simple docstring''' snake_case_ :Optional[int] = re.compile( r"""^(?:0|94|\+94|0{2}94)""" r"""7(0|1|2|4|5|6|7|8)""" r"""(-| |)""" r"""\d{7}$""" ) return bool(re.search(_lowercase, _lowercase ) ) if __...
66
1
'''simple docstring''' from typing import Any class __magic_name__ : def __init__( self , snake_case) -> Optional[Any]: '''simple docstring''' _UpperCAmelCase : Dict =data _UpperCAmelCase : str ...
365
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( __lowerCamelCase : list[int] ): '''simple docstring''' if not nums: return 0 _UpperCAmelCase : Tuple =nums[0] _UpperCAmelCase : int ...
242
0
'''simple docstring''' from __future__ import annotations def snake_case_ ( _lowerCAmelCase : float , _lowerCAmelCase : float , _lowerCAmelCase : float ) -> dict[str, float]: if (voltage, current, resistance).count(0 ) != 1: ...
23
'''simple docstring''' import unittest from transformers import MraConfig, 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, floats_tensor, i...
23
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: if n...
361
"""simple docstring""" import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_...
112
0
"""simple docstring""" 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 SCREAMING_SNAKE_...
106
'''simple docstring''' a__ : Union[str, Any] = [sum(int(c, 1_0) ** 2 for c in i.__str__()) for i in range(1_0_0_0_0_0)] def _UpperCamelCase ( __A ) -> int: '''simple docstring''' UpperCamelCase__ = 0 while number: # In...
80
0
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_=False ) -> Any: if isinstance(lowercase_ , lowercase_ ) and isinstance(lowercase_ , lowercase_ ): A__ = len(set_a.intersection(lowercase_ ) ) ...
356
"""simple docstring""" import random from .binary_exp_mod import bin_exp_mod def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_=10_00 ) -> Optional[Any]: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd A__ = n - 1 A__ = 0 while...
230
0
# Algorithm for the pigeonhole sorting def _UpperCAmelCase ( a__): '''simple docstring''' a_ : List[Any] = min(a__) # min() finds the minimum value a_ : List[str] = max(a__) # max() finds the maximum value a_ : str = max_val - min_val + 1 ...
248
from __future__ import annotations def _UpperCAmelCase ( a__): '''simple docstring''' a_ : List[str] = str(a__) return len(a__) == 9 and set(a__) == set("""123456789""") def _UpperCAmelCase ( ): '''simple docstring''' for base_num in range(9_9_9_9 , 4_9...
248
1
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast from ..uti...
194
import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE...
194
1
"""simple docstring""" import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": __lowercase = argparse.ArgumentParser( description=( """Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Tran...
40
'''simple docstring''' __SCREAMING_SNAKE_CASE :List[str] = '''0.18.2''' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, i...
22
0
"""simple docstring""" import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def _snake_case ( lowercase__ ): def wrapper(*lowercase__ , **lowercase__ ): ...
12
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class lowerCAmelCase__ ( lowercase ): '''simple docstring''' lowerCamelCase__ = (UnCLIPScheduler,) def ...
12
1
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tor...
197
"""simple docstring""" def UpperCAmelCase__ ( lowerCAmelCase__ :str , lowerCAmelCase__ :Optional[Any] ) -> int: '''simple docstring''' lowercase = [0 for i in range(r + 1 )] # nc0 = 1 lowercase = 1 for i in range...
197
1
from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class lowercase ( a ): lowercase__ : ...
362
def __lowerCamelCase (UpperCAmelCase__ : int , UpperCAmelCase__ : int ): while b: SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = b, a % b return a def __lowerCamelCase (UpperCAmelCase__ : int , UpperCAmelCase__ ...
206
0
'''simple docstring''' # 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 # # Unle...
341
'''simple docstring''' import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax...
341
1
'''simple docstring''' import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": SCREAMING_SNAKE_CASE_: Any ='%20'.join(argv[1:]) if len(argv) > 1 else quote...
362
'''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 __A ( unittes...
106
0
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch c...
51
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import Toke...
51
1
'''simple docstring''' from __future__ import annotations from collections.abc import Generator def lowercase (): """simple docstring""" _lowerCAmelCase : dict[int, int] = {} _lowerCAmelCase : ...
25
'''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 lowerCAmelCase : int = logging.get_logger...
25
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __a = { 'configuration_mega': ['MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegaConfig', 'MegaOnnxConfig'], } try: if not is_torch_avail...
145
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { '''microsoft/wavlm-base''': '''https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json''', ...
5
0
'''simple docstring''' import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): ...
334
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCamelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDep...
334
1
'''simple docstring''' from decimal import Decimal, getcontext from math import ceil, factorial def _lowercase ( __A ): '''simple docstring''' if not isinstance(__A ,__A ): raise TypeError("""Undefined for non-integers""" ) elif precision < 1: ...
349
'''simple docstring''' import string def _lowercase ( __A ): '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): __UpperCamelCase = """""" for symbol in message: if symbol in string.ascii_uppercase: __UpperCamelC...
349
1
'''simple docstring''' from torch import nn def snake_case_ ( lowerCAmelCase_ )-> List[Any]: '''simple docstring''' if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": ...
349
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import g...
349
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()...
228
import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMix...
228
1
from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class _UpperCamelCase : '''simple docstring''' pass
350
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _UpperCamelCase ( _A , unittest.TestCase ): '''simple docstring''' __UpperCamelCase : Tu...
223
0
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass A__ : str = (3, 9, -11, 0, 7, 5, 1, -1) A__ : int = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class _UpperCAmelCase : """simple docstring""" lowercase__ ...
207
import warnings warnings.warn( 'memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: ' '`from accelerate import find_executable_batch_size` to avoid this warning.', FutureWarning, )
207
1
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accel...
365
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accel...
176
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowercase__ = { """configuration_blip""": [ """BLI...
96
"""simple docstring""" def _snake_case ( lowercase__ , lowercase__ ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) _lowerCamelCase : List[Any] = (boundary[1] - boundary[0]) / steps _lowerCamelCase : Tuple = b...
96
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTokenizerBase, TensorType l...
369
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class ...
121
0
import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK_RECORDS_FILENAME, RealmRetriev...
15
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def A__ ( __lowerCamelCase ): SCREAMING_SNAKE_CASE_ = int(number**0.5 ) return number == sq * sq def A__ ( __lowerCamelCase, __lowerCamelCase, __lowerCamelCase, __lowerCamelCa...
299
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBertConfig', ...
177
import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def SCREAMING_SNAKE_CASE ( __UpperCamelCase : Tuple , __UpperCamelCase : List[str] , __UpperCamelCase : str ) -> str: UpperCAmelCa...
177
1
from __future__ import annotations from collections.abc import Iterator from typing import Any class _snake_case : def __init__( self , a) -> List[str]: SCREAMING_SNAKE_CASE = data SCREAMING_SNAKE_CASE = None class _snake_case ...
137
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from ...
137
1
def __lowerCAmelCase ( a__ , a__ ) -> str: __a = len(a__ ) __a = len(a__ ) __a = ( first_str_length if first_str_length > second_str_length else second_str_length ) __a = [] for char_count in range(a__ ): ...
33
import functools def __lowerCAmelCase ( a__ , a__ ) -> int: __a = len(a__ ) __a = len(a__ ) @functools.cache def min_distance(a__ , a__ ) -> int: # if first word index is overflow - delete all from the second word if indexa ...
33
1
"""simple docstring""" import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) lowerCAmelCase__ = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_per_block...
108
'''simple docstring''' import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import v...
271
0
"""simple docstring""" import copy from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto.configuration_auto import AutoConfig ...
362
"""simple docstring""" def lowercase_ ( _lowerCamelCase: int = 4000000 ) -> int: '''simple docstring''' __lowerCamelCase : Tuple = [0, 1] __lowerCamelCase : Union[str, Any] = 0 while fib[i] <= n: fib.append(fib[i] ...
64
0
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import logging ...
244
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffuse...
161
0
"""simple docstring""" import argparse import os import re lowercase_ = "src/transformers" # Pattern that looks at the indentation in a line. lowercase_ = re.compile(r"^(\s*)\S") # Pattern that matches `"key":" and puts `key` in group 0. lowercase_ = re.compi...
357
"""simple docstring""" import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from trans...
11
0
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE = 1_000 ) -> int: snake_case_ = -1 snake_case_ = 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 snake_case_ = (n *...
347
"""simple docstring""" from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWit...
221
0
'''simple docstring''' import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, Musicgen...
246
'''simple docstring''' from sklearn.metrics import matthews_corrcoef import datasets UpperCamelCase_ = "\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass clas...
246
1
"""simple docstring""" import pickle import numpy as np from matplotlib import pyplot as plt class UpperCAmelCase_ : def __init__( self , a , a , a , a , a , a=0.2 , a=0.2 ) -> Dict: lowercase__ : Any = bp_numa lowercase__ ...
77
"""simple docstring""" import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def a_ ( _lowerCAmelCase : Tuple , _lowerCAmelCase : Optional[int] , _lo...
77
1
'''simple docstring''' # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_uti...
217
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def _lowerCAmelCase ( ): print('''Making key files...''' ) make_key_files('''rsa''' , 1...
217
1
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def __lowercase ( __lowerCAmelCase : str , __lowerCAmelCase : List[str] , __lowerCAmelCase : Any , __lowerCAmelCase : int=1_0_2...
240
import cva import numpy as np class A_ : def __init__( self , _A , _A ): '''simple docstring''' if k in (0.04, 0.06): UpperCAmelCase = k UpperCAmelCase = window_size else: raise ValueError('''invalid k value''' ) def __...
273
0
import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def _lowerCAmelCase ( __lowerCAmelCase ) -> List[str]: """simple docstring""" return 1 / (1 + np.exp(-z )) def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase )...
366
from sklearn.metrics import mean_squared_error import datasets A__ = '''\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel, M. and Prettenho...
44
0
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class _UpperCAmelCase ( _lowerCAmelCase ): def a ( self : Tuple , _lowercase : Dict=None , _lowercase : str=None , _lowercase : Union[str, Any]=...
332
"""simple docstring""" # Copyright 2022 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/LI...
332
1
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SH...
350
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCamelCase = { 'configuration_conditional_detr': [ 'CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConditionalDetrConfi...
177
0
'''simple docstring''' from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = {'''vocab_file'''...
89
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase__ : Any = logging.get_logger(__name__) UpperCamelCase__ :...
344
0
'''simple docstring''' import re from filelock import FileLock try: import nltk _UpperCAmelCase : str = True except (ImportError, ModuleNotFoundError): _UpperCAmelCase : List[Any] = False if NLTK_AVAILABLE: with FileLock(""".lock""") as lock: nltk.downlo...
9
'''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__ ( _...
9
1
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...util...
15
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel SCREAMING_SNAKE_CASE :Union[str, Any] = False SCREAMING_SNAKE_CASE :Any = True SCREAMING_SNAKE_CASE :Tuple = False ...
15
1
'''simple docstring''' import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) fr...
366
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __A : List[Any] = { "configuration_roc_bert": ["ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "RoCBertConfig"], ...
89
0
"""simple docstring""" import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import Aut...
96
def __UpperCamelCase ( _A : int ) ->int: """simple docstring""" assert ( isinstance(_A , _A ) and number_of_steps > 0 ), f'number_of_steps needs to be positive integer, your input {number_of_steps}' if number_of_steps == 1: return 1 ...
154
0
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class A__ ( __snake_case , unittest.TestCase ): _UpperCAmelCase :List[str] = CTR...
140
from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_commo...
140
1
"""simple docstring""" import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __A ( a_ :Optional[Any]) -> Union[str, Any]: __a : Dict = os.path.join(args.tf_model_dir ...
160
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean __UpperCAmelCase = 0 __UpperCAmelCase = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0...
323
0
'''simple docstring''' import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py a__ : Optional[Any] = 'src/diffusers' # Matches is_xxx_available() a__ : ...
243
'''simple docstring''' # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar a__ : int = TypeVar('T') class UpperCAmelCase__ (...
243
1
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor UpperCAmelCase__ = logging.get_logger(__name__) class lowercase_ ( lowercase ): '''simple docstring''' def __init__( se...
0
def _a ( a :int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('''The given input must be positive''' ) # get the generated string sequence a = gray_code_sequence_string(a ) # # convert them to integers f...
0
1
from math import ceil, sqrt def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ = 1_0_0_0_0_0_0 ) -> int: __lowerCamelCase : Tuple = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: __lowerCamelCase : List[str] = max(cei...
113
import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import disable_progress_b...
113
1
"""simple docstring""" import importlib import os import fsspec import pytest from fsspec import register_implementation from fsspec.registry import _registry as _fsspec_registry from datasets.filesystems import COMPRESSION_FILESYSTEMS, HfFileSystem, extract_path_from_uri, is_remote_filesystem ...
78
"""simple docstring""" import os import time import numpy as np import onnxruntime as ort snake_case_ = """1""" snake_case_ = """0""" snake_case_ = """1""" snake_case_ = ort.SessionOptions() snake_case_ = ort.GraphOptimiz...
78
1
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_onnx_availa...
370
"""simple docstring""" def _A ( _a : int ): """simple docstring""" A = abs(_a ) A = 0 while n > 0: res += n % 1_0 n //= 1_0 return res def _A ( _a...
77
0
import random class __A: @staticmethod def SCREAMING_SNAKE_CASE_ ( _snake_case ) -> tuple[list[int], list[int]]: '''simple docstring''' __a = [ord(_snake_case ) for i in text] __a = [] __a = [] ...
6
'''simple docstring''' import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_se...
89
0
'''simple docstring''' class lowerCAmelCase_: '''simple docstring''' def __init__( self ,__UpperCAmelCase ) -> None: lowerCAmelCase__ : Optional[int] = size lowerCAmelCase__ : Any = [0] * size lowerCAmelCase__ : Any = [0] * size @...
365
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase = 1000 ): """simple docstring""" lowerCAmelCase__ : Union[str, Any] = -1 lowerCAmelCase__ : Optional[Any] = 0 for a in range(1 , n // 3 ): # Solving the two equa...
184
0
'''simple docstring''' from __future__ import annotations def UpperCAmelCase_ ( __lowercase : list[float] , __lowercase : list[float] ) -> float: '''simple docstring''' _UpperCAmelCase = sorted(numsa + numsa ) _UpperCAm...
22
import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowercase_ = (DDPMParallelScheduler,) def SCREAMING_SNAKE_CASE_ (self : Any ,...
10
0
import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( '''kwargs, expected''' , [ ({'''num_shards''': 0, '''max_num_jobs''': 1}, []), ({'''num_shards''': 10, '''max_num_jobs''': 1}, [range(10 )]),...
281
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _sn...
281
1
def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> int: if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise TypeError('only integers accepted as input' ) else: lowerCamelCase__ : List[Any] = str(abs(_UpperCAmelCase ) ) lowerCamelCas...
50
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer _UpperCAmelCa...
50
1
"""simple docstring""" import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def lowerCA...
359
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class lowerCAmelCase_ ( unittest.TestCase ): """simple docstring""" ...
149
0
'''simple docstring''' 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...
163
'''simple docstring''' import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def _UpperCamelCase ( UpperCamelCase__ ): return x + 2 class _snake_case ( unittest.TestCase ): ...
163
1
"""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_tor...
356
"""simple docstring""" import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_c...
254
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase__ : str = { '''configuration_wav2vec2''': ['''WAV_2_...
190
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class SCREAMING_SNAKE_CASE (datasets.BuilderConfig ): lower...
190
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available __snake_case = { """configuration_audio_spectrogram_transformer""": [ """AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ASTCo...
169
from __future__ import annotations from statistics import mean def _lowercase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ) -> list[int]: '''simple docstring''' SCREAMING_SNAKE_CASE__ = [0] * no_of_processes SCREAMING_SNAKE_CASE__ ...
169
1
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowercase__ ( snake_case_ :ndarray ): return np.dot(snake_case_ , snake_case_ ) class _UpperCAmelCase : def __init__( ...
332
"""simple docstring""" import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def lowercase__ ( ): raise RuntimeError('''CUDA out of memory.''' ) class _Up...
332
1
"""simple docstring""" SCREAMING_SNAKE_CASE = "Alexander Joslin" import operator as op from .stack import Stack def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> int: A__ = {"*": op.mul, "/": op.truediv, "+": op.add, "-": op.sub} A__ = Stack() A__ = Stack() for i in...
230
"""simple docstring""" SCREAMING_SNAKE_CASE = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] SCREAMING_SNAKE_CASE ...
230
1
"""simple docstring""" import requests _snake_case = 'https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=' def lowerCAmelCase__ ( UpperCamelCase__ ): '''simple docstring''' # fetching a list of articles in json format _a : Dict ...
294
"""simple docstring""" from __future__ import annotations def lowerCAmelCase__ ( UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' print(F"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(UpperCamelCase__ ): prin...
294
1
"""simple docstring""" from __future__ import annotations from statistics import mean def _snake_case ( _snake_case : list[int] , _snake_case : list[int] , _snake_case : int ) -> list[int]: '''simple docstring''' _A = [0] * no_of_...
271
"""simple docstring""" import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging a = ...
271
1
def lowercase_ (A : int = 2_0_0_0_0_0_0 ): snake_case__ : Dict = [0 for i in range(n + 1 )] snake_case__ : List[str] = 1 snake_case__ : List[str] = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i...
277
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_...
277
1
'''simple docstring''' def a ( lowerCamelCase__ ): '''simple docstring''' A_ : List[Any] = [0] * len(lowerCamelCase__ ) A_ : int = [] A_ : int = [] A_ : Tuple = 0 for values in graph.values(): for i...
135
'''simple docstring''' import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class _lowerCAmelCase ( unittest.TestCase ): def _a (self ): A_ : Dict = 10 ...
135
1
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() _UpperCAmelCase : Dict ...
50
'''simple docstring''' import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tenso...
298
0
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProcessing ...
350
from __future__ import annotations def lowerCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase )-> list[list[int]]: '''simple docstring''' UpperCAmelCase : list[list[int]] =[] create_all_state(1 , __lowerCAmelCase , __lowerCAmelCase , ...
78
0
"""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_dimensi...
78
"""simple docstring""" 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 ...
78
1
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: __lowerCAmelCase = None try: import msvcrt except ImportError: __lowerCAmelCase = None try: import fcntl except ImportError: __lowerCAmelCase = ...
5
'''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 UpperCAmelCase__ ( lowercase__ ...
5
1
def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ) -> Optional[Any]: lowerCamelCase : Tuple = [0 for i in range(r + 1 )] # nc0 = 1 lowerCamelCase : Optional[int] = 1 for i in range(1 ,n + 1 ): # to compute c...
48
"""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 m...
213
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy _lowerCAmelCase :str = logging.get_logger(__n...
68
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
68
1
'''simple docstring''' import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def UpperCamelCase_( snake_case : Optional[i...
85
def __lowerCamelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ): """simple docstring""" while b: a , a :Optional[Any] = b, a % b return a def __lowerCamelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ ...
94
0
from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { """microsoft/xprophetnet-large-wiki100-cased""": ( """https://huggingface.co/m...
364
import enum import shutil import sys UpperCamelCase__ , UpperCamelCase__ = shutil.get_terminal_size() UpperCamelCase__ = {"""UP""": """A""", """DOWN""": """B""", """RIGHT""": """C""", """LEFT""": """D"""} class a__ ( enum.Enum ): _a : Any = 0 _...
102
0
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 UpperCAmelCase__ ...
62
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import C...
137
0
'''simple docstring''' # Algorithm for the pigeonhole sorting def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ ) -> Optional[Any]: '''simple docstring''' snake_case : int = min(SCREAMING_SNAKE_CASE__ ) # min() finds the minimum value snake_case : int ...
83
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_mod...
83
1