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 cmath import math def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> complex: """simple docstring""" snake_case_ : Optional[int] = math.radians(_UpperCamelCase ) snake_case_ : List[str] ...
279
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_filename, infer_...
279
1
from __future__ import annotations def A__ ( lowerCamelCase ) -> int: UpperCamelCase_: Tuple = len(lowerCamelCase ) // 2 # choose the middle 3 elements UpperCamelCase_: Union[str, Any] = lst[m - 1 : m + 2] # if middle element is peak if three[1] > three[0] and...
366
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mvp import MvpTokenizer lowerCamelCa...
223
0
"""simple docstring""" import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils impor...
60
"""simple docstring""" from datetime import datetime import matplotlib.pyplot as plt import torch def _snake_case ( _snake_case : int ): for param in module.parameters(): lowerCAmelCase : Optional[int] = False def _snake_case ( ): lowerCAmelCase : List[str]...
60
1
"""simple docstring""" from bisect import bisect from itertools import accumulate def __A ( a_ :Optional[int] , a_ :Any , a_ :List[str] , a_ :int) -> str: __a : Union[str, Any] = sorted(zip(a_ , a_) , key=lambda a_: x[0...
188
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowercase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [''...
188
1
"""simple docstring""" from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar __A : List[str] = TypeVar('''T''') class _UpperCAmelCase ( Generic[T] ): SCREAMING_SNAKE_CASE_ : Optional...
33
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class lowerCAmelCase__ ( a): '''simple docstring''...
11
0
'''simple docstring''' import socket def lowerCamelCase ( ): """simple docstring""" __magic_name__ : List[str] = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) __magic_name__ : Union[str, Any] = socket.gethostname() __magic_name__ : int ...
275
'''simple docstring''' import os import unittest from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_to...
275
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _snake_case = { 'configuration_pix2struct': [ 'PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Pix2StructConfig', 'Pix2Struc...
250
'''simple docstring''' import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load_me...
250
1
'''simple docstring''' def __lowerCamelCase ( __snake_case : int ) -> int: """simple docstring""" assert isinstance(_UpperCAmelCase, _UpperCAmelCase ), f"The input value of [n={number}] is not an integer" if number == 1: return 2 elif number <...
350
'''simple docstring''' import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker ...
136
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_...
331
'''simple docstring''' import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class __lowercase ( tf.keras.layers.Layer ): def __init__(self , ...
318
0
def __UpperCamelCase (_SCREAMING_SNAKE_CASE = 10**12 ) -> int: lowercase__ = 1 lowercase__ = 0 lowercase__ = 1 lowercase__ = 1 while numerator <= 2 * min_total - 1: prev_numerator += 2 * numerator numerator += 2 * prev...
269
import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class SCREAMING_SNAKE_CASE (UpperCAmelCase ...
269
1
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( UpperCAmelCase_ : list , UpperCAmelCase_ : int ) -> str: '''simple docstring''' if len(UpperCAmelCase_ ) <= 1 or n <= 1: return insert_next(UpperCAmelCase_ , ...
172
"""simple docstring""" import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch...
172
1
"""simple docstring""" import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class lowerCAmelCase__ ( ...
318
"""simple docstring""" import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.d...
318
1
"""simple docstring""" from math import isqrt def _snake_case ( lowercase__ ): return all(number % divisor != 0 for divisor in range(2 , isqrt(lowercase__ ) + 1 ) ) def _snake_case ( lowercase__ = 10**6 ): _lowerCamelCase ...
96
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _lowerCAmelCase ( unittest.TestCase ,lowercase ): """simple docstring""" def _lowercase ( self : List[Any] ): __lowercase = ...
17
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImagePr...
365
"""simple docstring""" import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() _UpperCamelCase ...
234
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel...
38
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeni...
257
0
'''simple docstring''' import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transform...
275
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase :str = { '''configuration_vision_encoder_decoder''': ['''VisionEncoderDecoder...
275
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_availabl...
17
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_u...
199
0
from maths.prime_check import is_prime def A ( __UpperCAmelCase ) -> int: '''simple docstring''' if not isinstance(__UpperCAmelCase , __UpperCAmelCase ): UpperCAmelCase_ = f"Input value of [number={number}] must be an integer" ...
344
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase_ = logging.get_logger(__name__) class a_ ( _snake_case , _snake_case ): UpperCam...
344
1
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() __lowerCamelCase = logging.get_logger("""transformers.models.speecht5""") def UpperCamelCase ( __lowerCamelCase : Union[str,...
59
__lowerCamelCase = { "joule": 1.0, "kilojoule": 10_00, "megajoule": 1_00_00_00, "gigajoule": 10_00_00_00_00, "wattsecond": 1.0, "watthour": 36_00, "kilowatthour": 3_60_00_00, "newtonmeter": 1.0, "calorie_nutr": 41_86.8, "kilocalorie_nutr": 4_18_68_00.00, ...
59
1
import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transformers.utils import logging ...
367
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_availab...
229
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) __UpperCAmelCase = { """configuration_trocr""": ["""TROCR_PRETRAINED_CONFIG_ARC...
323
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { """microsoft/git-base""": """https://huggingface.co/microsoft/gi...
323
1
A_ :Union[str, Any] = [ '''DownloadConfig''', '''DownloadManager''', '''DownloadMode''', '''StreamingDownloadManager''', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import St...
245
def A ( a_ ) -> bool: if number < 0: raise ValueError('number must not be negative' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
245
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Any = logging.get_logger(__name__) __A : int = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json''', # See all GPTNeoX models at h...
138
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A = { "configuration_distilbert": [ "DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "...
231
0
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 tokeni...
252
import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --host <ho...
252
1
from __future__ import annotations def _UpperCamelCase ( lowercase__ , lowercase__ ): __SCREAMING_SNAKE_CASE : Union[str, Any] = sorted(numsa + numsa ) __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE : Tuple = divmod(len(_lowerCAmelCa...
9
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class __lowerCamelCase : '''simple docstring''' def __init__( self ) -> Tuple: _a = {} def _UpperCAmelCase ( s...
320
0
# Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - generate model_cards -...
359
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onn...
138
0
'''simple docstring''' import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class __lowercase ( _lowercase , _lowe...
318
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImageProces...
318
1
'''simple docstring''' import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FO...
352
'''simple docstring''' import logging from transformers import PretrainedConfig _snake_case = logging.getLogger(__name__) _snake_case = { 'bertabs-finetuned-cnndm': 'https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json', } class...
199
0
import math def lowerCAmelCase__ ( a__: int ) -> str: '''simple docstring''' _UpperCAmelCase = 0 _UpperCAmelCase = 0 while num > 0: _UpperCAmelCase = num % 8 _UpperCAmelCase = octal + (remainder * math.floor(math.pow(1_...
329
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule, get_constant_sche...
329
1
"""simple docstring""" import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _UpperCamelCase : Union[str, Any] = logging.get_...
351
"""simple docstring""" import os import sys _UpperCamelCase : str = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Auto...
186
0
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassification, MobileViTVaFor...
295
from collections.abc import Sequence def _lowerCamelCase( lowercase__ , lowercase__ = False ) -> float: '''simple docstring''' if not arr: return 0 __lowercase= 0 if allow_empty_subarrays else float('-inf' ) __lowercase= 0.0 for num in arr: __lowercase= max(0 if ...
295
1
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast fr...
199
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class a__ ( lowerCamelCase_ ): _SCREAM...
199
1
'''simple docstring''' from maths.prime_check import is_prime def UpperCAmelCase ( a_ ) -> int: """simple docstring""" if not isinstance(a_ , a_ ): A_ : int = F"Input value of [number={number}] must be an integer" raise...
344
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase__ : Any = { 'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2...
344
1
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class lowercase__ ( unittest.TestCase ): '''simple docstring''' a : Union[str, Any] = JukeboxTokenizer a : Optional[int] ...
365
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer UpperCAmelCase_ = logging.getLogger(__name__) def lowerCAmelCase_ ( ) -> Any: UpperCamelCase__ : Dict = argparse.Arg...
247
0
'''simple docstring''' import random from typing import Any def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> Union[str, Any]: for _ in range(len(a__ ) ): lowerCamelCase__ : Tuple = random.randint(0 ...
41
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
0
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np _lowerCamelCase : Optional[Any] = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 _lowerCamelCase : Optional[int] = typing.Union[np.floataa, i...
360
def a__ ( UpperCAmelCase : int ) -> bool: if not isinstance(UpperCAmelCase , UpperCAmelCase ): UpperCAmelCase : List[str] = f'''Input value of [number={number}] must be an integer''' raise TypeError(UpperCAmelCase ) if number < 0: return Fal...
99
0
import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyazr, require_zstandard @p...
348
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) # TODO Update this __snake_case = { '''facebook/esm-1b''': '''https://huggingface.co/facebook/esm-1b/re...
348
1
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": __lowerCamelCase : Tuple = input('''Enter image url: ''').strip() print(F"""Downloading image from {url} ...""") __lowerCamelCase : Optional[Any] = Beautifu...
204
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class __snake_case ( unittest.TestCase ): def __a ( self : Dict ): """simple docstring""" ...
204
1
'''simple docstring''' import math def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : int ): '''simple docstring''' UpperCAmelCase__ = 0 UpperCAmelCase__ = 0 while num > 0: UpperCAmelCase__ = num % 8 UpperCAmelCase__ = octal + (remainder * math.flo...
346
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _UpperCamelCase ( ): '''simple docstring''' import os as original_os from os import path as original_path from os import rename as original_rename from os.path im...
346
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @...
265
import pprint import requests _A : Any = 'https://zenquotes.io/api' def _a ( ) -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def _a ( ) -> list: """simple docstring""" return requests.get(API_EN...
265
1
'''simple docstring''' a_ = '\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https://github.com/huggi...
152
'''simple docstring''' import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets a_ = datasets.logging.get_logger(__name__) a_ = '\\n@inproceedings{bleurt,\n title={BLEURT: Learning Robust Metrics for Text Generation},\n...
152
1
"""simple docstring""" import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __UpperCamelCase = logging.ge...
367
"""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_features_out...
312
0
'''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 ): snake_c...
152
import os def _lowercase ( ) -> List[str]: '''simple docstring''' with open(os.path.dirname(UpperCamelCase_ ) + '/p022_names.txt' ) as file: SCREAMING_SNAKE_CASE__ = str(file.readlines()[0] ) SCREAMING_SNAKE_CASE__ = names.replace('"' ...
176
0
"""simple docstring""" 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, PreTrainedTokenize...
370
"""simple docstring""" def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = [False] * len(_UpperCamelCase ) __lowerCAmelCase = [] queue.append(_UpperCamelCase ) __...
259
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available UpperCamelCase__ : str = {'''tokenization_herbert''': ['''HerbertTokenizer''']} try: if not is_tokenizers_available(): raise OptionalDe...
112
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ : Any = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig''', ...
112
1
def lowerCamelCase_ ( _a : int , _a : int ): '''simple docstring''' if b == 0: return 1 if (b % 2) == 0: return actual_power(_a , int(b / 2 ) ) * actual_power(_a , int(b / 2 ) ) else: return a * actual_power(_a , int(b / 2 ) ...
59
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { '''shi-labs/dinat-mini-in1k-224''': '''http...
59
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configurat...
134
'''simple docstring''' import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Model...
134
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase_ : Tuple = {'''configuration_encoder_decoder...
350
"""simple docstring""" def _lowerCAmelCase ( ): '''simple docstring''' return [ a * b * (1000 - a - b) for a in range(1 , 999 ) for b in range(lowerCAmelCase , 999 ) if (a * a + b * b == (1000 - a - b) ** 2) ][0] if ...
248
0
'''simple docstring''' from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder lowercase__ : str = datasets.utils.logging.get_logger(__name__) class __lowerCAmelCase ( folder_based_builder.Folder...
324
"""simple docstring""" import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): impor...
291
0
import colorsys from PIL import Image # type: ignore def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_ ): _A : Dict = x _A : Optional[Any] = y for step in range(snake_case_ ): # noqa: B007 _A : Lis...
343
from __future__ import annotations from decimal import Decimal from numpy import array def lowerCAmelCase_ ( snake_case_ ): _A : Tuple = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works for 2x2 mat...
343
1
'''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, TestCa...
3
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available snake_case_ = { """configuration_longt5""": ["""LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LongT5Config""", """LongT5On...
78
0
"""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 transformers impo...
95
"""simple docstring""" import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _a : Dict= logging.get_logger(__name__) class UpperCamelCase ( lowercase ): def __init__(self : List[str] , *_A : Dict ...
95
1
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case_ = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctct''': ['''MCTCTFeatureExtractor'''], '''process...
214
def __lowerCamelCase ( UpperCAmelCase_ : int = 100_0000 ): """simple docstring""" a :Any = set(range(3 , UpperCAmelCase_ , 2 ) ) primes.add(2 ) for p in range(3 , UpperCAmelCase_ , 2 ): if p not in primes: ...
94
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE = { "con...
355
'''simple docstring''' import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __lowerCamelCase ( __lowerCA...
3
0
def SCREAMING_SNAKE_CASE_ ( __A : int , __A : Any ) -> str: """simple docstring""" return abs(lowerCamelCase__ ) if a == 0 else greatest_common_divisor(b % a , lowerCamelCase__ ) def SCREAMING_SNAKE_CASE_ ( __A : List[str] , ...
32
'''simple docstring''' from math import pow def a ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , ): '''simple docstring''' if current_sum == needed_sum: # If the sum of the powers is equal ...
206
0
from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestCommand ...
238
from __future__ import annotations snake_case_ = 'Muhammad Umer Farooq' snake_case_ = 'MIT' snake_case_ = '1.0.0' snake_case_ = 'Muhammad Umer Farooq' snake_case_ = 'contact@muhammadumerfarooq.me' snake_case_ = ...
238
1
"""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, ids_tensor, random_att...
61
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def __snake_case ( ): """simple docstring""" A_ = { "repo_name": ["test_repo1", "test_repo2", "test_repo3"], "...
312
0
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
104
'''simple docstring''' import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _A () -> Optional[Any]: '''simple docstr...
104
1
import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, is_staging_te...
29
from math import factorial __snake_case = {str(digit): factorial(digit) for digit in range(10)} def _A ( SCREAMING_SNAKE_CASE__ : int ): if not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): raise TypeError('''Parameter number must be int''' ...
259
0
"""simple docstring""" def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' return str(lowerCAmelCase_ ) == str(lowerCAmelCase_ )[::-1] def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' return int(lowerCAmelCase...
195
"""simple docstring""" import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pyt...
195
1
"""simple docstring""" import math def lowerCamelCase__ ( _lowerCamelCase : Any ) -> Union[str, Any]: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, ...
183
"""simple docstring""" # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger fro...
96
0
import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class __lowercase (__SCREAMING_SNAKE_CASE ): """simple docstring""" _UpperCAmelCase = (DDPMParallelScheduler,) ...
162
import argparse import os 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_task_guides.py lowerCAmelCase__ : Optional[Any] ='src/transformers' lowerCAmelC...
162
1
'''simple docstring''' import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_...
321
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE_ ( metaclass=__a ): """simple docstring""" __lowercase : Tuple = ['''keras_nlp'''] def __init__( self , *lowerCAmelCase__ , **lowerCAmelCase__): ...
100
0
import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization impor...
368
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A_ :int = logging.get_logger(__name__) A_ :List[str] = { '''facebook/xlm-roberta-xl''': ''...
245
0
import math def _SCREAMING_SNAKE_CASE ( a ) -> list[int]: __A : List[str] = [] __A : Any = 2 __A : Union[str, Any] = int(math.sqrt(a ) ) # Size of every segment __A : Any = [True] * (end + 1) __A : Lis...
280
import unittest from transformers import BertGenerationTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin UpperCAmelCase : List[str] = ...
280
1
'''simple docstring''' import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffu...
190
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): lowercase__ : Dict = { '''linear''': PIL.Image.Resampling.BILINE...
190
1
'''simple docstring''' import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu a : Any ...
56
'''simple docstring''' import re from filelock import FileLock try: import nltk a : Union[str, Any] = True except (ImportError, ModuleNotFoundError): a : Any = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', q...
56
1
"""simple docstring""" import torch def lowerCAmelCase( )-> str: """simple docstring""" if torch.cuda.is_available(): UpperCamelCase_ = torch.cuda.device_count() else: UpperCamelCase_ = 0 print(f"Successfully ran on {num...
366
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ = 1_0_0 )-> int: """simple docstring""" UpperCamelCase_ = (n * (n + 1) // 2) ** 2 UpperCamelCase_ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(F'''{solutio...
60
0
def SCREAMING_SNAKE_CASE_ ( snake_case__ ) -> List[Any]: if divisor % 5 == 0 or divisor % 2 == 0: return 0 lowerCAmelCase = 1 lowerCAmelCase = 1 while repunit: lowerCAmelCase = (1_0 * repunit + 1) % divisor ...
338
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('''dataset_size''' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('''input_in_memory_max_size''' , ['''default''', 0, 100...
3
0
"""simple docstring""" from math import factorial _UpperCamelCase = {str(d): factorial(d) for d in range(10)} def _a ( _snake_case ): """simple docstring""" return sum(DIGIT_FACTORIAL[d] for d in str(_snake_case ) ) def _a ( ): ""...
234
"""simple docstring""" import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokeniz...
234
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar _A : str =TypeVar('''T''') class _lowercase ( Generic[T] ): def __init__( self: List[str] , UpperCamelC...
41
import random def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE : List[Any] ): """simple docstring""" __a , __a , __a = [], [], [] for element in data: if element < pivot: less.append(_SCREAMING_SNAKE_CASE ...
302
0
'''simple docstring''' def __lowerCamelCase ( __snake_case : int | float | str ) -> tuple[int, int]: """simple docstring""" try: A__ : List[str] =float(__snake_case ) except ValueError: raise ValueError("""Please enter a vali...
357
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, ...
136
0
from __future__ import annotations class _A : def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[Any] = text, pattern SCREAMING_SNAKE_CASE_ : List[str] ...
253
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase ) -> float: '''simple docstring''' return math.sqrt(sum(pow(a - b, 2 ) for a, b in zip(_UpperCAmelCase, _Upp...
138
0
"""simple docstring""" def a__ ( _SCREAMING_SNAKE_CASE ): """simple docstring""" for i in range(len(_SCREAMING_SNAKE_CASE ) - 1 , 0 , -1 ): UpperCamelCase = False for j in range(_SCREAMING_SNAKE_CASE , 0 , -1 ): if unsorted[j] < unsor...
358
"""simple docstring""" import doctest from collections import deque import numpy as np class _lowerCamelCase : def __init__(self ) -> None: UpperCamelCase = [2, 1, 2, -1] UpperCamelCase = [1, 2, 3, 4] def snake_case_ (self ) -> list...
244
0
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, BlipI...
59
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(): import onnxruntime as ort __l...
59
1
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () __UpperCAmelCase = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
366
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(): ...
139
0
"""simple docstring""" import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetV...
269
"""simple docstring""" import os from math import logaa def _lowercase ( __snake_case = "base_exp.txt" ) -> int: __lowerCAmelCase : float = 0 __lowerCAmelCase : Any = 0 for i, line in enumerate(open(os.path.join(os.path.d...
269
1
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 lowerCAmelCase__ = logging.get_logger(_...
119
from __future__ import annotations lowerCAmelCase__ = tuple[int, int, int] lowerCAmelCase__ = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase lowerCAmelCase__ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # -------------------------- default selecti...
119
1
import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('.') def snake_case( __magic_name__ ) -> List[Any]: '''simple docstring''' low...
308
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase_ = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ], } tr...
308
1
'''simple docstring''' from __future__ import annotations def _snake_case ( A , A = None ) -> list[list[str]]: lowerCAmelCase__ = word_bank or [] # create a table lowerCAmelCase__ = len(A ) + 1 lowerCAmelCase__ ...
228
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_...
228
1
'''simple docstring''' from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder __a = datasets.utils.logging.get_logger(__name__) class UpperCAmelCase_ ( folder_based_builder.FolderBasedBu...
35
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def lowerCAmelCase_ ( _lowercase : Dict , _lowercase : str , _lowercase : str , _lowercase : Optional[Any]=1024) -> List[Any]:...
170
0
'''simple docstring''' import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings("ignore", category=UserWarning, module="torch.optim.lr_scheduler") class a : def __init__( self , __magic_name__ , __magic_name__ , __magic_name__ = True ,...
363
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable a_ : List[Any] = {"configuration_gpt_neox": ["GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_M...
104
0
def __lowerCAmelCase ( a__ , a__ , a__ ) -> int: def count_of_possible_combinations(a__ ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_combinations(target - item ) for item in array ) r...
6
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase ): lowercase__ , lowercase__ : Optional[int] = [], [] while len(UpperCAmelCase ) > 1: lowercase__ , lowercase__ : List[str] = min(UpperCAmelCase ), max(UpperCAmelCase ) start.append(UpperCAme...
198
0
"""simple docstring""" import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: ...
80
"""simple docstring""" import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trus...
80
1
def _UpperCamelCase ( lowercase__ = 1000 ): __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE : Optional[Any] = 1, 1 __SCREAMING_SNAKE_CASE : List[str] = [] for i in range(1 , n + 1 ): __SCREAMING_SNAKE_CASE : O...
9
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(""">=""", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint....
92
0
"""simple docstring""" def lowerCamelCase_ ( _lowerCamelCase , _lowerCamelCase ): return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
316
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) A_ : int = { "configuration_clip": ...
316
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { 'uclanlp/visualbert-vqa': 'https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json', 'uclanlp/visualbert-...
155
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) a = { 'configuration_speech_to_text': ['SPEECH_T...
155
1
"""simple docstring""" import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class ...
355
"""simple docstring""" def lowercase_ ( _lowerCamelCase: int ) -> int: '''simple docstring''' if not isinstance(_lowerCamelCase , _lowerCamelCase ): raise TypeError("Input value must be an 'int' type" ) __lowerCamelCase : Dict = 0 ...
64
0
def __A ( __lowerCAmelCase )-> int: """simple docstring""" if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('multiplicative_persistence() only accepts integral values' ) if num < 0: raise ValueError('multipli...
39
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class __A( __lowerCamelCase ): """simple docstring""" SCREAMING_SNAKE_CASE__ = (CMStochasticIterativeScheduler,) SCREAMING_SNAKE_CASE__ = 10 def UpperCAmel...
244
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _snake_case = { "configuration_convnext": ["CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ConvNextConfig", "ConvNextOnnxConfig"] }...
343
# Copyright (c) 2021-, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by...
343
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 a_ ( _lowerCAmelCase...
208
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase =...
208
1
"""simple docstring""" 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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDi...
53
"""simple docstring""" from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, ...
53
1
'''simple docstring''' import os import jsonlines import numpy as np from tqdm import tqdm __a: Optional[int] = 20_48 __a: Union[str, Any] = 40_96 __a: List[Any] = 42 __a: List[Any] = os.environ.pop("""PROCESS_TRAIN""", """false""") __a: Optional[Any] = {"""nul...
198
'''simple docstring''' 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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENA...
198
1
from statistics import mean import numpy as np def lowerCamelCase ( a_ , a_ , a_ , a_ ) -> list: lowerCAmelCase_ = 0 # Number of processes finished lowerCAmelCase_ = 0 # Displays the finished process....
14
import baseaa def lowerCamelCase ( a_ ) -> bytes: return baseaa.baaencode(string.encode('utf-8' ) ) def lowerCamelCase ( a_ ) -> str: return baseaa.baadecode(a_ ).decode('utf-8' ) if __name__ == "__main__": lowerCamelC...
14
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ :Any = logging.get_logger(__name__) A_ :int = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json''', # See all ViT...
71
A_ :str = '''0.21.0''' from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader import s...
71
1
def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> float: UpperCamelCase__ : List[str] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total ...
196
from __future__ import annotations def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase = None , __lowerCAmelCase = None ) -> None: if start is None: UpperCamelCase__ : Union[str, Any] = 0 if end is None: U...
196
1
'''simple docstring''' import colorsys from PIL import Image # type: ignore def _UpperCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): UpperCAmelCase__ : Dict = x UpperCAmelCase__ : int = y ...
163
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable lowerCAmelCase__ = { '''configuration_gpt_neox_japanese''': ['''GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXJap...
104
0
"""simple docstring""" from typing import Any class __snake_case : def __init__( self , lowercase) -> List[Any]: '''simple docstring''' a__: Tuple = data a__: Optional[int] = None def __repr__( ...
353
"""simple docstring""" import argparse import collections import json import os import re import string import sys import numpy as np lowercase__ = re.compile(r'\b(a|an|the)\b', re.UNICODE) lowercase__ = None def __a ( ) ->List[Any]: a__: Dict = argparse.Ar...
203
0
import os from distutils.util import strtobool def _snake_case ( lowerCAmelCase : Dict , lowerCAmelCase : Tuple ): """simple docstring""" for e in env_keys: SCREAMING_SNAKE_CASE_ : Dict = int(os.environ.get(lowerCAmelCase , -1 ) ) if val >= 0: retur...
18
'''simple docstring''' def lowerCAmelCase_ ( _lowerCamelCase: list ): if any(not isinstance(_lowerCamelCase , _lowerCamelCase ) or x < 0 for x in sequence ): raise TypeError("""Sequence must be list of non-negative integers""" ) for _ in range(len(_lowerCamelCase )...
112
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowercase_ = logging.get_logger(__name__) lowercase_ = { """Intel/dpt-large""": """https://huggingface.co/Intel/dpt-large/resolve/main/config.json""", # See all ...
359
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureEx...
224
0