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 warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor UpperCamelCase_ = logging.get_logger(__name__) class a_ (UpperCamelCase__ ): def __init__( self , *snake_case_ , **snake_case_ ...
309
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer a__: Optional[int] = logging.get_logger(__name__) a_...
193
0
"""simple docstring""" import math def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> Tuple: return math.pow(lowerCamelCase__ , 2 ) - a def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> List[str]: return 2 * x def SCREAMING_SNAKE_CASE__ (...
352
"""simple docstring""" from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class UpperCAmelCase : """simple docstring""" _UpperCAmelCase :s...
2
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import requ...
55
"""simple docstring""" import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStruct...
288
0
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse("3.8"): import importlib_metadata else: import importlib.metadata as importlib_metadata SCREAMING_SNAKE_...
252
def UpperCamelCase ( _a ) -> list: '''simple docstring''' if any(not isinstance(_a , _a ) or x < 0 for x in sequence ): raise TypeError('''Sequence must be list of non-negative integers''' ) for _ in range(len(_a ) ): ...
252
1
'''simple docstring''' __A = [ (1_000, "M"), (900, "CM"), (500, "D"), (400, "CD"), (100, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] def _A ( lowercase__ ): lowercase__ ...
164
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __A = logging.get_logger(__name__) __A = { "facebook/convnextv2-tiny-1k-224": "https://...
164
1
"""simple docstring""" import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as ...
86
"""simple docstring""" from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 _lowercase : str = { # 1536-bit 5: { ...
86
1
from collections.abc import Callable import numpy as np def lowerCAmelCase_ ( __A, __A, __A, __A, __A ) -> np.array: '''simple docstring''' UpperCAmelCase__ = int(np.ceil((x_end - xa) / step_size ) ) UpperCAmelCase__ =...
65
"""simple docstring""" from math import pi, sqrt, tan def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> float: '''simple docstring''' if side_length < 0: raise ValueError("""surface_area_cube() only accepts non-negative values""" ) return 6 * side_length...
136
0
def UpperCamelCase( lowercase_ ) -> bool: '''simple docstring''' snake_case_ = 0 for ch in input_str: snake_case_ = ord(lowercase_ ) snake_case_ = pow(2 , lowercase_ ) # If we already turned on bit for current character's uni...
356
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester ...
34
0
from statistics import mean import numpy as np def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , lowercase_ ) -> list: """simple docstring""" A__ = 0 # Number of processes finished A__ = 0 # Displays the...
14
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Any = logging.get_logger(__name__) class UpperCamelCase_ ( UpperCAmelCase__ ): '''simple docstring''' UpperCAmelCase__ = '''encoder-decoder''' ...
14
1
'''simple docstring''' from collections import defaultdict class _lowerCAmelCase : '''simple docstring''' def __init__(self , UpperCAmelCase , UpperCAmelCase ) -> Any: _snake_case = total # total no of tasks (N) # DP table will have a ...
270
'''simple docstring''' import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp ...
270
1
import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_visio...
230
from torch import nn class a ( nn.Module ): def __init__( self :Tuple ,__lowercase :Optional[int] ,__lowercase :int ): super().__init__() snake_case__ : Optional[Any] = class_size snake_case__ : Dict = embed_size ...
230
1
import unittest import numpy as np import requests from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(...
357
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def SCREAMING_SNAKE_CASE__ ( lowercase ) -> List[str]: return ConvertCommand( args.model_type ,args.tf_checkpoint ,args.pytorch_dump_output ,args.conf...
176
0
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowercase (SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : Any=False ) -> str: SCREAMING_SNAKE_CASE = ...
113
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class lowerCAmelCase ( datasets.BeamBasedBuilder ): '''sim...
113
1
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def _lowerCAmelCase ( UpperCAmelCase__ : List[str] ) ->str: return 1 / (1 + np.exp(-z )) def _lowerCAmelCase ( UpperCAmelCase__ : Union[s...
365
"""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...
296
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) A__ : Optional[Any] ={ '''configuration_mega''': ['''MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MegaConfig''', ...
70
'''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 .tokeniz...
70
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'tanreinama/GPTSAN-2.8B-spout_is_uniform': ( 'https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/resolve/main/config.json' ), } class _lowercase ...
366
import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurati...
50
0
'''simple docstring''' def _lowerCAmelCase ( _UpperCamelCase : int = 10_00 ) -> int: """simple docstring""" _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE =1, 1 _SCREAMING_SNAKE_CASE =[] for i in range(1 , n + 1 ): ...
47
'''simple docstring''' import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCamelCase : List[str] ...
2
0
"""simple docstring""" import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_co...
367
"""simple docstring""" from __future__ import annotations import numpy as np def lowercase ( _SCREAMING_SNAKE_CASE : np.ndarray ): '''simple docstring''' _UpperCAmelCase , _UpperCAmelCase = np.shape(_SCREAMING_SNAKE_CASE ) if...
326
0
import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from transformers.configuratio...
252
def __lowerCamelCase ( lowerCamelCase__ : Any , lowerCamelCase__ : Optional[int] ): '''simple docstring''' return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def __lowerCamelCase ( lowerCamelCase__ : List[str] , lowerCamelCase__ ...
252
1
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( ...
87
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCamelCase__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: Up...
87
1
__UpperCamelCase : str = """Input must be a string of 8 numbers plus letter""" __UpperCamelCase : List[Any] = """TRWAGMYFPDXBNJZSQVHLCKE""" def a_ ( _A ) -> bool: """simple docstring""" if not isinstance(_A , _A ): ...
307
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class __SCREAMING_SNAKE_CASE( ctypes.Structure ): # _fields is a specific attr expected by ctypes _Uppe...
307
1
'''simple docstring''' import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( 'The `image_to_image.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionImg2ImgPipeline` instead.' )
360
'''simple docstring''' from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case : int = logging.get_logger(__name__) __snake_case : str = { 'microsoft/xprophetnet-large-wiki100-cased': ( ...
18
0
import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset from transformers import Au...
52
'''simple docstring''' from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": A =input('Enter image url: ').strip() print(f"""Downloading image from {url} ...""") A =BeautifulSoup(requests.get(url).content, 'html.parser') # The image URL ...
34
0
import functools from typing import Any def _a ( UpperCAmelCase , UpperCAmelCase ) -> bool: """simple docstring""" # Validation if not isinstance(UpperCAmelCase , UpperCAmelCase ) or len(UpperCAmelCase ) == 0: raise ValueError('''the string should be...
265
from math import ceil, sqrt def _a ( UpperCAmelCase = 1000000 ) -> int: """simple docstring""" lowerCamelCase__ : Any = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: lowerCamelCase__ : ...
265
1
import re import string import numpy as np import datasets __UpperCamelCase : Union[str, Any] = """ Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. """ __UpperCamelCase ...
307
import doctest from collections import deque import numpy as np class __SCREAMING_SNAKE_CASE: def __init__( self: Dict ) -> None: snake_case__ = [2, 1, 2, -1] snake_case__ = [1, 2, 3, 4] def lowerCAmelCa...
307
1
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 ...
204
from math import isqrt def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : int ) -> list[int]: """simple docstring""" SCREAMING_SNAKE_CASE__ = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: ...
204
1
"""simple docstring""" import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_visio...
40
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''' import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration lowerCamelCase_ = { '''tiny.en''': '''https://openaipublic.azureedge.net...
174
'''simple docstring''' 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 imp...
174
1
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case_ : Union[str, Any] = logging.get_logger(__name__) snake_case_ : Optional[int] = {name: getattr...
51
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ ...
296
0
import requests from bsa import BeautifulSoup def UpperCamelCase ( _a = "https://www.worldometers.info/coronavirus" ) -> dict: '''simple docstring''' lowercase_ :List[str] = BeautifulSoup(requests.get(lowercase_ ).text , '''html.pars...
362
import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common import SequenceFeatu...
252
0
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from...
225
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 : Optional[Any]...
50
0
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase=7 ): __snake_case : str = None if token is not None: __snake_cas...
134
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def lowerCAmelCase_ ( __lowerCamelCase ): __snake_case : Any = [] __snake_case : Optional[Any] = ...
134
1
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> int: if divisor % 5 == 0 or divisor % 2 == 0: return 0 _lowerCAmelCase : Any = 1 _lowerCAmelCase : Optional[Any] = 1 while repunit: _lowerCAmelCase ...
44
class _a : def __init__( self: Any ) -> Tuple: """simple docstring""" lowercase__ = '''''' lowercase__ = '''''' lowercase__ = [] def lowerCamelCase...
110
0
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def UpperCamelCase__ ( ): __lowerCamelCase : Dict = { 'repo_name': ['test_repo1', 'test_repo2', 'test_repo3'], 'path': ['test_1.py', 'test_2.py'...
194
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_device=Fa...
194
1
"""simple docstring""" import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version lowerCAmelCase_ = version.parse(importlib_metadata.version('nltk')) if NLTK_VERSION >= version.Version('3.6.4'): f...
16
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase__ = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys lowercase__ = _LazyModule...
290
0
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu...
361
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determini...
222
0
"""simple docstring""" import requests from bsa import BeautifulSoup def a_ ( lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = BeautifulSoup(requests.get(lowerCamelCase , params=lowerCamelCase ).content , 'html.parser' ) UpperCAmelCa...
98
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDConditi...
18
0
from __future__ import annotations from math import pow, sqrt def A_ ( A__ , A__ , A__ ) -> dict[str, float]: if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError('One and only one argument must be 0' ) if resistance == 0: ret...
225
import glob import os import random from string import ascii_lowercase, digits import cva lowercase : Optional[Any] = """""" lowercase : int = """""" lowercase : List[Any] = """""" lowercase : Optional[int] = 1 # (0 is vertical, 1 is horizontal) def...
225
1
from __future__ import annotations import unittest from transformers import DistilBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_atten...
196
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase = { '''configuration_canine''': ['''CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CanineConfig'''], '''tokenization_canine''...
196
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) _SCREAMING_SNAKE_CASE = { "configuration_speecht5": [ "SPEECHT5_PRETRAINE...
371
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) fr...
3
0
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 snake_case ( unittest.TestCase ): '''simple docstring''' def...
317
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature fro...
90
0
"""simple docstring""" import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def a__ ( SCREA...
353
"""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: ...
133
0
'''simple docstring''' import argparse import os import re _UpperCAmelCase : Tuple = """src/transformers""" # Pattern that looks at the indentation in a line. _UpperCAmelCase : Any = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0....
174
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, Stabl...
174
1
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging __lowerCAmelCase = logging.get_logger(__name__) # TODO: upload to AWS __lowerCAmelCase = { '''yjernite/retribert-base-uncased''': ( '''https://huggingface.co/yj...
107
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { '''dis...
107
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase__ : int = { """configuration_m2m_100""": ["""M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP""", """M2M10...
224
"""simple docstring""" import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient lowercase__ : List[str] = WebClient(token=os.environ["""CI_SLACK_BOT_T...
224
1
def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" if n_term == "": return [] lowercase__ = [] for temp in range(int(SCREAMING_SNAKE_CASE ) ): series.append(f'1/{temp + 1}' if series else '''1''' ) return series if __name__ == "__ma...
93
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase = { 'configuration_luke': ['LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LukeConfig'], 'tokenization_luke': ['LukeTokenizer'], } try: if not is_torch_availa...
93
1
def lowercase__ ( __snake_case : float , __snake_case : float , __snake_case : int ): '''simple docstring''' if principal <= 0: raise Exception('Principal borrowed must be > 0' ) if rate_per_annum < 0: ...
29
from math import sqrt def UpperCAmelCase_ ( __UpperCAmelCase : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiple...
225
0
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, ) __lowerCamelCase : List[Any] = { """configuration_clip""": [ ...
368
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __lowerCamelCase : Any = collections.namedtuple("""_Datasets""", ["""...
140
0
"""simple docstring""" import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_...
16
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_property from ...t...
87
0
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py UpperCamelCase_ = "." if __name__ == "__main__": UpperCamelCase_ = os.path.join(REPO_PATH, "utils/documentation_tests.txt") ...
344
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "facebook/lev...
344
1
'''simple docstring''' _UpperCamelCase = '\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+...
208
'''simple docstring''' # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPText...
208
1
import os import sys import unittest lowercase_ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get_model_to_test_mapping, get_model_to_t...
20
from __future__ import annotations import math def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : bool , __SCREAMING_SNAKE_CASE : list[int] , __SCREAMING_SNAKE_CASE : float ): ...
20
1
"""simple docstring""" import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": UpperCamelCase : Union[str, Any] = argparse.ArgumentParser() parser.add_argument( "--checkpoint_path", default=None...
316
from __future__ import annotations import collections import pprint from pathlib import Path def __lowerCamelCase ( UpperCAmelCase_ : str ): """simple docstring""" return "".join(sorted(UpperCAmelCase_ ) ) def __lowerCamelCase ( UpperCAmelCase_ : str...
94
0
'''simple docstring''' import os import jsonlines import numpy as np from tqdm import tqdm __UpperCamelCase = 2048 __UpperCamelCase = 4096 __UpperCamelCase = 42 __UpperCamelCase = os.environ.pop("PROCESS_TRAIN", "false") __UpperCamelCase = {...
13
'''simple docstring''' import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever __UpperCamelCase = logging.getLogger(__name__) class _A ( ...
13
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import loggi...
66
'''simple docstring''' import requests from bsa import BeautifulSoup def lowerCAmelCase_ ( snake_case__ , snake_case__ ): '''simple docstring''' A : str = BeautifulSoup(requests.get(snake_case__ , params=snake_case__ ).content ...
3
0
"""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_roform...
367
"""simple docstring""" import logging import os import threading import time try: import warnings except ImportError: snake_case_ = None try: import msvcrt except ImportError: snake_case_ = None try: import fcntl except ImportError: snake_case_...
181
0
import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils import assert_arrow...
182
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate lowercase_ : Optional[Any] = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow('', '|', '|'), data...
133
0
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as...
344
import functools def A ( __UpperCAmelCase , __UpperCAmelCase ) -> int: '''simple docstring''' UpperCAmelCase_ = len(__UpperCAmelCase ) UpperCAmelCase_ = len(__UpperCAmelCase ) @functools.cache def min_distance(_...
344
1
def __lowerCamelCase ( UpperCAmelCase_ : Any , UpperCAmelCase_ : Any ): """simple docstring""" a :Union[str, Any] = [1] for i in range(2 , UpperCAmelCase_ ): factorials.append(factorials[-1] * i ) assert 0 <= k < fac...
94
def __lowerCamelCase ( UpperCAmelCase_ : int = 1000 ): """simple docstring""" a , a :int = 1, 1 a :Any = 2 while True: a :Optional[int] = 0 a :str = fa + fa ...
94
1
'''simple docstring''' from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class UpperCAmelCase_ : '''simple docstring''' pass
363
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """YituTech/conv-bert-base""": """https://hug...
229
0
'''simple docstring''' from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _snake_case : lowerCAmelCase_ : int lowerCAmelCase_ : TreeNode | None = None lowerCAmelCase_ : TreeNode | No...
85
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) _SCREAMING_SNAKE_CASE = models.Sequential() # Step 1 -...
343
0
"""simple docstring""" def a__ ( lowerCAmelCase__ ): for i in range(0 , lowerCAmelCase__ ): for _ in range(0 , n - i - 1 ): # printing spaces print(" " , end="" ) for _ in range(0 , i + ...
371
"""simple docstring""" from collections.abc import Iterable from typing import Generic, TypeVar lowerCamelCase = TypeVar("""_T""") class lowercase__ ( Generic[_T] ): '''simple docstring''' def __init__( self : int , _Up...
241
0
import collections import os import re from pathlib import Path _SCREAMING_SNAKE_CASE : int = '''src/transformers''' # Matches is_xxx_available() _SCREAMING_SNAKE_CASE : List[str] = re.compile(r'''is\_([a-z_]*)_available()''') # Catches a one-line _import_struct = {xxx} _SCREAMING_SNAKE_CA...
314
import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vision from transformers.utils ...
314
1
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 from .utils import require_...
82
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 from .utils import require_...
82
1
import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) class UpperCamelCase__ ( lowerCAmelCase_ ): '''simple docstring''' def __init__( self : ...
296
import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments SCREAMING_SNAKE_CASE_ = logging.getLogger(__name__) @dataclass class UpperCamelCase__ ( lowerCAmel...
296
1
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, ...
371
"""simple docstring""" import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": UpperCAmelCase =argparse.ArgumentParser() parser.add_argument("--dump_path", de...
77
0
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def _snake_case( SCREAMING_SNAKE_CASE__ ) -> tuple: return ...
20
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class __snake_case : _a : int _a : TreeNode | None= None _a : TreeNode | None= None lowercase : Dict = namedtuple("""CoinsDistribResult""",...
20
1
"""simple docstring""" import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from t...
371
"""simple docstring""" import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency a_ = { """E""": 12.70, """T""": 9.06, """A""": 8.17, """O""": 7.51, """I""": 6.97, """N""": 6.75, """S""": 6.33, """H""": 6.09, """R""": 5.99, """D""": 4.25...
291
0
import os import jsonlines import numpy as np from tqdm import tqdm lowerCAmelCase : Optional[int] = 2048 lowerCAmelCase : Dict = 4096 lowerCAmelCase : Any = 42 lowerCAmelCase : str = os.environ.pop("""PROCESS_TRAIN""", """false""") lowerCAmelCase :...
13
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, DistributedTy...
13
1
import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenization_transfo_xl import CORPUS_N...
103
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class lowerCAmelCase_ ( unittest.TestCase ): UpperCAmelCase__ : Union[str, Any] = JukeboxTokenizer UpperCAmelCase__ : Optional[int] = { ...
103
1
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput ...
151
'''simple docstring''' import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py lowercase__ = "\\n@INPROCEEDINGS{Papineni02bleu:a,\n author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu},\n title = {B...
151
1
'''simple docstring''' import requests from bsa import BeautifulSoup def UpperCamelCase ( a , a ) -> str: '''simple docstring''' __magic_name__ = BeautifulSoup(requests.get(a , params=a ).content , '''html.parser''' ) __magic_name__ ...
98
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers....
98
1
'''simple docstring''' from __future__ import annotations lowercase__ : Optional[int] = tuple[int, int, int] lowercase__ : Optional[Any] = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase lowercase__ : str = 'ABCDEFGH...
324
'''simple docstring''' import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowercase__ : Tuple = logging.get_logger(__name...
324
1
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependencyNotAvailabl...
65
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): # Check if the input is valid if not len(SCREAMING_SNAKE_CASE ) == len(SCREAMING_SNAKE_CASE ) == 3: raise ValueError('''Please enter a valid equation.''' ) if equationa[0] == equationa[1] == equationa[0] == equationa...
65
1
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import GenerationTester...
43
'''simple docstring''' import math import unittest def UpperCAmelCase__ ( UpperCAmelCase__ ) -> bool: assert isinstance(UpperCAmelCase__, UpperCAmelCase__ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 ar...
162
0
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class A_ (lowercase__ ): '''simple docstring''' SC...
360
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class A_ (lowercase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__...
23
0
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets UpperCamelCase = '''\ @inproceedings{snover-etal-2006-study, title = "A Study of Translation Edit Rate with Targeted Human Annotation", author = "Snover, Matthew and Dorr, Bonnie and ...
87
import operator def lowercase_ ( _lowerCamelCase : list , _lowerCamelCase : bool = False , _lowerCamelCase : list | None = None): lowercase__ : int = operator.lt if reverse else operator.gt lowercase__ : str = solution or [] if ...
87
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Optional[Any] = { "came...
359
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
84
0
'''simple docstring''' import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTok...
31
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 _UpperCAm...
207
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers import AutoTokenizer, TF...
317
"""simple docstring""" from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def __UpperCAmelCase ( snake_case_ : Union[str, Any] ) -> Dict: """simple docstring""" return getitem, k def __UpperCAm...
317
1
def SCREAMING_SNAKE_CASE_ ( __A : list[list] ) -> list[list]: """simple docstring""" a_ : List[str] = current_set.copy() for row_index, row in enumerate(__A ): a_ : List[str] = row[0] for column_index, column ...
32
"""simple docstring""" import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy...
77
0
"""simple docstring""" import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def ...
340
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging _lowerCAmelCase : Dict ...
340
1
import math import flax.linen as nn import jax.numpy as jnp def _a ( SCREAMING_SNAKE_CASE_ : jnp.ndarray , SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : float = 1 , SCREAMING_SNAKE_CASE_ : float = 1 , SCREAMING_S...
92
"""simple docstring""" import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils i...
113
0
"""simple docstring""" from __future__ import annotations import typing from collections import Counter def _A ( lowercase ): """simple docstring""" a =Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(UpperC...
363
"""simple docstring""" from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image ...
215
0
"""simple docstring""" from scipy.stats import pearsonr import datasets __UpperCamelCase = ''' Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the a...
69
"""simple docstring""" import argparse __UpperCamelCase = '''docs/source/_static/js/custom.js''' def UpperCAmelCase ( UpperCAmelCase ) -> int: with open(UpperCAmelCase , encoding='utf-8' , newline='\n' ) as f: snake_case_ = f....
69
1
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 is_torc...
359
'''simple docstring''' from bisect import bisect from itertools import accumulate def __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> str: __lowerCamelCase = sorted(zip(UpperCamelCase__ , UpperCamelCase__ ) ...
237
0
def lowerCAmelCase_ ( __lowerCamelCase ): if edge <= 0 or not isinstance(__lowerCamelCase , __lowerCamelCase ): raise ValueError("Length must be a positive." ) return 3 * ((2_5 + 1_0 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def lowerCAmelCase_ ( __lo...
123
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor _snake_case : Optional[Any] = logging.get_logger(__name__) class a (_lowerCAmelCase ): """simple docstring""" def __init__( self : Optional[Any] , *lowerCa...
123
1
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : Dict = 4_00_00_00 ): """simple docstring""" _snake_case : Optional[int] = [] _snake_case , _snake_case : Optional[int] = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(_lowerc...
359
"""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...
132
0
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_bart import BartTokenizer ...
65
from __future__ import annotations from scipy.special import comb # type: ignore class A : def __init__(self : List[Any] , __UpperCAmelCase : list[tuple[float, float]] ) -> List[str]: """simple docstring""" UpperCAmelCase__ ...
65
1
'''simple docstring''' import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is...
365
'''simple docstring''' import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_t...
220
0
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def __UpperCamelCase ( self : Optional[int] ) ...
76
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, ...
23
0
"""simple docstring""" import random def __lowerCAmelCase ( a__ , a__ , a__ = False ) -> Optional[int]: __a = {i: [] for i in range(_A )} # if probability is greater or equal than 1, then generate a complete graph if probability >= 1: return comple...
357
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) A : str = { 'configuration_perceiver': ['PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PerceiverConfig', 'P...
33
0
def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' _validate_point(SCREAMING_SNAKE_CASE ) _validate_point(SCREAMING_SNAKE_CASE ) if len(SCREAMING_SNAKE_CASE ) != len(SCREAMING_SNAKE_CASE ): raise ValueError('''Both points must be in the same n...
43
"""simple docstring""" from PIL import Image def _snake_case ( lowercase__ : Image , lowercase__ : float ) -> Image: '''simple docstring''' def brightness(lowercase__ : int ) -> float: return 1_2_8 + level + (c - 1_2_8) if n...
84
0
def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase ): if mass < 0: raise ValueError("The mass of a body cannot be negative" ) return 0.5 * mass * abs(lowercase__ ) * abs(lowercase__ ) if __name__ == "__main__": import doctest doctest....
356
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSchedul...
134
0
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class snake...
87
"""simple docstring""" 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 transfo...
61
0
'''simple docstring''' from __future__ import annotations def snake_case_ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ )-> dict[str, float]: '''simple docstring''' if (voltage, current, resistance).count(0 ) != 1: raise ValueError("""One an...
370
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance A_ : List[Any] = 637_8137.0 A_ : Dict = 635_6752.31_4245 A_ : int = 6_3_7_8_1_3_7 def snake_case_ ( lowerCAmelCase_ ,...
349
0
import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def _a ( UpperCamelCase_ ...
340
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer a_ = logging.get_logger(__name__) a_ = {'''vocab_file''...
340
1
'''simple docstring''' from collections import defaultdict from math import ceil, sqrt def lowercase__ ( __UpperCamelCase = 1000000 , __UpperCamelCase = 10 )-> int: UpperCamelCase = defaultdict(__UpperCamelCase ) for outer_width in range(3 , ...
183
'''simple docstring''' def lowercase__ ( __UpperCamelCase , __UpperCamelCase )-> list: UpperCamelCase = word.split() def justify(__UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> str: UpperCamelCase = max_width - width ...
183
1
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __UpperCamelCase = (720, 1280) # Height, Width __UpperCamelCase = (0.4, 0.6) # if height or width lower than this scale, drop it. __UpperCamelCase ...
69
'''simple docstring''' import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from tr...
215
0
import argparse import os import re import zipfile import torch from transformers import AutoTokenizer, GPTaConfig def _lowercase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_=0 ) -> int: '''simple docstring''' if name is None: SCREAMING_SNAKE_C...
351
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() __snake_case = logging.get_logger(__name__) __snake_case = {name: getattr(transformers, name + """Fast""") for name in SLOW_TO...
169
0