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
"""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 __lowerCamelCase = logging.get_logger(__name__...
96
import warnings 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 _Uppe...
367
0
'''simple docstring''' import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPri...
47
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def _a ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ): """simple docstring""" _snake_case : List[Any] = 0 if start < end: ...
47
1
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 Uppe...
487
lowerCamelCase :Optional[Any] = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } def __snake_case ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> list[s...
487
1
'''simple docstring''' import unittest import numpy as np import requests from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
706
'''simple docstring''' from math import log from scipy.constants import Boltzmann, physical_constants _lowercase = 300 # TEMPERATURE (unit = K) def A (__lowerCamelCase :float , __lowerCamelCase :float , __lowerCamelCase :float , ): if donor_conc <= 0: raise V...
162
0
"""simple docstring""" _lowerCAmelCase = """Tobias Carryer""" from time import time class __UpperCamelCase : def __init__( self ,_A ,_A ,_A ,_A=int(time() ) ): # noqa: B008 '''simple docstring''' _lowerCAmelCase :...
259
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_alig...
259
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { '''abeja/gpt-neox-japanese-2.7b''': '''https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json''', } class __snake_case ( UpperCame...
717
from __future__ import annotations from collections.abc import Sequence from typing import Literal def UpperCamelCase ( snake_case__ , snake_case__): lowerCAmelCase_ : Optional[int] = list(snake_case__) lowerCAmelCase_ : Tuple = list(snake_case__) lowerCAmel...
683
0
import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor __SCREAMING_SNAKE_CASE =logging.get_logger(__name__) class __magic_name__ ( A__): '''simple docstring''' def __init__( self: Optional[Any] , ...
234
from __future__ import annotations _lowercase : Optional[int] =1.6021E-19 # units = C def lowerCAmelCase_ ( _lowercase : float , _lowercase : float , _lowercase : float , ) -> tuple[str, float]: """simple docstring""" if (condu...
136
0
"""simple docstring""" import operator as op lowercase = '''scaler.pt''' lowercase = '''pytorch_model''' lowercase = '''random_states''' lowercase = '''optimizer''' lowercase = '''scheduler''' lowercase = '''pytorch_model...
468
"""simple docstring""" def _lowerCAmelCase ( __lowerCamelCase:list , __lowerCamelCase:list ): '''simple docstring''' _validate_point(__lowerCamelCase ) _validate_point(__lowerCamelCase ) if len(__lowerCamelCase ) != len(__lowerCamelCase ): ...
468
1
def __A(lowerCAmelCase , lowerCAmelCase ) -> list: """simple docstring""" _UpperCamelCase = len(lowerCAmelCase ) _UpperCamelCase = [] for i in range(len(lowerCAmelCase ) - pat_len + 1 ): _UpperCamelCase = True for j in range(lowerCAmelCa...
612
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __A(lowerCAmelCase , lowerCAmelCase ) -> np.array: """simple docstring""" _UpperCamelCase = F'{sampling_rate}' _UpperCamelCase = """1""" _UpperCam...
612
1
'''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 _lowerCamelCase ...
710
'''simple docstring''' from __future__ import annotations from typing import Any def a__ ( _SCREAMING_SNAKE_CASE : list ) -> int: """simple docstring""" if not postfix_notation: return 0 UpperCAmelCase_ : Tuple = {"+", "-", "*", "/"} ...
323
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging...
328
'''simple docstring''' from importlib import import_module from .logging import get_logger lowerCamelCase :Dict = get_logger(__name__) class _lowerCAmelCase : def __init__(self , lowercase , lowercase=None ): A_ : Optional[int] = attrs or [] if m...
667
0
'''simple docstring''' UpperCamelCase_ = '''Input must be a string of 8 numbers plus letter''' UpperCamelCase_ = '''TRWAGMYFPDXBNJZSQVHLCKE''' def lowerCamelCase ( UpperCAmelCase__ : List[Any] ) -> bool: '''simple docstring''' if not isinstance(__SCREAMING_...
701
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class _SCREAMING_SNAKE_CASE: A_ : int A_ : int class _SCREAMING_SNAKE_CASE: def __init__( self ...
320
0
from __future__ import annotations class lowerCamelCase: '''simple docstring''' def __init__( self , snake_case_=None ): _A = data _A = None def __repr__( self ): _A = [] ...
27
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCamelCase( un...
27
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass __lowerCamelCase = (3, 9, -11, 0, 7, 5, 1, -1) __lowerCamelCase = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class A__ : lowercase = ...
704
'''simple docstring''' import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_ava...
667
0
from __future__ import annotations def UpperCamelCase ( _a ) -> list[int]: # This function is recursive '''simple docstring''' lowercase_ :Any = len(_a ) # If the array contains only one element, we return it (it's the stop condition o...
257
import math def UpperCamelCase ( _a ) -> bool: '''simple docstring''' lowercase_ :int = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(_a ) def UpperCamelCase ( _a = 1 / 1_2_3...
257
1
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { "BridgeTower/bridgetower-base": "https:/...
712
'''simple docstring''' def _a ( _lowercase : int = 50000000 ): '''simple docstring''' __UpperCAmelCase : List[str] = set() __UpperCAmelCase : Tuple = int((limit - 24) ** (1 / 2) ) __UpperCAmelCase...
266
0
from __future__ import annotations def A ( lowercase__ : int ) -> list[int]: UpperCamelCase__ :Tuple = 2 UpperCamelCase__ :Dict = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(lowercase__ ) if n > 1: factors.append(lowercase__ ) retu...
45
'''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 _SCREAM...
369
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.ut...
506
'''simple docstring''' import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...u...
506
1
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__lowerCamelCase ) class __lowercase ( __lowerCamelCase ...
65
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow ...
383
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Tuple = {'configuration_wavlm': ['WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'WavLMConfig']} try: if not is_torch_available(): raise OptionalDepe...
663
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __A ( unittest.TestCase ): def __A ( self ): _lowerCAmelCa...
663
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a : Optional[Any] = logging.get_logger(__name__) a : List[str] = {} class SCREAMING_SNAKE_CASE__ ( _UpperCamelCase ): __SCREAMING_SNAKE_CASE...
69
'''simple docstring''' import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC _UpperCamelCase : Union[str, Any] =parse(importlib.metadata.version("torch")) def lowerCamelCase_ ( A_ , A_ ...
316
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, I...
705
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict" , [ SplitDict(), SplitDict({"train": SplitInfo(name="train" , num_bytes=1_3_3_7 , num_examples=4_2 , dataset_na...
582
0
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken ...
112
import os import string import sys SCREAMING_SNAKE_CASE__ : int = 1 << 8 SCREAMING_SNAKE_CASE__ : List[str] = { """tab""": ord("""\t"""), """newline""": ord("""\r"""), """esc""": 2_7, """up""": 6_5 + ARROW_KEY_FLAG, """down""": 6_6 + ARROW_KEY_FLA...
112
1
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_fl...
625
"""simple docstring""" import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def snake_case__ ...
625
1
import os def a ( snake_case__: str = "matrix.txt" ): '''simple docstring''' with open(os.path.join(os.path.dirname(_lowerCamelCase ) , _lowerCamelCase ) ) as in_file: lowercase_ = in_file.read() lowercase_ = [[int(_lowerCamelCase )...
97
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase_ : List[str] = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'...
24
0
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _a = logging.get_logger(__name__) _a = {"""vocab_file""": """sentencepiece.model"""} _a = ...
700
from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Dict = logging.get_logger(__name__) _a : Optional[Any] = { """caidas/swin2sr-classicalsr-x2-64""": ( """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json...
111
0
'''simple docstring''' 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 UpperCAmelCase__ : Union[str, Any] = Fals...
48
'''simple docstring''' from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, ...
48
1
from itertools import count def lowerCamelCase__ (_UpperCAmelCase = 50): SCREAMING_SNAKE_CASE = [1] * min_block_length for n in count(_UpperCAmelCase): fill_count_functions.append(1) for block_length in range(_UpperCAmelCase , n + 1): for block_start in ...
444
import unittest from transformers import DebertaVaConfig, 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 ModelTesterMixin, ids_tensor...
444
1
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import Token...
426
import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) # pylint: disable=invalid-name class _A ( _lowerCamelC...
217
0
"""simple docstring""" def __lowerCAmelCase ( __lowerCAmelCase : Tuple , __lowerCAmelCase : Union[str, Any] , __lowerCAmelCase : Union[str, Any] ) -> Union[str, Any]: if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(__lowerCAmelCase , n - ...
239
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PI...
239
1
from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_space_optuna, default_h...
25
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_,snake_case_ ): # Initiali...
307
0
from __future__ import annotations def _SCREAMING_SNAKE_CASE ( snake_case = 4 ) -> list[list[int]]: _UpperCAmelCase = abs(snake_case ) or 4 return [[1 + x + y * row_size for x in range(snake_case )] for y in range(snake_case )] ...
175
def _SCREAMING_SNAKE_CASE ( snake_case , snake_case ) -> bool: _UpperCAmelCase = len(snake_case ) + 1 _UpperCAmelCase = len(snake_case ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # length i o...
175
1
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline UpperCAmelCase = argparse.ArgumentParser('''Stable Diffusion script with intel optimization''', add_help=False) parser.add_argument('''--dpm''', action='''sto...
84
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf_...
495
0
"""simple docstring""" 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 _A : Tuple = logging.get_logger...
721
"""simple docstring""" 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() _A : Optional[Any] = logg...
518
0
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMod...
575
"""simple docstring""" from __future__ import annotations def snake_case__ ( _lowerCamelCase, _lowerCamelCase, _lowerCamelCase, ) ->tuple: """simple docstring""" if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more o...
575
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase = { '''configuration_mega''': ['''MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MegaConfig''', '''MegaOnnxConfig'''], } try: if ...
700
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE = 6008_5147_5143 ): try: lowercase = int(__SCREAMING_SNAKE_CASE ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n must be greater tha...
565
0
import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class lowerCAmelCase_ ( tf.keras.layers.Layer ): def __init__( self , _lower...
66
from collections.abc import Sequence def __UpperCamelCase ( _A , _A = False ): if not arr: return 0 lowerCAmelCase_ = 0 if allow_empty_subarrays else float('''-inf''' ) lowerCAmelCase_ = 0.0 for num in arr: lowerCAmelCase_ ...
431
0
def _SCREAMING_SNAKE_CASE ( __snake_case = 1_0_0_0 ) -> int: _UpperCAmelCase = 2**power _UpperCAmelCase = str(__snake_case ) _UpperCAmelCase = list(__snake_case ) _UpperCAmelCase = 0 for i in list_num: sum_of_num...
708
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 ) , '''Tatoeba d...
402
0
"""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
102
from math import isclose, sqrt def snake_case__ ( UpperCAmelCase : float , UpperCAmelCase : float , UpperCAmelCase : float ): lowerCAmelCase__ :Optional[int] = point_y / 4 / point_x lowerCAmelCase__ :Tuple = 2 * normal_gradient / (1 + norm...
145
0
"""simple docstring""" class _SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__(self , lowerCAmelCase__ ): '''simple docstring''' _UpperCamelCase : List[str] = size _UpperCamelCase : Optional[int] = [0] * size ...
239
"""simple docstring""" import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ....
239
1
# Copyright 2022 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 a...
312
def __UpperCAmelCase( lowercase_ , lowercase_ ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) _lowerCamelCase : int = (boundary[1] - boundary[0]) / steps _lowerCamelCase : Any = boundary[0] _lowerCamelCase : Tuple ...
114
0
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 import ModelT...
650
# Copyright 2022 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 applic...
650
1
def __lowerCAmelCase ( __magic_name__ , __magic_name__ , __magic_name__ ): return round(float(moles / volume ) * nfactor ) def __lowerCAmelCase ( __magic_name__ , __magic_name__ , __magic_name__ ): return round(float((moles * 0.0_821 * temperature) / (volum...
226
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_fnet ...
583
0
from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_co...
414
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMi...
414
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ = { 'configuration_blenderbot_small': [ 'BLENDERBOT_SMALL_P...
14
# Copyright 2022 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...
557
0
'''simple docstring''' import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax imp...
686
'''simple docstring''' import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import Nest...
686
1
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) _snake_case = _symbol_database...
500
def A ( _lowerCamelCase ): '''simple docstring''' if not isinstance(_lowerCamelCase , _lowerCamelCase ): _lowerCAmelCase : Union[str, Any] = F"Input value of [number={number}] must be an integer" raise TypeError(_lowerC...
500
1
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( __UpperCAmelCase = 4000000 ): _lowercase : List[Any] = [0, 1] _lowercase : Dict = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 ...
712
"""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 OptionalDependencyN...
600
0
'''simple docstring''' import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class snake_case ( UpperCamelCase__ ): """simple docstring""" _lowerCamelCase = (PNDMScheduler,) ...
675
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 _snake_case = logging.get_logger(__name__) _snake_case = { "hustvl/yolos-small": "https...
307
0
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class __snake_case ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): @register_to_config def __init__( ...
709
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundfile_availble, is...
604
0
from __future__ import annotations def SCREAMING_SNAKE_CASE ( __UpperCamelCase , __UpperCamelCase = None , __UpperCamelCase = None) -> Any: if start is None: a = 0 if end is None: a = len(__UpperCamelCase) - 1 if start >= end: ...
515
'''simple docstring''' import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME,...
508
0
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common import FlaxModelTes...
721
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Conf...
52
0
'''simple docstring''' from __future__ import annotations lowerCAmelCase__ : str = """#""" class a : """simple docstring""" def __init__( self : str ): '''simple docstring''' snake_case__ : dict = {} ...
347
'''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 ...image_utils import ( ...
347
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class UpperCAmelCase_ ( unittest.TestCase): '''s...
643
import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFormerTokenizer f...
643
1
'''simple docstring''' from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixi...
13
'''simple docstring''' import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_te...
13
1
"""simple docstring""" import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def snake_case ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=1024 ) -> List[Any]: _snake_cas...
404
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCAmelCase ( metaclass=__SCREAMING_SNAKE_CASE ): A__ : Tuple = ['''torch''', '''transformers''', '''onnx'''] def __init__( self : Union[str, Any] ...
404
1
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCamelCase__ :Union[str, Any] = logging.get_logger(__name__) # TODO: upload to AWS UpperCamelCase__ :Union[str, Any] = { """yjernite/retribert-base-uncased""": ( """https...
355
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ :str = logging.get_logger(__name__) UpperCamelCase__ :Optional[int] = { """microsoft/markuplm-base""": """https://huggingface.co/microsoft/markuplm-base/resolve/main/c...
355
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer SCREAMING_SNAKE_CASE__ = logging.get...
393
"""simple docstring""" from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_co...
393
1
def _lowerCamelCase ( a_ : list): lowerCamelCase :Optional[int] = False while is_sorted is False: # Until all the indices are traversed keep looping lowerCamelCase :Union[str, Any] = True for i in range(0 , len(a_) - 1 , 2): # iterating over all eve...
166
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def _lowerCamelCase ( a_ : Optional[int] , a_ : Optional[Any] , a_ : List[st...
166
1
from __future__ import annotations from PIL import Image # Define glider example _SCREAMING_SNAKE_CASE = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, ...
703
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class a ( __lowerCAmelCase ): """simple docstring""" def UpperCAmelCase ( self ) -> List[str]: return [ ...
83
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by...
105
'''simple docstring''' import sys _UpperCAmelCase : Dict = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' '''6...
72
0
import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import ( ...
719
import os from pathlib import Path def A ( ): """simple docstring""" from torch.utils.cpp_extension import load UpperCAmelCase__ :Any = Path(SCREAMING_SNAKE_CASE ).resolve().parent.parent.parent / 'kernels' / 'deformable_detr' UpperCAmelCase__ :Tuple = [ ro...
433
0
import random from typing import Any def __lowercase ( snake_case ): """simple docstring""" for _ in range(len(lowerCAmelCase_ ) ): __magic_name__ :Union[str, Any] = random.randint(0, len(lowerCAmelCase_ ) - 1 ) __magic_name__ :Optional[int] = r...
0
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class lowerCAmelCase__ ( __lowerCamelCase ): """simple docstring""" def _UpperCamelCase ( self ): return [ ...
250
0
from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging a__ ...
702
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a__ = { """configuration_clip""": [ """CLIP_PRETRAINED_...
99
0
"""simple docstring""" from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase_ (a__ ): """simple docstring""" __UpperCamelCase : Dict = ['''image_processor''', '''tokenizer'''] __UpperCamelCase...
223
"""simple docstring""" from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent UpperCAmelCase__ : Optional[Any] = {'UserAgent': UserAgent().random} def lowercase_ ( _snake_case ): SCREAMIN...
223
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class A_ ( unittest.TestCase ): def _UpperCAmelCase ( self...
525
import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_checkpoint SCREAMING_SNA...
525
1
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.b...
246
import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def a_ ( ...
246
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_...
601
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = { """configuration_swinv2""": ["""SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Swinv2Config"""], } try: if not is_torch_available(): r...
601
1
'''simple docstring''' import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class UpperCAmelCase ( ...
310
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance __lowerCamelCase : int = 637_8137.0 __lowerCamelCase : Any = 635_6752.31_4245 __lowerCamelCase : List[Any] = 637_8137 def UpperCA...
310
1
'''simple docstring''' import unittest from transformers import XLMConfig, 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 ...
702
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class UpperCAmelCase__( unittest.TestCase , lowerCamelCase ): '''simple docstring''' def UpperCAmelCase ( self : List[str]) -> Any: """simple docstring"...
642
0
'''simple docstring''' import functools def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ) -> int: # Validation if not isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) or not all(isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) for day in days ): ...
75
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAna...
75
1
import numpy class _a : def __init__( self: int , UpperCamelCase_: numpy.ndarray , UpperCamelCase_: numpy.ndarray ) -> None: """simple docstring""" lowercase__ = input_array # Random initial weight...
429
from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...t...
429
1
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from diffusers.pipe...
106
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses...
516
0
def lowercase ( _a = 2000000 ) -> int: UpperCAmelCase_: List[str] = [0 for i in range(n + 1 )] UpperCAmelCase_: str = 1 UpperCAmelCase_: Union[str, Any] = 1 for i in range(2 ,int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in ...
306
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class UpperCAmelCase__ ( snake_case__ ): snake_case_ = ...
306
1
"""simple docstring""" from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import ...
277
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowercase ( lowerCAmelCase__ ): '''simple docstring''' a : List[Any] = ["image...
502
0
import math from collections.abc import Callable def __lowerCamelCase ( __a : Callable[[float], float] , __a : float , __a : float ) -> str: _lowercase = xa _lowercase = xa while True: if x_n == x_na or function(__a ) == function(__a...
706
from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, id...
594
0
import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging _lowercase : Any =logging.get_logger(__name__) ...
364
"""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
import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def __UpperCAmelCase ( A : str , A : str , A : Optional[int] ) -> Tuple: # Initialise PyTorc...
715
'''simple docstring''' import numpy as np def __UpperCAmelCase ( A : np.ndarray , A : np.ndarray , A : float = 1e-12 , A : int = 1_0_0 , ) -> tuple[float, np.ndarray]: assert np.shape(A )[0] == np.shape(A )[1] # Ensure proper dimensionality. assert np...
216
0
from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { 'microsoft/cvt-13': 'https://huggingface.co/microsoft/cvt-13/resolve/main/config.json', # See all Cvt models at https://huggingface.co/models?filter=cvt } ...
544
def lowerCamelCase ( UpperCamelCase : int = 60_08_51_47_51_43 ) -> int: try: _lowerCamelCase = int(UpperCamelCase ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n...
544
1
class A__ ( lowerCAmelCase__ ): pass class A__ ( lowerCAmelCase__ ): pass class A__ : def __init__( self : Optional[Any] ) -> Tuple: """simple docstring""" __lowercase = [ [], ...
707
from __future__ import annotations import math def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : float , SCREAMING_SNAKE_CASE : int ) -> float: __lowercase = u for i in range(1 , SCREAMING_SNAKE_CASE ): __lowercase = temp * (u - i) ret...
688
0
from collections import namedtuple SCREAMING_SNAKE_CASE = namedtuple('from_to', 'from_ to') SCREAMING_SNAKE_CASE = { 'cubicmeter': from_to(1, 1), 'litre': from_to(0.0_01, 1000), 'kilolitre': from_to(1, 1), 'gallon': from_to(0.0_04_54, 2_64.1_72), 'cubicyard...
485
import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor SCREAMING_SNAKE_CASE = logging.get_logger(__name__) class A_ ( __lowercase ): '''simple docstring''' def __init__( self , *_A ,...
485
1
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch if is_tf_availab...
703
from random import randint, random def lowerCamelCase_ ( lowerCAmelCase: int , lowerCAmelCase: int , lowerCAmelCase: int , lowerCAmelCase: bool = False , lowerCAmelCase: bool = False , lowerCAmelCase: int = 5 , )-> list: _snake_case : Dict ...
669
0
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extractio...
150
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def __UpperCamelCase ...
235
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enable_full_determinism, load_numpy, ...
714
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class lowerCamelCase_ ( lowercase , lowercase ): @register_to_config def __init__( self , *, lowerCamelCase_ = 4 , lowerC...
589
0
'''simple docstring''' import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets UpperCAmelCase_ : Tuple = '''\ @inproceedings{kakwani2020indicnlpsuite, title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained...
24
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_featur...
24
1
from __future__ import annotations def __lowerCamelCase ( lowerCAmelCase__ ,lowerCAmelCase__ ): if b == 0: return (1, 0) ((A__) , (A__)) = extended_euclid(lowerCamelCase_ ,a % b ) A__ = a // b return (y, x - k * y) ...
712
"""simple docstring""" from ...processing_utils import ProcessorMixin class snake_case_ ( _lowerCamelCase ): """simple docstring""" SCREAMING_SNAKE_CASE_: Union[str, Any] = ["""image_processor""", """feature_extractor"""] SCREAMING_...
554
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenizati...
154
def lowerCAmelCase ( ) ->Dict: """simple docstring""" __magic_name__ : Optional[int] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] __magic_name__ : Optional[Any] = 6 __magic_name__ : Dict = 1 ...
154
1
import math def snake_case__ ( UpperCAmelCase : Optional[Any] ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes ...
710
import re def snake_case__ ( UpperCAmelCase : str ): return [char.split() for char in re.split(R"[^ a-z A-Z 0-9 \s]" , str_ )] def snake_case__ ( UpperCAmelCase : str ): lowerCAmelCase__ :List[Any] = split_input(str...
111
0
'''simple docstring''' import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class a ( unittest.TestCase ): """simple docstring""" __lowerCAmelCase = JukeboxTokenizer __lowerCAmelCase = { 'artist': ...
523
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vis...
613
0
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[str] = logging.get_logger(__name__) a : Any = { """RUCAIBox/mvp""": """https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json""", } class...
709
"""simple docstring""" import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...te...
85
0
"""simple docstring""" import os import sys import unittest a : List[str] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, c...
273
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case: Optional[Any] = logging.get_logger(__name__) class _UpperCAmelCase ( lowerCAmelCase__ ): """simple docstring""" a_ = "timm_backbo...
577
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ : Optional[Any] = { """configuration_distilbert""": [ """DISTILBER...
670
import warnings from ..trainer import Trainer from ..utils import logging lowerCamelCase_ : Dict = logging.get_logger(__name__) class _UpperCamelCase ( _A ): '''simple docstring''' def __init__( self : List[str] , snake_case_ : Tuple=None , **sn...
670
1
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping __SCREAMING_SNAKE_CASE = tuple[int, int] class a__ : def __init__( self :Union[str, Any] , _lowerCamelCase :set[int] , _lowerCamelCase :Mapping[EdgeT, int] ...
357
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFo...
357
1
"""simple docstring""" def A_ ( __UpperCamelCase : int ): assert ( isinstance(__UpperCamelCase , __UpperCamelCase ) and number_of_steps > 0 ), f"""number_of_steps needs to be positive integer, your input {number_of_steps}""" if number_of_steps == 1: return 1 l...
396
"""simple docstring""" import os from pathlib import Path def A_ ( ): from torch.utils.cpp_extension import load lowercase = Path(__UpperCamelCase ).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr''' lowercase = [ root / filename for...
396
1
"""simple docstring""" import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def A ( snake_case__ ): '''simple docstring''' if "model" in orig_key: SCREAMING_SNAKE_CASE__ = orig_key.replace("""model.""" , """""...
196
"""simple docstring""" import math import sys def _lowerCAmelCase ( _UpperCamelCase ): """simple docstring""" _lowercase: Any = '''''' try: with open(_UpperCamelCase , '''rb''' ) as binary_file: _lowercase: Dict = binary_file.read() for dat in...
353
0
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_...
69
import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from transformers impo...
69
1
def A ( lowercase__ : int , lowercase__ : float , lowercase__ : float ) -> float: return round(float(moles / volume ) * nfactor ) def A ( lowercase__ : float , lowercase__ : float , lowercase__ : float ) -> float: return round(float((moles * 0.0821 * temperature) / (...
45
import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFormerTokenizer from .tokeniza...
511
0
def A__ ( _a : Optional[Any] , _a : Tuple , _a : List[str]=False ): '''simple docstring''' if isinstance(_a , _a ) and isinstance(_a , _a ): snake_case__ : int =len(set_a.intersection(_a ) ) if alternative_union: snake_case__ : int ...
448
import math from typing import Dict, Iterable, List, Optional, Tuple, 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 from ...image_utils import ( IMAGENET_...
448
1
from __future__ import annotations def __a ( __UpperCAmelCase ): if len(__UpperCAmelCase ) == 0: return [] a__ , a__ = min(__UpperCAmelCase ), max(__UpperCAmelCase ) a__ = int(max_value - min_value ) + 1 a__ = [[] for _ in r...
194
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Union[str, Any] = logging.get_logger(__name__) a_ : Optional[Any] = { 'kakaobrain/align-ba...
194
1
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def _lowerCAmelCase ( _a : str , _a : complex , _a : str = "x" , _a : float = 10**-10 , _a : int = 1 , ) -> complex: lowerCAmelCase_ : Di...
440
from collections.abc import Sequence def _lowerCAmelCase ( _a : Sequence[float] , _a : bool = False ) -> float: if not arr: return 0 lowerCAmelCase_ : List[str] = 0 if allow_empty_subarrays else float("""-inf""" ) lowerCAmelCase_ : ...
440
1