code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, ...
222
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : List[Any] = log...
222
1
"""simple docstring""" 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 __lowercase = logging.get_logge...
361
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { """EleutherAI/gpt-neox-20b""": """https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json""", ...
226
0
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets UpperCAmelCase : List[Any] = "\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Translation for Text Simplification},\n auth...
252
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase : Optional[Any] = { "configuration_swiftformer": [ "SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwiftFormerConfig", "SwiftF...
252
1
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin ...
359
from __future__ import annotations _lowerCamelCase = list[list[int]] # assigning initial values to the grid _lowerCamelCase = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0...
177
0
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = int(SCREAMING_SNAKE_CASE ) # Initialize Result lowercase__ = [] # Traverse through all denomination for denomination in reversed(SC...
110
import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCase = logging.get_logger(__name__) de...
110
1
"""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_availabl...
364
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
100
0
'''simple docstring''' from __future__ import annotations a_ : Tuple = list[list[int]] # assigning initial values to the grid a_ : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9,...
55
"""simple docstring""" from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class UpperCamelCase ( yaml.SafeLoader ): def _UpperCAmelCase ( self ,__UpperCamelCase ) -> Optional[int]: '''simple docstring''' ...
213
0
from __future__ import annotations import os from collections.abc import Mapping _SCREAMING_SNAKE_CASE : Any = tuple[int, int] class UpperCAmelCase__ : """simple docstring""" def __init__( self : Dict , __lowerCamelCase : set[int] , __l...
218
from functools import reduce _SCREAMING_SNAKE_CASE : Any = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443...
218
1
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class _a ( _lowerCAmelCase ): ...
147
a : Optional[int] = 9.8_0_6_6_5 def lowerCAmelCase_ (lowerCAmelCase__: float , lowerCAmelCase__: float , lowerCAmelCase__: float = g ): """simple docstring""" if fluid_density <= 0: raise ValueError("""Impossible...
147
1
'''simple docstring''' import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditi...
357
'''simple docstring''' from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. a : Optional[int] = 1_0 def __lowerCamelCase ( _lowercase , _lowercase , ...
338
0
'''simple docstring''' import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_proper...
223
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Optional[Any] ={ '''configuration_nllb_moe''': [ '''NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
223
1
"""simple docstring""" from __future__ import annotations import numpy as np def lowercase__ ( lowercase_ ) -> Any: """simple docstring""" return np.maximum(0 ,lowercase_ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
310
"""simple docstring""" import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_availabl...
310
1
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_remote_code from ...featu...
76
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class lowercase__ ( __lowerCamelCase ): '''simple docstring''' def UpperCamelCase__ ( self, __magic_name__ ) -> Union[str, Any]: ...
201
0
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class lowercase_ : '''simple docstring''' ...
26
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_at...
26
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, FEAT...
111
import math def A__ ( SCREAMING_SNAKE_CASE__) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # All primes number ...
111
1
from __future__ import annotations from collections.abc import Generator def lowerCAmelCase_ (): """simple docstring""" UpperCAmelCase_: Any = {} UpperCAmelCase_: Union[str, Any] = 2 while True: UpperCAmelCase_: ...
352
def lowerCAmelCase_ (lowerCAmelCase__: int , lowerCAmelCase__: float , lowerCAmelCase__: float ): """simple docstring""" return round(float(moles / volume ) * nfactor ) def lowerCAmelCase_ (lowerCAmelCase__: f...
82
0
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class a_ ( snake_case_ ): ...
58
"""simple docstring""" import unittest import numpy as np from transformers import RobertaConfig, 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(): ...
171
0
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) __A : Op...
8
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @requi...
8
1
"""simple docstring""" import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCL...
84
"""simple docstring""" import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration _UpperCAmelCase = 5_0_0_0_0_0 _UpperCAmelCase, _UpperCAmelCase = os.path.split(__file__) _UpperCAmelCase = os.path.join(RESULTS...
173
0
'''simple docstring''' import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_fla...
366
'''simple docstring''' from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class __...
217
0
from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transforme...
51
"""simple docstring""" import copy import os import cva import numpy as np from matplotlib import pyplot as plt class UpperCamelCase_ : def __init__( self : str ) -> Dict: UpperCAmelCase_ : List[Any] = "" UpperCAmelCase_ : int = ""...
268
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a_ : List[Any] = {"""processing_layoutxlm""": ["""...
6
'''simple docstring''' 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_fast import BertTokenizerFast from .tokenization_dpr import D...
6
1
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_tor...
139
'''simple docstring''' import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _snake_case ( _a , unittest.TestCase ): _A : st...
139
1
'''simple docstring''' import argparse import os from accelerate.test_utils import execute_subprocess_async def a__ ( lowercase : Any=None ) -> List[Any]: """simple docstring""" if subparsers is not None: _UpperCamelCase = subparsers.add_parser('''test''' ...
368
'''simple docstring''' from cva import destroyAllWindows, imread, imshow, waitKey def a__ ( lowercase : str ) -> Optional[int]: """simple docstring""" _UpperCamelCase , _UpperCamelCase = img.shape[0], img.shape[1] # converting each pixel's color to its nega...
287
0
'''simple docstring''' def _lowerCAmelCase ( ) -> Tuple: """simple docstring""" _SCREAMING_SNAKE_CASE =[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] _SCREAMING_SNAKE_CASE =6 _SCREAMING_SNAKE_CASE =1 _SCREAMING_SNAKE_CASE =...
47
def __a ( ) -> list[list[int]]: '''simple docstring''' return [list(range(1_0_0_0 - i , -1_0_0_0 - i , -1 ) ) for i in range(1_0_0_0 )] A_ : Union[str, Any] = generate_large_matrix() A_ : Union[str, Any] = ( [[4,...
333
0
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version A_ = { '''<''': operator.lt, '''<=''': operator.le, '''==''': operator.eq, '''!=''': operator.ne, '''>=''': operator...
132
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : int = 10_00 ): """simple docstring""" _snake_case , _snake_case : List[Any] = 1, 1 _snake_case : str = [] for i in range(1 , n + 1 ): _snake_case : Any = prev_num...
132
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.mode...
225
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) def ...
225
1
"""simple docstring""" 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 im...
209
"""simple docstring""" from __future__ import annotations from collections import namedtuple def _snake_case ( lowerCamelCase__ : float , lowerCamelCase__ : float , lowerCamelCase__ : float ) -> tuple: lowerCamelCase_ : Optional[Any] =...
209
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available a_ : Union[str, Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except Optional...
55
'''simple docstring''' import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig __lowercase : Dict = logging.get_logger(__name__) __lowercase : str = ...
318
0
import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import disable_progress_bar, ...
204
def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : Union[str, Any] ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE__ = len(__UpperCamelCase ) for i in range(length - 1 ): SCREAMING_SNAKE_CASE__ = i for k in range(i + 1...
204
1
'''simple docstring''' import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from tra...
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
"""simple docstring""" from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf im...
371
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Dict = logging.get_logger(__name__) __...
233
0
import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import VOCAB_FILES_NAMES, Proph...
214
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { '''google/switch-base-8''': '''https://huggingface.co/google/switch-base-8/blob/main/config.json''', } class SCREAMING_SNAKE_CASE__ (__snake_case )...
214
1
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accel...
182
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase , _UpperCamelCase = None ): if version.parse(hfh.__version__ ).release < version.parse('0.11.0' ).rel...
182
1
from ...configuration_utils import PretrainedConfig class SCREAMING_SNAKE_CASE__ ( lowercase__ ): A_ : List[str] = """bert-generation""" def __init__(self : Optional[int] , a__ : Optional[int]=5_0358 , a__ : Dict=10...
24
"""simple docstring""" from collections import namedtuple _a = namedtuple('from_to', 'from_ to') _a = { 'cubicmeter': from_to(1, 1), 'litre': from_to(0.001, 1_000), 'kilolitre': from_to(1, 1), 'gallon': from_to(0.0_0454, 264.172), 'cubicyard': from_to(0.7_6455, 1....
61
0
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_...
221
from __future__ import annotations UpperCamelCase = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def _A ( lowerCAmelCase_ : list[list[int]] , lowerCAmelCase_ : list[int] , lowerCAmelCase_ : list[i...
221
1
import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : Optional[int] = logging.get_logger(__name__) UpperCAmelCase__ : Tuple = { """facebook/encodec_24khz""": """htt...
245
# Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def __lowercase ( _A , _A , _A ) -> int: SCREAMING_SNAKE_CASE : Optional[Any] = { """en""": """Machine learning is great, isn't it?""", """ru""": """Маши...
245
1
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_availabl...
332
'''simple docstring''' from __future__ import annotations def __magic_name__ ( A ) -> list: if len(A ) == 0: return [] snake_case , snake_case = min(A ), max(A ) snake_case = int(max_value - min_value ) + 1 snake_case = [[] for _ in ra...
332
1
from __future__ import annotations def _snake_case ( lowerCAmelCase : list[list[int]] ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[int] = len(lowerCAmelCase ) # We need to create solution object to save path. SCREAMING_SNAKE_CASE_ : str = [[0 ...
18
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _A = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except Optional...
231
0
def a__ ( UpperCAmelCase : int ) -> bool: UpperCAmelCase : int = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def a__ ( UpperCAmelCase : int = 5_000 ) -> int: UpperCAmelCase : int = [(i * (3 * i - 1)) // 2 for i...
99
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Train...
99
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available __magic_name__ = {"tokenization_herbert": ["HerbertTokenizer"]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvail...
100
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { "huggingface/informer-tourism-monthly": ( "https://huggingface.co/huggin...
100
1
"""simple docstring""" from torch import nn def snake_case ( A__ ): if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(F"""Unsupported activation functi...
356
"""simple docstring""" from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class UpperCamelCase_ : def __init__( self : Optional[Any] , lowerCAmelCase_ : Collection[float] | None = None ) -> ...
253
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCAmelCase ( A_ ): ...
59
'''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
"""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 O...
371
"""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 if TYPE_CHECKING: from trans...
168
0
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def lowerCAmelCase_ ( __A ) -> int: '''simple ...
65
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { 'vocab_file': 'vocab.json', 'tokenizer_config...
65
1
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase , _UpperCAmelCase : Dict = len(__lowerCAmelCase ), len(grid[0] ) if ( min(__lowerCAmelCase , __lowerCAmelCase ) < 0 ...
322
'''simple docstring''' from collections.abc import Sequence def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): return sum(c * (x**i) for i, c in enumerate(__lowerCAmelCase ) ) def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase ...
322
1
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_xlnet...
65
import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def lowerCAmelCase_ ( __A ) -> Dict: '''simple docstring''' UpperCAmelCase__ = [ "encoder.version", "dec...
65
1
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_t...
219
'''simple docstring''' from __future__ import annotations import math def a ( __a ) -> bool: '''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,...
219
1
"""simple docstring""" class A_ : """simple docstring""" def __init__( self :List[str] ): """simple docstring""" lowerCamelCase__ : Tuple ='' lowerCamelCase__ : Dict ='' lowerCa...
126
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import...
126
1
'''simple docstring''' lowerCamelCase__ = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100_000)] def __lowerCAmelCase (__lowerCAmelCase ): _UpperCAmelCase : Optional[Any] = 0 while number: # Increased Speed Slightly by checking every 5 digi...
322
'''simple docstring''' from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor ...
322
1
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def UpperCamelCase_( lowerCamelCase_ ) -> Any: _lowercase : Any = [ 'encoder.version', 'decoder.version', 'model.encoder.versio...
21
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVPro...
101
0
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": lowercase__ =argparse.ArgumentParser() parser.add_argument( '--checkpoint_path', default=None, type=str, required=True, help='Path to t...
90
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration lowercase__ =50000 lowercase__ =5000 lowercase__ , lowercase__ =os.path.split(__file__) lowercase__ =os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENA...
90
1
'''simple docstring''' import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backb...
27
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) _UpperCAmelCase = { """sample_size""": 32, """in_channels""": 3, """out_channels""": 3, """layers_per_block""": 2, """num_cla...
140
0
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _snake_case ( _snake_case , unittest.TestCase ): SCREAMING_SNAKE_CASE__ = CTRLTokenizer SCR...
350
def __lowerCamelCase ( UpperCAmelCase_ : str ): """simple docstring""" if n_term == "": return [] a :list = [] for temp in range(int(UpperCAmelCase_ ) ): series.append(F'''1/{temp + 1}''' if series else '''1''' ...
281
0
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake SCREAMING_SNAKE_CASE_: str =numpy.array([0, 0]) SCREAMING_SNAKE_CASE_: str =numpy.array([0.5, 0.8660254]) SCREAMING_SNAKE_CASE_: Optional[int] ...
1
'''simple docstring''' from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import s...
1
1
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset __UpperCAmelCase = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5...
145
from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusionSchedu...
145
1
"""simple docstring""" import math class __SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : Optional[int], lowerCamelCase : Any=0 )-> Any: # a graph with Node 0,1,...,N-1 lowerCamelCase__ : Optional[Any] =n lowerCamel...
238
import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transformers.testing_utils import r...
270
0
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accel...
145
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) ...
145
1
import random def UpperCamelCase ( _A, _A, _A = False ): """simple docstring""" __magic_name__ : dict = {i: [] for i in range(_A )} # if probability is greater or equal than 1, then generate a complete graph if probability >= 1: ...
342
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
342
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) _SCREAMING_SNAKE_CASE = { "configu...
3
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepa...
3
1
from __future__ import annotations from random import random class _snake_case : def __init__( self , _lowerCamelCase = None ): a :List[Any] = value a :int = random() a :Node | None = None a :Node | None ...
94
import string import numpy def __lowerCamelCase ( UpperCAmelCase_ : int , UpperCAmelCase_ : int ): """simple docstring""" return b if a == 0 else greatest_common_divisor(b % a , UpperCAmelCase_ ) class _snake_case : SCREAMING_SNAKE_CASE__ = ...
94
1
'''simple docstring''' import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import disa...
219
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule __snake_case = {'''tokenization_wav2vec2_phoneme''': ['''Wav2Vec2PhonemeCTCTokenizer''']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys __snak...
219
1
'''simple docstring''' import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def _A (lowerCAmelCase__ :List[Any] , lo...
168
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a_ : Union[str, Any] = { "config...
168
1
from math import ceil def SCREAMING_SNAKE_CASE ( __UpperCamelCase : int = 1001 ) -> int: UpperCAmelCase_ = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): UpperCAmelCase_ = 2 * i + 1 UpperCAmelCase_ = ...
177
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging _lowerCamelCase = logging.get_logger(__...
177
1
from ...processing_utils import ProcessorMixin class __lowerCAmelCase ( SCREAMING_SNAKE_CASE ): _a = """WhisperFeatureExtractor""" _a = """WhisperTokenizer""" def __init__( self , lowerCAmelCase , lowerCAmelCase ) -> Union[str, Any...
205
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common im...
205
1
import argparse import json from tqdm import tqdm def SCREAMING_SNAKE_CASE ( ) -> Tuple: a = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=__UpperCamelCase , default="biencoder-nq-dev.json" , help="Path to raw DPR...
180
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(UpperCamelCase__ ) , """Tato...
180
1
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Distribut...
284
def a_ ( lowerCAmelCase_ : int ): if number < 0: raise ValueError('number must not be negative' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
284
1
"""simple docstring""" from sklearn.metrics import recall_score import datasets __snake_case = ''' Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true positives and FN i...
351
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __snake_case = { '''configuration_resnet''': ['''RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Res...
153
0
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device from...
225
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as or...
225
1
UpperCamelCase_ = '''0.18.2''' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_librosa_available, ...
361
from sklearn.metrics import matthews_corrcoef import datasets UpperCamelCase_ = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes into account true and fa...
59
0
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...test_p...
175
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP a_ = False try: a_ = _is_package_available('goog...
175
1
import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from...
196
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_ut...
196
1
"""simple docstring""" # XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path _a : List[str] = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import dataclasses # ...
44
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a : List[Any] = logging.get_logger(__name__) _a : Any = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swinv2-tiny-patch4-win...
44
1
'''simple docstring''' from math import factorial, pi def _UpperCAmelCase ( _UpperCamelCase : float, _UpperCamelCase : int = 30 ) -> float: if not isinstance(_UpperCamelCase, (int, float) ): raise ValueError('''maclaurin_sin() requires either...
18
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvail...
18
1
import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline SCREAMING_SNAKE_CASE__ : Dict = vers...
48
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(lowerCAmelCase__ ...
48
1
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 import MarianMTModel from transformers.file_utils ...
304
from typing import Any import numpy as np def _lowerCamelCase( lowercase__ ) -> bool: '''simple docstring''' return np.array_equal(lowercase__ , matrix.conjugate().T ) def _lowerCamelCase( lowercase__ , lowercase__ ) -> Any: '''sim...
304
1
class __snake_case : def __init__( self : str , A_ : Dict , A_ : Optional[int]): lowerCAmelCase_ : str = name lowerCAmelCase_ : List[Any] = val def __str__( self : List[str]):...
103
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _a ( __a ): __a : int = ["""image_processor""", """tokenizer"""] __a : Union[str, Any] = """ChineseCLIPImage...
34
0
'''simple docstring''' def _lowerCAmelCase ( _UpperCamelCase : list ) -> list: """simple docstring""" if any(not isinstance(_UpperCamelCase , _UpperCamelCase ) or x < 0 for x in sequence ): raise TypeError('Sequence must be list of non-negative...
350
'''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
0
from __future__ import annotations __UpperCamelCase : List[Any] = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] __UpperCamelCase : List[Any] = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def a_ ( _A ) -> list[float]: ...
307
def a_ ( _A = 1000 ) -> int: """simple docstring""" return sum(e for e in range(3 , _A ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(f'''{solution() = }''')
307
1
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow SCREAMING_SNAKE_CASE_ = False class UpperCamelCase__ ( unittest.TestCase ): ...
361
import json import sys def __lowercase ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Any: '''simple docstring''' with open(_SCREAMING_SNAKE_CASE , encoding="""utf-8""" ) as f: SCREAMING_SNAKE_CASE = json.lo...
193
0
"""simple docstring""" from __future__ import annotations from math import pi def A ( snake_case :float , snake_case :float , snake_case :float ) -> dict[str, float]: if (inductance, frequency, reactance).count(0 ) != 1: raise ValueError('One and only one ...
316
"""simple docstring""" import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings UpperCamelCase : str = lo...
316
1
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __snake_case :Optional[int] = TypeVar('''T''') class _A ( Generic[T] ): def __init__( self : Any , __SCREAMING_SNAKE_CASE : T): '''si...
353
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 from ..image_utils import load_image if is_torch_available(...
131
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { """vinvino02/glpn-kitti""": """https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json""", # See all GLPN models at ht...
68
"""simple docstring""" # Lint as: python3 import itertools import os import re _UpperCAmelCase = re.compile(r"""([A-Z]+)([A-Z][a-z])""") _UpperCAmelCase = re.compile(r"""([a-z\d])([A-Z])""") _UpperCAmelCase = re.compile(r"""(?<!_)_(?!_)""") _UpperCAmelCase = re.compile(r"""(_{2,})""") _...
173
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import RoFormerConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tens...
363
'''simple docstring''' 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_fl...
242
0
"""simple docstring""" def __UpperCAmelCase ( UpperCAmelCase_ : int ) -> bool: '''simple docstring''' __snake_case : Dict = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def __UpperCAmelCase ( UpperCAmelCase_ : int = 50_00 ) ...
172
"""simple docstring""" import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline _a : i...
172
1
import re from filelock import FileLock try: import nltk __snake_case : Dict = True except (ImportError, ModuleNotFoundError): __snake_case : str = False if NLTK_AVAILABLE: with FileLock(""".lock""") as lock: nltk.download("""pun...
353
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __snake_case : Optional[Any] = TypeVar("""KEY""") __snake_case : str = TypeVar("""VAL""") @dataclass(frozen=__lowercase , sl...
122
0
def A ( a_ ) -> list: if n_term == "": return [] __UpperCamelCase : list =[] for temp in range(int(a_ ) ): series.append(F'1/{temp + 1}' if series else '1' ) return series if __name__ == "__main__...
71
def snake_case( __magic_name__ , __magic_name__ ) -> float: '''simple docstring''' return price * (1 + tax_rate) if __name__ == "__main__": print(f'''{price_plus_tax(1_00, 0.2_5) = }''') print(f'''{price_plus_tax(1_2_5.5_0, 0.0_5) = }''')
308
0
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def __lowercase ( ) -> Dict: '''simple docstring''' _A = HfArgumentParser(__lowercase ) _A = parser.parse_args_into_dataclas...
371
'''simple docstring''' lowerCamelCase_ = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' lowerCa...
174
0
def _UpperCAmelCase (UpperCamelCase__ : int = 600851475143 ): try: _A : List[str] = int(UpperCamelCase__ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: ...
11
'''simple docstring''' from __future__ import annotations from typing import Any class snake_case ( __lowerCamelCase ): """simple docstring""" pass class snake_case : """simple docstring""" def __init__( self : List[Any] , __A : ...
53
0
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case_ : List[str] = logging.get_logg...
236
'''simple docstring''' from torch import nn def A__ ( UpperCAmelCase_ ): if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(f...
236
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _snake_case = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LlamaCo...
157
import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available, logging from .be...
157
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = """▁""" Upp...
54
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version UpperCAmelCase = { """<""": operator.lt, """<=""": operator.le, """==""": operator.eq, """!=""": operator.ne, """>=""": operator.ge, """>""":...
54
1
def UpperCAmelCase__ (UpperCamelCase_ ): """simple docstring""" if number > 0: raise ValueError('''input must be a negative integer''' ) snake_case = len(bin(UpperCamelCase_ )[3:] ) snake_case = bin(abs(UpperCamelCase_ ) - (1 <<...
127
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 _SCREAMING_SNAKE_CASE : List[Any] = logging.get_logger(__name__) _SCREAMING_SNA...
127
1
'''simple docstring''' import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class a__ ( a__ ): '''simple docstring''' def __SCREAMING_SNAKE_CASE ( self , lowerCamelCase_ ...
228
'''simple docstring''' from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...imag...
228
1
from __future__ import annotations def lowerCAmelCase_ ( _lowercase : float , _lowercase : float , _lowercase : float , ) -> tuple[str, float]: """simple docstring""" if (stress, tangential_force, area).count(0) != 1: raise Va...
170
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowercase : int =logging.get_logger(__name__) _lowercase : Union[str, Any] ={ "vocab_file": "voc...
170
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase : Any = logging.get_logger(__name__) lowerCAmelCase : List[Any] = { """fac...
369
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer lowerCAmelCase : Any = logging.get_logger(__name__) lower...
127
0
"""simple docstring""" import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() lowercase__ = logging....
241
"""simple docstring""" import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelT...
241
1
from collections.abc import Callable import numpy as np def UpperCAmelCase ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): A : int = int(np.ceil((x_end - xa) / step_size ) ) A : Tupl...
256
def UpperCAmelCase ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): A , A : Optional[Any] = len(_lowerCamelCase ), len(grid[0] ) if ( min(_lowerCamelCase , _lowerCamelCase ) < 0 or row == row_lengt...
256
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils import...
154
'''simple docstring''' def lowercase_ ( lowerCAmelCase__ : int ): """simple docstring""" __UpperCAmelCase : list[list[int]] = [[0 for _ in range(lowerCAmelCase__ )] for _ in range(m + 1 )] for i in range(m + 1 ): __UpperCAmelCa...
254
0
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor _snake_case = logging.get_logger(__name__) class UpperCAmelCase_ ( _lowerCAmelCase): def __init__( self, *__a, **__a): '''simple docstring''' ...
366
from __future__ import annotations from typing import Any class UpperCAmelCase_ : def __init__( self, __a, __a, __a = 0): '''simple docstring''' _lowerCAmelCase , _lowerCAmelCase : int = row, column _...
300
0