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 pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def UpperCAmelCase_ ( __lowercase : int , ...
22
'''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 center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET...
341
0
"""simple docstring""" import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cach...
203
"""simple docstring""" def __a ( _SCREAMING_SNAKE_CASE ) ->bool: return credit_card_number.startswith(('34', '35', '37', '4', '5', '6') ) def __a ( _SCREAMING_SNAKE_CASE ) ->bool: a__: Any = credit_card_number a__: Tuple ...
203
1
import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC lowercase__ :Optional[Any] = parse(importlib.metadata.version("torch")) def UpperCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase...
101
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE = None ,_SCREA...
48
0
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 l...
261
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer _A = logging.get_logger(__name__) _A = {'''vocab_fil...
261
1
"""simple docstring""" from heapq import heappop, heappush import numpy as np def snake_case_ ( A_ : np.ndarray, A_ : tuple[int, int], A_ : tuple[int, int], A_ : bool, ): '''simple docstring''' _lowerCamelCase , _lowerCamelCase ...
72
"""simple docstring""" import math def snake_case_ ( A_ : int ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, ...
72
1
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> str: lowerCamelCase__ : str =...
352
'''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 HfArgumentPar...
129
0
class snake_case__ : """simple docstring""" def __init__( self : Optional[Any] , __lowerCamelCase : int ) -> List[str]: # we need a list not a string, so do something to change the type a = arr.split("," ) def _...
107
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCam...
243
0
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_c...
355
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer _UpperCAmelCase = logging.get_logger(__name__) _Uppe...
192
0
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, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils i...
232
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar lowercase : Optional[Any] = TypeVar('T') class lowerCamelCase__ ( Generic[T]): '''simple docstring''' _A = 42 # Cache store ...
232
1
import fire from utils import calculate_rouge, save_json def lowerCamelCase_ ( lowerCAmelCase: List[Any] , lowerCAmelCase: int , lowerCAmelCase: Any=None , **lowerCAmelCase: List[Any] )-> Any: _snake_case : int = [x.strip() for x in open(l...
358
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATAS...
260
0
'''simple docstring''' import unittest import numpy as np from transformers import DistilBertConfig, 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(): import j...
83
"""simple docstring""" UpperCamelCase_ = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} UpperCamelCase_ = ['a', 'b', 'c', 'd', 'e'] def UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) ->Optional[int]: """simple docstring""" ...
243
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE :Optional[int] = { 'RWKV/rwkv-4-169m-pile': 'https://huggingface.co/RWKV/rwkv-4-1...
359
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : int , __lowercase : Optional[int] , __lowercase : List[Any] , __lowercase : int ) -> Tuple: '''simple docstring''' _UpperCAmelCase = [False] * l...
156
0
'''simple docstring''' from __future__ import annotations from collections import namedtuple def lowerCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ ): '''simple docstring''' A : Optional[int] = namedtuple('''result''' ,...
3
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_torch cl...
240
0
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load...
245
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging A_ :Union[str, Any] = logging.get_logger(__name__) A_ :Tuple = { '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased/resolve/main/config.json''', '''x...
245
1
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class a_ (unittest.TestCase ): def ...
309
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch import nn ...
280
0
"""simple docstring""" import math import unittest def __lowerCamelCase ( a_ : int ) -> bool: assert isinstance(a_ , a_ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: ...
239
"""simple docstring""" import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class _SCREAMING_SNAKE_CASE( A ): ...
239
1
'''simple docstring''' import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipeline...
112
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase = { '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], } try: if n...
254
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Union[str, Any] = { """config...
318
"""simple docstring""" from itertools import permutations def _A (__a ) -> bool: """simple docstring""" if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False SCREAMING_SNAK...
318
1
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__ = { 'andreasmadsen/efficient_mlm_...
65
def lowerCAmelCase__ ( lowerCamelCase_ : str): '''simple docstring''' lowerCAmelCase__ : Any = [0] * len(lowerCamelCase_) for i in range(1 ,len(lowerCamelCase_)): # use last results for better performance - dynamic programming lowerCAmelCase__ ...
129
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor a_ : List[Any] = logging.get_logger(__name__) class __UpperCamelCase ( lowerCamelCase__ ): def __init__( self, *lowerCAmelCase, **...
6
'''simple docstring''' from itertools import product def a_ ( __snake_case : int , __snake_case : int ) -> list[int]: """simple docstring""" lowerCamelCase_ =sides_number lowerCamelCase_ =max_face_number * dice_...
6
1
"""simple docstring""" import argparse import os import re __a = 'src/diffusers' # Pattern that looks at the indentation in a line. __a = re.compile(r"^(\s*)\S") # Pattern that matches `"key":" and puts `key` in group 0. __a = re.compile(r"^\s*\"([^\"]+)\":") # Pattern that matches `_impo...
66
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, requir...
192
0
"""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 data...
215
"""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
1
"""simple docstring""" from __future__ import annotations def _A ( UpperCamelCase_ : list[int]) -> int: '''simple docstring''' if not nums: return 0 __lowercase = nums[0] __lowercase = 0 for num in nums[1:]: __lowercase ,__lowercase ...
17
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : Union[str, Any] = logging.get_logger(__name__) __A : Dict ...
260
0
'''simple docstring''' import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler...
353
'''simple docstring''' import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepie...
25
0
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, PixaStructProcessor, PixaStructTextConfig, ...
50
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase : str = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_torch_available(): raise...
156
0
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class SCREAMING_SNAKE_CASE__ ( unittest.TestCase , lowerCamelCase_ ): def UpperCamelCase ( self ): A__ = load_tool('''text-classification'...
366
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a__: List[Any] = logging.get_logger(__name__) a__: Optional[Any] = { 'microsoft/unispeech-large-1500h-cv': ( 'https://huggingface.co/microsoft/unispeec...
39
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = { 'configuration_time_series_transformer': [ 'TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Time...
84
import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEmbeddings, ...
245
0
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before toke...
361
import json import os import tempfile import unittest import numpy as np from datasets import load_dataset 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 ImageProcessingSavi...
223
0
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device...
89
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import load_numpy, slow f...
343
0
import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import ConfigTester ...
315
from __future__ import annotations import collections import pprint from pathlib import Path def a ( SCREAMING_SNAKE_CASE_ : str ): """simple docstring""" return "".join(sorted(SCREAMING_SNAKE_CASE_ ) ) def a ( SCREAMIN...
315
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : int = { '''configuration_blenderbot''': [ ...
318
'''simple docstring''' import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_r...
318
1
from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstrings, add_start_docstrings_t...
362
import math def __UpperCamelCase ( _A : int = 100 ) ->int: """simple docstring""" lowerCamelCase_ =sum(i * i for i in range(1 , n + 1 ) ) lowerCamelCase_ =int(math.pow(sum(range(1 , n + 1 ) ) , 2 ...
49
0
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor A : Tuple = logging.get_logger(__name__) class __A( a ): def __init__( self , *_snake_case , **_snake_case ) -> None: '''simple docstring''' ...
6
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 A : List[str] = logging.get_logger(__name__) A : Optional[int] = { 'facebook/levit-128S': '...
6
1
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__ = { "facebook/xmod-base":...
26
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__ ...
26
1
'''simple docstring''' import argparse import json import subprocess def snake_case_ ( lowerCAmelCase_ , lowerCAmelCase_ )-> Optional[int]: '''simple docstring''' _UpperCAmelCase : Optional[Any] = [] _UpperCAmelCase : Optional[Any] ...
215
'''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
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase = { """configuration_rag""": ["""RagConfig"""], """retrieval_rag""": ["""RagRetriever"""], """tokenization_rag""": ["""RagTokenizer"""], ...
370
from __future__ import annotations class __lowercase : '''simple docstring''' def __init__( self : List[Any] , _a : int ): UpperCamelCase__ = data UpperCamelCase__ = None UpperCamelCase__ = ...
35
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase : int = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_vision_available()...
47
"""simple docstring""" import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, ...
25
0
def a__ ( lowerCAmelCase , lowerCAmelCase ) -> str: if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) UpperCAmelCase__ : Optional[Any] = str(bin(lowerCAmelCase ) )[2:] # remove the leading "0b" UpperCAmelCase__ : str...
358
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from ...
166
0
'''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'''): _lowerCAmelCase = { '''linear''': PIL.Image.Resampling.BILINEAR, '''bilinear''': P...
37
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set...
39
0
'''simple docstring''' from __future__ import annotations from random import choice def __lowerCamelCase ( __lowerCAmelCase : Optional[int] ) -> str: return choice(__lowerCAmelCase ) def __lowerCamelCase ( __lowerCAmelCase :...
3
'''simple docstring''' def __lowerCamelCase ( __lowerCAmelCase : Dict ) -> Optional[Any]: return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], ...
3
1
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( A_ ): lowerCAmelCase__ : Union[str, Any] = len(A_ ) for i in range(length - 1 ): lowerCAmelCase__ : Tuple = i for k in range(i + 1 , A_ ): if collection[k] < collection[least]: lowerCAmelCase__ : Optional[i...
106
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_comm...
255
0
def UpperCamelCase_( lowerCamelCase_ ) -> Optional[Any]: # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection _lowercase : str = len(lowerCamelCase_ ) _lowercase : Optional[int] = ...
84
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_altclip": [ "ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "AltCLIPConfig", "AltC...
84
1
"""simple docstring""" import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import ...
315
"""simple docstring""" from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDepe...
315
1
from __future__ import annotations snake_case__ : List[str] = list[tuple[int, int]] snake_case__ : str = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0...
250
def _a ( lowerCamelCase: str ) -> bool: '''simple docstring''' __A = [int(lowerCamelCase ) for i in ip_va_address.split('''.''' ) if i.isdigit()] return len(lowerCamelCase ) == 4 and all(0 <= int(lowerCamelCase ) <= 2_5...
250
1
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A : int = logging.get_logger(__name__) A : Union[str, Any] = '''▁''' A : List[str] = {'''vocab_file''...
6
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def __snake_case ( _UpperCAmelCase = "isbn/0140328726" ): __a = olid.strip().strip('''/''' ) # Remove leading/trailing whitespace & slashes if new_olid.count('''/''' )...
49
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class a ( __lowerCAmelCase ): """simple docstring""" lowerCamelCase :List[str] = ['''image_processor''', '''tokenizer'''] lowerCamelC...
81
import colorsys from PIL import Image # type: ignore def snake_case ( snake_case__ :float , snake_case__ :float , snake_case__ :int) -> float: _A = x _A = y for step in range(snake_case__): # noqa: B007 ...
81
1
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATU...
26
from math import asin, atan, cos, radians, sin, sqrt, tan _snake_case = 6_3_7_8_1_3_7.0 _snake_case = 6_3_5_6_7_5_2.3_1_4_2_4_5 _snake_case = 6378137 def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_,snake_case_ ): _A : Any ...
26
1
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TE...
39
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class SCREAMING_SNAKE_CASE__ ( tf.keras.optimizers.sched...
39
1
import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor A : Optional[int] = logging.get_logger(__name__) class _lowercase ( _a): """simple docstring""" def __init__( self : ...
184
'''simple docstring''' import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaV...
35
0
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenizati...
352
"""simple docstring""" import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import FlaxAu...
203
0
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 ...onnx...
273
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MCT...
166
0
'''simple docstring''' def _lowerCAmelCase ( _UpperCamelCase : int = 60_08_51_47_51_43 ) -> int: """simple docstring""" try: _SCREAMING_SNAKE_CASE =int(_UpperCamelCase ) except (TypeError, ValueError): raise TypeError('Parameter n must be in...
114
'''simple docstring''' from math import factorial def _lowerCAmelCase ( _UpperCamelCase : int , _UpperCamelCase : int , _UpperCamelCase : float ) -> float: """simple docstring""" if successes > trials: raise ValueError('successes mu...
114
1
'''simple docstring''' from __future__ import annotations from random import choice def lowerCAmelCase_ ( snake_case__ ): '''simple docstring''' return choice(snake_case__ ) def lowerCAmelCase_ ( snake_case__ , snake_case__ ...
3
'''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 ( center_crop, get_resize_output_image_size, normalize, rescale, resiz...
3
1
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __A = logging.get_logger(__name__) class __lowerCAmelCase ( UpperCamelCase_ ): """simple docstring""" def __init__( self , *lowerCamelCase__ , **lowerCam...
362
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "asapp/sew-d-tiny-100k": "https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json", # See all SEW-D models...
348
0
"""simple docstring""" import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( A__ ): UpperCAmelCase_ :Dict = (PNDMScheduler,) UpperCAmelCase_ :Tuple = (("n...
84
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __UpperCAmelCase = { 'configuration_roc_bert': ['ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoCBertConfig'], 'token...
84
1
from __future__ import annotations _UpperCamelCase = [] def UpperCamelCase_( snake_case__: list[list[int]] , snake_case__: int , snake_case__: int ) -> bool: for i in range(len(snake_case__ ) ): if board[row][i] == 1: return False for i in range(len(...
335
class lowercase : # Public class to implement a graph '''simple docstring''' def __init__(self , __a , __a , __a ) -> None: """simple docstring""" UpperCAmelCase__ = row UpperCAmelCase__ = col UpperCAmelCase__ = graph ...
335
1
'''simple docstring''' import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.ut...
250
'''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 ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resi...
250
1
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): lowercase : Optional[int] = yaml.safe_load( """\ name: \"\" allow_empty: false allow_empty_text: true subsections: - nam...
225
def A_ ( A__ ) -> List[str]: # noqa: E741 a__ : Dict = len(A__ ) a__ : str = 0 a__ : Any = [0] * n a__ : int = [False] * n a__ : Optional[Any] = [False] * n def dfs(A__ , A__ , A_...
225
1
"""simple docstring""" def _A ( lowercase , lowercase ): """simple docstring""" if b == 0: return 1 if (b % 2) == 0: return actual_power(lowercase , int(b / 2 ) ) * actual_power(lowercase , int(b / 2 ) ) e...
81
"""simple docstring""" lowerCamelCase_ : Any = [ """DownloadConfig""", """DownloadManager""", """DownloadMode""", """StreamingDownloadManager""", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .st...
81
1
"""simple docstring""" import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( '''files''' , [ ['''full:README.md''', '''dataset_infos.json'''], ['''empty:README.md'...
367
"""simple docstring""" def lowerCamelCase (a_ :int) -> None: lowercase :Tuple = generate_pascal_triangle(a_) for row_idx in range(a_): # Print left spaces for _ in range(num_rows - row_idx - 1): print(end=''' ''') ...
172
0
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() _a = logging.get_logger(__name__) _a = { '''post_extract_proj''': '''feature_projection.projectio...
39
import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging _a = logging.get_logger(__name__) def __A ( ...
39
1
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils ...
362
"""simple docstring""" from math import factorial lowerCamelCase_ = {str(d): factorial(d) for d in range(10)} def snake_case ( A__ ): return sum(DIGIT_FACTORIAL[d] for d in str(A__ ) ) def snake_case ( ): UpperCAmelCase_ : int = 7 * fac...
253
0
'''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 ...
34
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { """facebook/xmod-base""": """ht...
203
0
"""simple docstring""" from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available()...
365
"""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 tra...
320
0
from collections.abc import Iterable from typing import Any class a : """simple docstring""" def __init__( self : Dict , __lowercase : int | None = None ) -> Dict: __UpperCAmelCase : Union[str, Any] = value ...
114
from ...configuration_utils import PretrainedConfig from ...utils import logging a : Optional[int] = logging.get_logger(__name__) a : List[Any] = { "facebook/xglm-564M": "https://huggingface.co/facebook/xglm-564M/resolve/main/config.json", # See all XGLM mode...
114
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import t...
360
from maths.prime_factors import prime_factors def _A ( lowerCAmelCase_ : int ): """simple docstring""" if not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ): lowerCAmelCase__ = F'Input value of [number={number}] must be an int...
221
0
'''simple docstring''' def __magic_name__ ( __UpperCAmelCase = 200 ) -> int: '''simple docstring''' snake_case_ = [1, 2, 5, 10, 20, 50, 100, 200] snake_case_ = [0] * (pence + 1) snake_case_ = 1 # base case: 1 way to make 0 pence for coin in c...
56
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCAmelCase_ ( __lowerCAmelCase )-> Optional[Any]: '''simple docstring''' def is_in_circle(__lowerCAmelCase , __lowerCAmelCase ) -> bool: ...
348
0
"""simple docstring""" from pathlib import Path import numpy as np from PIL import Image def _A (__a ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[int] = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :, 2] return 0.29_89 * r + 0.58_70 * g + 0.11_40 * b de...
366
"""simple docstring""" UpperCAmelCase_ : List[Any] = 9.8_0_6_6_5 def _A (__a , __a , __a = g ) -> float: """simple docstring""" if fluid_density <= 0: raise ValueError('''Impossible fluid density''' ) if volume < 0: ra...
318
0
"""simple docstring""" from __future__ import annotations SCREAMING_SNAKE_CASE_ : Optional[Any] = [] def _snake_case ( UpperCAmelCase_ : list[list[int]] , UpperCAmelCase_ : int , UpperCAmelCase_ : int ): for i in range(len(Up...
335
"""simple docstring""" import unittest import torch from torch import nn from diffusers.models.activations import get_activation class a ( unittest.TestCase ): """simple docstring""" def UpperCamelCase ( self: str ): """simple doc...
335
1
"""simple docstring""" from __future__ import annotations def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> list: SCREAMING_SNAKE_CASE__ : List[str] = [] SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CA...
56
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example a :str = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0...
56
1
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging __lowerCAmelCase : Dict =logging.get_logger(__name__) def _UpperCamelCase ( lowercase__ , lowercase__ ): __SCREAMING_SNAKE_CASE : ...
9
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorT...
251
0
from __future__ import annotations class _snake_case : def __init__( self , a = 0) -> Optional[Any]: SCREAMING_SNAKE_CASE = key def SCREAMING_SNAKE_CASE__ ( self , a , a) -> list[str]: assert isinstance(a , a) and i...
363
import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils import is_torch_availa...
327
0
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCAmelCase_ ( A_ ): lowercase__ = ["""image_processor""", """tokenizer"""] lowercase__ = """CLIPImageProces...
247
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _a : str= { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "tokenization_xlm":...
172
0
"""simple docstring""" # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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 # ...
359
"""simple docstring""" import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu,...
182
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_b...
312
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer __a :List[str] = {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'} _...
312
1
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py __lowercase...
367
'''simple docstring''' def SCREAMING_SNAKE_CASE__( _UpperCamelCase : str ) -> bool: '''simple docstring''' return credit_card_number.startswith(("34", "35", "37", "4", "5", "6") ) def SCREAMING_SNAKE_CASE__( _UpperCamelCase : str ) ...
31
0
'''simple docstring''' import requests UpperCamelCase__ : Dict = 'YOUR API KEY' def UpperCAmelCase ( a_ , a_ = giphy_api_key ) -> Tuple: """simple docstring""" A_ : Any = """+""".join(query.split() ) A_ : ...
344
"""simple docstring""" import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import c...
320
0
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
126
"""simple docstring""" import socket def SCREAMING_SNAKE_CASE ( ) -> str: _lowerCAmelCase : Optional[int] = socket.socket(socket.AF_INET ,socket.SOCK_STREAM ) _lowerCAmelCase : Optional[int] = socket.gethostname() _lowerCAmelCase : Tuple ...
126
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available UpperCAmelCase__ = {"tokenization_herbert": ["HerbertTokenizer"]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except OptionalD...
339
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 UpperCAmelCase__ = { "tiny.en": "https://openaipublic.azureedge.net/main/whisper/models/d3dd57d32acce...
339
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase : str = logging.get_logger(__name__) __UpperCAmelCase : Tuple = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-b-16x2-kinetics400/reso...
367
import inspect import unittest from transformers import MobileViTConfig 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_configuration_common import ConfigTester from ...t...
293
0
class A : '''simple docstring''' def __init__(self : Any , _UpperCAmelCase : str = "" , _UpperCAmelCase : bool = False ) -> None: """simple docstring""" lowercase__ = {} # A node will ...
305
import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepInverseS...
305
1
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case_ : List[Any] = logging.get_logger(__name__) snake_case_ : Optional[int] = { "vocab_file": "vocab.json", "...
350
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets snake_case_ : Dict = "\\n@inproceedings{snover-etal-2006-study,\n title = \"A Study of Translation Edit Rate with Targeted Human Annotation\",\n author = \"Snover, Matthew and\n Dorr, ...
7
0
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common imp...
56
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simp...
56
1
"""simple docstring""" import os from datetime import datetime as dt from github import Github _A = [ """good first issue""", """feature request""", """wip""", ] def a__ ( ) -> List[str]: UpperCAmelCase__ : Any = Github(os.environ["""GITHUB_TOKEN"""] ...
350
"""simple docstring""" import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase ( lowerCAmelCase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE = (DDIMParallelScheduler,) SCREAMING_SNAKE_CASE = ...
166
0
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from ...
333
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class A_ ( _a ): '''simple docstring''' a__ = (IPNDMScheduler,) a__ = (("num_inference_steps", 50),) def lower...
333
1
'''simple docstring''' import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.au...
368
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBe...
174
0
class __A : """simple docstring""" def __init__( self , lowerCamelCase__ ): """simple docstring""" __UpperCamelCase : str =set_counts __UpperCamelCase : Optional[Any] =max(lowerCam...
71
import itertools import string from collections.abc import Generator, Iterable def A ( _lowercase , _lowercase ): SCREAMING_SNAKE_CASE : Union[str, Any] = iter(_lowercase ) while True: SCREAMING_SNAKE_CASE : Optional[Any] = tup...
182
0
'''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_weight...
311
'''simple docstring''' from __future__ import annotations from random import random class A : def __init__( self , SCREAMING_SNAKE_CASE = None ) -> Tuple: """simple docstring""" A : Optional[Any] = ...
311
1
"""simple docstring""" from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from trans...
291
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Dict = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : List[Any] = { """facebook/en...
31
0
"""simple docstring""" import requests def lowerCamelCase (a_ :str , a_ :str) -> None: lowercase :str = {'''Content-Type''': '''application/json'''} lowercase :Any = requests.post(a_ , json={'''text''': message_body} , headers=a_) ...
172
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase = logging.get_logger(__name__) # TODO: upload to AWS UpperCAmelCase = { '''yjernite/retribert-base-uncased''': ( '''https://huggingface.co/yjernite/retribert-...
172
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig""...
126
"""simple docstring""" import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCAmelCase = get_test...
126
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : List[Any] = logging.get_logger(__name__) a__ : Tuple = { '''Salesforce/blip-vqa-base''': '''https...
195
"""simple docstring""" def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ ): '''simple docstring''' __SCREAMING_SNAKE_CASE = [0 for i in range(r + 1 )] # nc0 = 1 __SCREAMING_SNAKE_CASE = 1 for i in range(1 , n + 1...
195
1
import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) UpperCAmelCase__ : str = logging.getLogger() def lowerCamelCase__ ( ...
121
"""simple docstring""" from __future__ import annotations __A = tuple[int, int, int] __A = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase __A = """ABCDEFGHIJKLMNOPQRSTUVWXYZ""" # -------------------------- default selection -...
293
0
'''simple docstring''' from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCAmelCase__ ( UpperCAmelCase__ ): def __init__...
359
'''simple docstring''' import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_ava...
322
0
"""simple docstring""" def __lowerCamelCase ( a_ : float , a_ : float , a_ : float , a_ : float , a_ : float , ) -> float: __SCREAMING_SNAKE_CASE :Dict = [redshift, radiation_density, matter_density, dark_energy] if any(p < 0 for ...
191
import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _snake_case( SCREAMING_SNAKE...
7
0
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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( BitConfig, ViTHybridCon...
362
import argparse from collections import defaultdict import yaml lowerCAmelCase__ = 'docs/source/en/_toctree.yml' def __lowerCamelCase ( lowerCAmelCase__ ): lowerCAmelCase__ = defaultdict(lowerCAmelCase__ ) for doc in model_doc: counts[doc["loca...
119
0
def _snake_case ( lowerCAmelCase : list ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Dict = len(lowerCAmelCase ) for i in range(1 , lowerCAmelCase ): SCREAMING_SNAKE_CASE_ : int = collection[i] SCREAMING_SNAKE_CASE_ : Any = 0 SCRE...
18
'''simple docstring''' import numpy # List of input, output pairs lowerCamelCase = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) lowerCamelCase = (((515, 22, 13), 555), ((61, 35, 49), 150)) lowerCamelCase = [2, ...
166
0
"""simple docstring""" import random def _lowerCamelCase(__UpperCamelCase ) -> bool: _lowerCAmelCase =num - 1 _lowerCAmelCase =0 while s % 2 == 0: _lowerCAmelCase =s // 2 t += 1 for _ in range(5 ): _lowerCAmelCase =random.randrange(2 , num - 1 )...
341
"""simple docstring""" from __future__ import annotations def _lowerCamelCase(__UpperCamelCase ) -> bool: _lowerCAmelCase =str(__UpperCamelCase ) return n == n[::-1] def _lowerCamelCase(__UpperCamelCase = 1000000 ) -> str: _lowerCAmelCase =0 for i in range(1 ...
341
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase__: Optional[Any] = logging.get_logger(__name__) UpperCamelC...
23
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : Optional[Any] = { """config...
174
0
import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( """kwargs, expected""" , [ ({"""num_shards""": 0, """max_num_jobs""": 1}, []), ({"""num_shards""": 1_0, """max_num_jobs""": 1}, [range(1_...
20
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = { "configuration_blenderbot_small": [ "BLENDERBOT_SMALL_PRETRAINED_CONFIG_...
20
1