code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
def __UpperCamelCase ( lowercase__ : Optional[int] , lowercase__ : List[Any] , lowercase__ : Optional[Any] ) -> Optional[Any]: '''simple docstring''' if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiati...
600
def __UpperCamelCase ( lowercase__ : int , lowercase__ : int , lowercase__ : int ) -> float: '''simple docstring''' lowerCAmelCase_ : Tuple = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) ...
600
1
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common impo...
714
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCamelCase = { "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config", "M2M100OnnxConfig"], ...
190
0
def A__ ( snake_case_ : Optional[Any] , snake_case_ : Tuple , snake_case_ : Optional[Any] , snake_case_ : Optional[Any] , snake_case_ : int , snake_case_ : List[str] ): if index == r: for j in range(snake_case_ ): print(data[j] ...
64
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ = 4_0_0_0_0_0_0 )-> int: """simple docstring""" UpperCamelCase_ = [0, 1] UpperCamelCase_ = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break ...
628
0
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.confi...
701
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_tran...
377
0
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_commo...
34
'''simple docstring''' import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers impo...
442
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers....
701
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 .tokeni...
45
0
from pathlib import Path import fire def SCREAMING_SNAKE_CASE_ ( _snake_case :str , _snake_case :str , _snake_case :int ) -> int: _A = Path(_snake_case ) _A = Path(_snake_case ) dest_dir.mkdir(exist_ok=_snake_case ) for path in src_dir.iter...
2
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase : Union[str, ...
567
0
'''simple docstring''' def A_ ( ) ->List[Any]: lowercase_ = [] lowercase_ = 1 while len(SCREAMING_SNAKE_CASE_ ) < 1e6: constant.append(str(SCREAMING_SNAKE_CASE_ ) ) i += 1 lowercase_ = """""".join(SCREAMING_SNAKE_CASE_ ) return ( int(constant[0] ) * int...
704
'''simple docstring''' 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, BertEmb...
603
0
'''simple docstring''' def lowerCamelCase__ ( a , a ): if mass < 0: raise ValueError('The mass of a body cannot be negative' ) return 0.5 * mass * abs(a ) * abs(a ) if __name__ == "__main__": import doctest doctest.testmod(verbose=True)
356
'''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 tra...
356
1
def a__ ( __UpperCamelCase ): if not head: return True # split the list to two parts SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = head.next, head while fast and fast.next: SCREAMING_SNAKE_CASE_ = fast.next.next SCREAMING_SNA...
707
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device A : List[str] = False class lowerCamelCase (unittest.TestCase ): ...
356
0
'''simple docstring''' def lowercase__( _UpperCamelCase : list )-> list: """simple docstring""" if len(_UpperCamelCase ) < 2: return collection def circle_sort_util(_UpperCamelCase : list , _UpperCamelCase : int , _UpperCamelCase : int ) -> bool: ...
138
'''simple docstring''' # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def lowercase__( _UpperCamelCase : Optional[Any] , _UpperCamelCase : Dict , _UpperCamelCase : int , _UpperCamelCase : Optional[int] )-> List[Any]: """simple docstring""" _...
138
1
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def _lowerCamelCase( a , a = "cpu" , a = None ): __a = torch.load(a , map_location=a ) for k, v in tqdm(state_dict.items() ): if ...
67
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokeni...
67
1
def UpperCAmelCase__( __UpperCAmelCase : List[Any] , __UpperCAmelCase : int , __UpperCAmelCase : Dict=False ): if isinstance(__UpperCAmelCase , __UpperCAmelCase ) and isinstance(__UpperCAmelCase , __UpperCAmelCase ): __snake_case : ...
576
import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from transformers.utils import lo...
576
1
from typing import Any def UpperCamelCase( lowercase_ ) -> list[Any]: '''simple docstring''' if not input_list: return [] snake_case_ = [input_list.count(lowercase_ ) for value in input_list] snake_case_ = max(lowercase_ ) # Gets the maximum count ...
161
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase_ = { '''configuration_transfo_xl''': ['''TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TransfoXLConfig'''], '''tokenization_transfo_xl''': [''...
161
1
import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
10
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils impo...
118
0
"""simple docstring""" import logging 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_...
190
"""simple docstring""" 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 impor...
190
1
'''simple docstring''' from collections import defaultdict def snake_case__ ( UpperCamelCase ,UpperCamelCase ) -> bool: _UpperCamelCase : str = first_str.lower().strip() _UpperCamelCase : Dict = second_str.lower().strip() # Remove whitespace _UpperC...
683
'''simple docstring''' import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_att...
683
1
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency _UpperCAmelCase : Union[str, Any] = { """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"""...
108
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet impor...
108
1
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __a ( SCREAMING_SNAKE_CASE ) -> List[str]: '''simple...
303
def __a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> Union[str, Any]: '''simple docstring''' __UpperCAmelCase = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def __a ( SC...
303
1
def a__ ( snake_case ): """simple docstring""" if not all(char in '''01''' for char in bin_string ): raise ValueError('''Non-binary value was passed to the function''' ) if not bin_string: raise ValueError('''Empty string was passed to the function''' ) __SC...
131
def a__ ( snake_case , snake_case , snake_case=False ): """simple docstring""" if isinstance(snake_case , snake_case ) and isinstance(snake_case , snake_case ): __SCREAMING_SNAKE_CASE : Dict = len(set_a.intersection(snake_case ) ) ...
131
1
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging UpperCa...
37
"""simple docstring""" def __lowercase ( snake_case_ : list ) ->float: '''simple docstring''' __A : Tuple = 0 while len(snake_case_ ) > 1: __A : List[Any] = 0 # Consider two files with minimum cost to be merged for _ in ran...
177
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { """distilbert-base-uncased"...
717
"""simple docstring""" import unittest from knapsack import knapsack as k class a ( unittest.TestCase ): def lowerCAmelCase_ ( self : List[Any] ): _UpperCAmelCase = 0 _UpperCAmelCase = [0] _UpperCAmelCase = [0] _UpperCAmelCa...
275
0
def _lowerCamelCase ( lowerCamelCase_: int ): '''simple docstring''' A : Any = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def _lowerCamelCase ( lowerCamelCase_: int = 100 ): ...
256
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( snake_case ): lowerCamelCase_ = (CMStochasticIterativeScheduler,) lowerCamelCase_ = 1_0 def _UpperCAmelCase ( ...
256
1
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf __lowerCamelCase :Any = loggi...
717
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __lowerCamelCase :str = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvai...
42
0
'''simple docstring''' from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging _a : List[Any] = logging.get_logger(__name__) def _a (lowe...
56
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo lowerCAmelCase = '\\n@misc{wu2016googles,\n title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yonghui ...
43
0
'''simple docstring''' import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __UpperCamelCase (_SCREAMING_SNAKE_CASE ) -> Dict: lowercase__ = os.path.join(args.tf_mode...
705
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device lowercase_ = False class SCREAMING_SNAKE_CASE (unittes...
45
0
"""simple docstring""" from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "huggingface/autoformer-tourism-monthly": "https://huggingface.co/huggingface...
695
"""simple docstring""" import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class __lowerCAmelCase ( __SCREAMING_SNAKE_CASE , unittest.TestCase ): '''simple ...
695
1
lowerCAmelCase__ = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "huggingface-hu...
1
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"): from nltk import word_tokenize lowerCAmelCase__ = ...
1
1
import comet # From: unbabel-comet import torch import datasets a__ = datasets.logging.get_logger(__name__) a__ = """\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon}, title = {Unbabel's Participation in the WMT20 Metri...
654
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : Optional[int] = logging.get_logger(__name__) lowercase : Union[str, Any] = { """microsoft/un...
116
0
"""simple docstring""" import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging a : str = logging.get_logger(__name__) def _SCREAMING_SNAKE_CASE ( _lowe...
31
"""simple docstring""" import baseaa def _SCREAMING_SNAKE_CASE ( _lowercase : str ) ->bytes: '''simple docstring''' return baseaa.aaaencode(string.encode("utf-8" ) ) def _SCREAMING_SNAKE_CASE ( _lowercase : ...
31
1
'''simple docstring''' from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def UpperCAmelCase_ ( A , A , A = 1 / sqrt(2 ) ): '''simple docstring''' _a : List[Any] = tau * frequency / samplerate _a : Tuple = sin(A ) ...
120
'''simple docstring''' import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def UpperCAmelCase_ ( A ): '''simple docstring''' _a : Dict = args.pruning_method _a : Optional[Any] ...
120
1
'''simple docstring''' __lowerCamelCase : Dict = range(2, 20 + 1) __lowerCamelCase : Optional[Any] = [10**k for k in range(ks[-1] + 1)] __lowerCamelCase : dict[int, dict[int, list[list[int]]]] = {} def __UpperCAmelCase ( __magic...
656
'''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/l...
656
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { "configuration_autoformer": [ "AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "AutoformerConfig", ], ...
469
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 ...
469
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ = { "configuration_poolformer": [ "POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "PoolFormerConfig", "PoolFormerOnnxConfig",...
712
import json from typing import TYPE_CHECKING, 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_blenderbot import Blende...
594
0
'''simple docstring''' import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness UpperCamelCase_ : Dict = '''\ @misc{chen2021evaluating, ...
185
'''simple docstring''' from math import factorial def __a ( _UpperCamelCase: int = 100 ) -> int: """simple docstring""" return sum(map(_UpperCamelCase , str(factorial(_UpperCamelCase ) ) ) ) if __name__ == "__main__": print(solut...
185
1
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class UpperCamelCase ( unittest.TestCase , lowercase_ ): def _UpperCAmelCase ( self ) -> Tuple: '''simple docstring''' lowercase_ ...
721
"""simple docstring""" import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCal...
477
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch ...
20
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 import logging logging.set_verbosity_inf...
658
0
from collections.abc import Callable import numpy as np def A ( snake_case__ : Callable , snake_case__ : float , snake_case__ : float , snake_case__ : float , snake_case__ : float ) -> Union[str, Any]: '''simple docst...
702
from __future__ import annotations UpperCAmelCase__ : Dict = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def A ( snake_case__ : list[list[int]] , snake_case__ : list[int] , snake_case__ : list[in...
676
0
"""simple docstring""" import sys __UpperCamelCase : Any = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''1254069874715852386305071569329096329522...
4
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase_ = { 'configuration_nezha': ['NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NezhaConfig'], } try: if not is_torch_availabl...
173
0
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor __lowercase : Tuple = logging.get_logger(__name__) class _A ( __a ): '''simple docstring''' def __init__( self ,*SCREAMING_SNAKE_CASE_ ,**SCREAMING_SNAKE...
719
def lowercase ( __A : int = 100_0000 ) -> int: '''simple docstring''' snake_case : Union[str, Any] = [i - 1 for i in range(limit + 1 )] for i in range(2 , limit + 1 ): if phi[i] == i - 1: for j in range(2 * i , limit + 1 , ...
315
0
import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available()...
254
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, ...
254
1
import os from typing import Dict, List, Tuple, TypeVar, Union A__ = TypeVar('''T''') A__ = Union[List[T], Tuple[T, ...]] A__ = Union[T, List[T], Dict[str, T]] A__ = Union[str, bytes, os.PathLike]
219
def _lowerCAmelCase ( __lowerCAmelCase ) -> float: """simple docstring""" if edge <= 0 or not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('''Length must be a positive.''' ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) *...
219
1
"""simple docstring""" import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py __UpperCamelCase : Any = '''\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, t...
450
"""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_sim...
450
1
"""simple docstring""" import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_v...
700
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() ...
621
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase__ = { '''configuration_mobilevit''': ['''MOBILEVIT_PRETRAINED_CON...
83
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin a = g...
350
0
'''simple docstring''' from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def __A ( lowerCamelCase_ ): """simple docstring""" return getitem, k def __A ( lowerCamelCase_ , lowerCamelCase_ ): """simple docstring...
706
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva __UpperCAmelCase = """""" __UpperCAmelCase = """""" __UpperCAmelCase = """""" __UpperCAmelCase = 1 # (0 is vertical, 1 is horizontal) def __A ...
79
0
"""simple docstring""" import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_g...
363
"""simple docstring""" import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_ut...
169
0
'''simple docstring''' import re def _snake_case ( A_ : str ): """simple docstring""" a_ : Tuple = re.compile(R"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$""" ) if match := re.search(A_ , A_ ): return match.string == phone return ...
719
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging __snake_case: Tuple = logging.get_logger(__name__) __snake_case: Tuple = { "t5-small": "https://hugg...
460
0
import json import unittest import numpy as np from huggingface_hub import hf_hub_download 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_im...
85
'''simple docstring''' import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_b...
13
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = {"configuration_vit_msn": ["VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMSNConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() ...
716
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_ = { "distilbert-base-uncased": "https://huggingface.co/distilbert-b...
376
0
'''simple docstring''' _UpperCAmelCase : Tuple = [ """DownloadConfig""", """DownloadManager""", """DownloadMode""", """StreamingDownloadManager""", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import...
683
'''simple docstring''' from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class UpperCA...
683
1
'''simple docstring''' from __future__ import annotations lowerCAmelCase_ : Optional[Any] = [] def __A ( UpperCAmelCase ,UpperCAmelCase ,UpperCAmelCase ) -> Any: '''simple docstring''' for i in range(len(lowerCAmelCase_ ) ): ...
707
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import l...
204
0
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...utils import logging ...
37
"""simple docstring""" import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mode...
129
0
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _SCREAMING_SNAKE_CASE (unittest.TestCase ): ...
717
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _SCREAMING_SNAKE_CASE (UpperCamelCase ): def __init__( sel...
447
0
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path _lowerCAmelCase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) _lowerCAmelCase : list[int] = [or...
46
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test...
46
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase_ = { '''configuration_maskformer''': ['''MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MaskFormerConfig'''], '''configura...
721
"""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 transformers_loggin...
635
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
598
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 fro...
598
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class a ( UpperCAmelCase ): _lowercase = ["image_processor", "tokenizer"] _lowercase = "CLIPImageProcessor" _lowercase = ("XLMRobertaTokenize...
703
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import LearnedClassifierFreeSamplin...
467
0
"""simple docstring""" import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging UpperCAmelCase = logging.get_logger(__name__) def lowerCamelCase (a_ :Any , a_ ...
677
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { '''naver-clova-ix/donut-base''': '''https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json''', # ...
677
1
def _lowerCAmelCase ( _lowerCAmelCase = 1_0_0 ): '''simple docstring''' A_ : List[Any] = set() A_ : List[str] = 0 A_ : Dict = n + 1 # maximum limit for a in range(2 ,_lowerCAmelCase ): for b in range(2 ,_lowerCAmelCase ): ...
481
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 logging logging.set_verb...
481
1
"""simple docstring""" import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def a ( __UpperCAmelCase : List[Any] ) -> str: __magic_name__: Union[str, Any] = ...
96
'''simple docstring''' import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_avai...
448
0
'''simple docstring''' __A ='\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https://github.com/huggingface/tra...
113
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def _UpperCamelCase ( UpperCamelCase__ ): # A local function to see if a dot lands in the circle. def is_in_circle(UpperCame...
113
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, is_vision_available, ) lowercase_ : List[Any] = ...
572
"""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_ : List[str] = logging.g...
572
1
'''simple docstring''' import argparse import math import traceback import dateutil.parser as date_parser import requests def lowercase__( __UpperCamelCase: Optional[Any] ): """simple docstring""" SCREAMING_SNAKE_CASE : int = {} ...
508
'''simple docstring''' from __future__ import annotations import math def lowercase__( __UpperCamelCase: int ,__UpperCamelCase: int ,__UpperCamelCase: bool ,__UpperCamelCase: list[int] ,__UpperCamelCase: float ): """simple docstring""" ...
508
1
from math import sqrt def __lowerCamelCase ( __lowerCAmelCase : int ) -> int: __UpperCamelCase : List[Any] = 0 for i in range(1 , int(sqrt(__lowerCAmelCase ) + 1 ) ): if n % i == 0 and i != sqrt(__lowerCAmelCase ): ...
269
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _A ( UpperCAme...
269
1
'''simple docstring''' # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union UpperCAmelCase_ = re.compile(r"^(?P<major>\d+)" r"\.(?P<minor>\d+)" r"\.(?P<patch>\d+)$") @total_ord...
490
'''simple docstring''' import numpy as np import datasets UpperCAmelCase_ = "\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean dis...
490
1
"""simple docstring""" import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers cla...
96
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : Optional[int] = logging.get_logger(__name__) lowercase : Optional[Any] = { """google/pegasus-large""": """https://huggingface.co/...
116
0
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 =logging.get_logger(__name__) __A ={ '''google/vit-base-patch16-224''': '''https://huggin...
713
from itertools import count def lowerCamelCase_ ( lowerCamelCase__ = 5_0 ): lowerCamelCase_ = [1] * min_block_length for n in count(lowerCamelCase__ ): fill_count_functions.append(1 ) for block_length in range(lowerCamelCase__ , n + 1 ): ...
313
0
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTokenizerB...
48
"""simple docstring""" from __future__ import annotations from typing import Any def __snake_case ( UpperCamelCase__ ) -> int: """simple docstring""" if not postfix_notation: return 0 A = {'+', '-', '*', '/'} A = [] for token in pos...
690
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __snake_case : str = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
713
'''simple docstring''' import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor __snake_case : Optional[int] = logging.get_logger(__name__) class lowerCamelCase ( lowercase_ ): '''simple docstring''' def __init__( self : Tuple...
687
0
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar _lowerCamelCase = TypeVar('T') class UpperCamelCase_ ( Generic[T] ): def __init__( self :Optional[int] , __A :T ) -> Dict: """simple docst...
6
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokenizerFast, ) ...
6
1
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_verbosity_info() __SCRE...
149
def snake_case_ ( lowercase__ : list[int] ): '''simple docstring''' _lowerCAmelCase =[] if len(lowercase__ ) == 1: return [nums.copy()] for _ in range(len(lowercase__ ) ): _lowerCAmelCase =nums.pop(0 ) _lowerCAmelCase ...
149
1
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class _lowerCAmelCase ( UpperCAmelCase_ ): '''simple docstring''' a_ : List[str] =(DDPMScheduler,) def UpperCamelCase_ ( self : Dict , **Uppe...
411
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _lowerCAmelCase ( ): import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname from...
622
0
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class snake_case__(_UpperCamelCase ): """simple docstring""" def __init__( self : str , SCREAMING_SNAKE_CASE : Any , SCREAMING_SNAKE_CASE : List[Any] ): ...
81
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils import FrozenDict ...
81
1
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( snake_case__ :Any , snake_case__ :str , sn...
67
def UpperCAmelCase_ ( _A ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = int(_A ) if n_element < 1: SCREAMING_SNAKE_CASE__ = ValueError('''a should be a positive number''' ) raise my_error SCREAMING_SNAKE_CASE__ ...
493
0
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from d...
717
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIG...
382
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase : Dict = { "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config",...
262
'''simple docstring''' import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow __lowerCAmelCase : int = [ os.path.join(os.path.dirname(__file__), dirname) ...
262
1
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def UpperCamelCase_ ( lowerCamelCase : int ) -> bool: """simple docstring""" __magic_name__ : int = int(number**0.5 ) ret...
721
"""simple docstring""" from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { """microsoft/xprophetnet-large-wiki100-cased""": ( """https://huggingface.co/microsoft/xprophetnet-large-wiki100...
147
0
"""simple docstring""" from __future__ import annotations import csv import requests from bsa import BeautifulSoup def __snake_case ( __A = "" ) -> dict[str, float]: lowercase : Dict = url or """https://www.imdb.com/chart/top/?ref_=nv_mv_250""" low...
607
"""simple docstring""" import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCase: Tuple =logging.get_logger(__name__) lowerCAmelCase: int ...
607
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Tuple = logging.get_logger(__name__) _lowerCamelCase : Any = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swinv2-tiny-patch4-wi...
708
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer ...
407
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowerCAmelCase__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvaila...
626
"""simple docstring""" from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _lowerCamelCase ( __a = "isbn/0140328726" ): SCREAMING_SNAKE_CASE_ = olid.strip().strip('''/''' ) # Remove leading/trailing whitespace & slashes if n...
626
1
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __snake_case ( __lowerCamelCase ): '''simple docstring''' lowerCAmelCase__ = ["""image_processor""", """tokenizer"""] lowerCAmelCase__ ...
155
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def A__ ( ) -> Tuple: import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname f...
155
1
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block,...
38
'''simple docstring''' def __lowerCamelCase ( A__ , A__ ) -> bool: """simple docstring""" UpperCamelCase = len(A__ ) UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for e...
430
0
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup _UpperCamelCase : Tuple = [ """kernels/rwkv/wkv_cuda.cu""", """kernels/rwkv/wkv_op.cpp""", """kernels/deformable_detr/ms_deform_attn.h""", """kernels/deformable_detr/cuda/ms...
341
import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( MaxLengthCriteria, MaxNe...
341
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ : Optional[Any] = { 'configuration_megatron_bert': ['MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegatronBertConfig'], } try: if not is_torch_availabl...
105
'''simple docstring''' def _SCREAMING_SNAKE_CASE (A ) -> bool: """simple docstring""" lowercase__ = [int(A ) for i in ip_va_address.split('''.''' ) if i.isdigit()] return len(A ) == 4 and all(0 <= int(A ) <= 254 for octet in octets ) if __name__ == "__mai...
460
0
lowerCamelCase_ : Optional[Any] = range(2, 20 + 1) lowerCamelCase_ : Tuple = [10**k for k in range(ks[-1] + 1)] lowerCamelCase_ : int = {} def lowerCAmelCase( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): __a = s...
716
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from...
246
0
import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem UpperCamelCase__ : List[Any] = importlib.util.find_spec('''s3fs''') is not None if _has_safs: from .safil...
105
from numpy import exp, pi, sqrt def UpperCAmelCase ( a_ , a_ = 0.0 , a_ = 1.0 ) -> int: """simple docstring""" return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__": import doctest doctest.testmod()
55
0
import math def SCREAMING_SNAKE_CASE( __UpperCamelCase ) -> int: if not isinstance(__UpperCamelCase , __UpperCamelCase ): a__ : Tuple = F'Input value of [number={number}] must be an integer' raise TypeError(__UpperCamelCase ) if number < 1: a...
207
from __future__ import annotations def SCREAMING_SNAKE_CASE( __UpperCamelCase ) -> list: if len(__UpperCamelCase ) == 0: return [] a__ , a__ : int = min(__UpperCamelCase ), max(__UpperCamelCase ) a__ : Optional[int] = int(max_value - min_value ...
207
1
'''simple docstring''' from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from .....
245
'''simple docstring''' from typing import List import numpy as np def _A ( snake_case ) -> int: _lowercase : Optional[int] = {key: len(snake_case ) for key, value in gen_kwargs.items() if isinstance(snake_case , snake_case )} if len(set(lists_lengths.values() ) ) ...
245
1
import doctest from collections import deque import numpy as np class __SCREAMING_SNAKE_CASE : def __init__( self ): """simple docstring""" lowerCAmelCase__ = [2, 1, 2, -1] lowerCAmelCase__ = [1, 2, 3, 4] ...
365
import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() __snake_case : str = [ """word_embeddings_laye...
365
1
import cva import numpy as np class snake_case_ : '''simple docstring''' def __init__( self : int , _UpperCamelCase : float , _UpperCamelCase : int ) ->int: if k in (0.04, 0.06): snake_case_ = k ...
39
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer _lowercase = {"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokeniz...
356
0
from math import ceil def lowerCAmelCase_ ( lowercase: int = 1_001 ) -> int: '''simple docstring''' _UpperCamelCase: str = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): _UpperCamelCase: Any = 2 * i + 1 _UpperCamelCase: Any = 2 * i _UpperC...
264
# 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 # # Unless required by applicabl...
264
1
import os def lowerCAmelCase ( UpperCamelCase__ : Optional[Any] ) -> Optional[Any]: """simple docstring""" __SCREAMING_SNAKE_CASE: Any = len(grid[0] ) __SCREAMING_SNAKE_CASE: Any = len(UpperCamelCase__ ) __SCREAMING_SNAK...
202
import pprint import requests lowerCamelCase__ = "https://zenquotes.io/api" def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __A() -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """...
612
0
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, Scheduler...
713
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : str = logging.get_logger(__name__) UpperCAmelCase__ : Dict = { 'microsoft/unispeech-large-1500h...
545
0
from manim import * class _UpperCamelCase ( _lowercase ): '''simple docstring''' def _snake_case ( self : Optional[int] ): '''simple docstring''' __lowerCamelCase : Union[str, Any] = Rectangle(height=0.5 ...
519
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, ...
194
0
import inspect import unittest from transformers import MobileNetVaConfig 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 ConfigT...
550
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase : Union[str, Any] =logging.get_logger(__name__) __lowercase : List[Any] ={ """tanreinama/GPTSAN-2.8B-spout_is_uniform""": ( """https://huggingface.co/tanreinama/GPT...
550
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_available(): ...
92
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __lowercase ( ...
542
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available UpperCamelCase : int = {"""tokenization_herbert""": ["""HerbertTokenizer"""]} try: if not is_tokenizers_available(): raise OptionalD...
707
'''simple docstring''' import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration...
610
0
"""simple docstring""" def __lowerCamelCase ( UpperCamelCase__ ): # noqa: E741 """simple docstring""" _UpperCAmelCase = len(lowerCAmelCase__ ) _UpperCAmelCase = 0 _UpperCAmelCase = [0] * n _UpperCAmelCase = [False] * n _UpperCAmelCase = [False] * n def dfs(UpperCamel...
657
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'studio-ousia/luke-base': 'https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json', 'stud...
99
0
import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": lowercase : str = argparse.ArgumentParser( description=( '''Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for Transfer ...
714
import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # 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 : Tuple = '''.''' # Internal TensorFlow ops th...
114
0