code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' import math import os import sys def __magic_name__( lowerCamelCase): __lowerCAmelCase = '''''' try: with open(lowerCamelCase, '''rb''') as binary_file: __lowerCAmelCase = binary_file.read() for d...
174
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCAmelCase : Dict = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """Mvp...
174
1
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta import RobertaTokenizer U...
198
import argparse import struct import unittest class UpperCamelCase : def __init__( self , UpperCAmelCase__ ): A__ = data # Initialize hash values A__ = [ 0x6A_09E_667, 0xBB_67A_E85, 0x3C_6EF_372, 0xA...
198
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) A : Optional[Any] = { 'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvBertConfig', 'ConvBertOn...
6
from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE_ ( __lowerCAmelCase ): pass class SCREAMING_SNAKE_CASE_ : def __init__( self : List[Any] , lowerCamelCase_ : Any ): """simple docstring""" UpperCamelCase = d...
343
0
"""simple docstring""" import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( A...
85
"""simple docstring""" import os from pathlib import Path def lowerCAmelCase (): """simple docstring""" from torch.utils.cpp_extension import load __UpperCamelCase =Path(__UpperCamelCase ).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr''' __Uppe...
85
1
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 Config...
76
from math import factorial def lowerCamelCase__ ( _a , _a , _a): if successes > trials: raise ValueError("successes must be lower or equal to trials") if trials < 0 or successes < 0: raise ValueError("the function is defined for non-negative integers") if not isinstance(_a , ...
76
1
"""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.utils import floats_tensor, ...
352
"""simple docstring""" def snake_case__ ( __lowerCamelCase : int ): """simple docstring""" lowerCamelCase__ : List[Any] =[0] * len(__lowerCamelCase ) lowerCamelCase__ : List[Any] =[] lowerCamelCase__ : List[Any] =[1] * len(__lowerCamelCase ) ...
272
0
from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy _lowerCamelCase =logging.get_logger(__name__) class A__ (...
287
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, cached_file, get_file...
68
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, res...
326
"""simple docstring""" class _a : """simple docstring""" def __init__( self : Tuple , __UpperCamelCase : list[int] )->None: _UpperCAmelCase = len(__UpperCamelCase ) _UpperCAmelCase = [0] * len_array ...
326
1
'''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 TFModelT...
37
def __snake_case ( _lowerCAmelCase : List[str] , _lowerCAmelCase : int ) -> str: return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def __snake_case ( _lowerCAmelCase : int , _lowerCAmelCase : Union[str, Any]=0 ) -> ...
300
0
from __future__ import annotations def __UpperCamelCase ( lowercase__ : list[int] , lowercase__ : int ) -> bool: '''simple docstring''' if len(lowercase__ ) == 0: return False lowerCAmelCase_ : Optional[Any] = len(lowercase__ ...
371
from decimal import Decimal, getcontext from math import ceil, factorial def __UpperCamelCase ( lowercase__ : int ) -> str: '''simple docstring''' if not isinstance(lowercase__ , lowercase__ ): raise TypeError("""Undefined for non-integers""" ) eli...
28
0
import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute_subprocess_async, get_g...
282
class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self : List[str] , lowercase : list[int] ): '''simple docstring''' _snake_case = len(lowercase ) _snake_case = [0] * len_array if len_array > 0: _snake_case = array[0] for i in range...
282
1
"""simple docstring""" import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common...
357
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from s...
1
0
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class __lowerCAmelCase ( tf.keras.optimizers.schedules.LearningRateSchedule ...
339
UpperCAmelCase__ = {} def A ( _UpperCAmelCase : int , _UpperCAmelCase : int , _UpperCAmelCase : int ) -> int: '''simple docstring''' # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late ...
339
1
"""simple docstring""" import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_commo...
350
"""simple docstring""" import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state impo...
149
0
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_token...
347
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_token...
347
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class SCREAMING_SNAKE_CASE__ ( lowercase__ ): snake_case__ : Any = ['''image_processor''', '''tokenizer'''] snake_case__ : Optional[Any] ...
120
from string import ascii_uppercase UpperCAmelCase_ : Dict = {char: i for i, char in enumerate(ascii_uppercase)} UpperCAmelCase_ : Optional[int] = dict(enumerate(ascii_uppercase)) def SCREAMING_SNAKE_CASE_ ( __A : str , __A : str ) -> str: ...
120
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusion...
39
from __future__ import annotations def _lowerCamelCase( lowercase__ , lowercase__ ) -> Any: '''simple docstring''' if len(lowercase__ ) <= 1 or n <= 1: return insert_next(lowercase__ , n - 1 ) rec_insertion_sort(lowercase__ , n - 1 ) def _lowerCamelCase( lo...
295
0
def lowerCAmelCase_ ( UpperCamelCase_ , UpperCamelCase_ ) -> List[Any]: UpperCamelCase_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def lowerCAmelCase_ ( Up...
364
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _UpperCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ ): @register_to_config def __init__( self: List[str] , *, _SC...
328
0
from __future__ import annotations import requests UpperCAmelCase = set( '''approved_at_utc approved_by author_flair_background_color author_flair_css_class author_flair_richtext author_flair_template_id author_fullname author_premium can_mod_post category clicked content_categories created_utc downs edite...
195
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): if not isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): raise TypeError('Input value must be an \'int\' type' ) lowercase = 0 while number: position += 1 number >>= 1 return position if __name__ ==...
195
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, BertTokenize...
353
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class __A( a ): ...
33
0
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar lowerCAmelCase = TypeVar("""T""") class A_ ( Generic[T] ): """simple docstring""" def __init__( self :List[str] ...
126
def _SCREAMING_SNAKE_CASE ( lowercase : float , lowercase : list[float] ): '''simple docstring''' if discount_rate < 0: raise ValueError('Discount rate cannot be negative' ) if not cash_flows: raise ValueError('Cash ...
204
0
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils impor...
248
"""simple docstring""" def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(lowerCAmelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": _...
248
1
import math from datetime import datetime, timedelta def __A ( __lowerCamelCase ) -> datetime: a = year % 19 a = year % 4 a = year % 7 a = math.floor(year / 100 ) a = math.floor((13 + 8 * leap_...
228
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __A ( ) -> Any: a = ArgumentParser( description=( """PyTorch TPU distributed training ...
228
1
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def __lowerCamelCase ( __a :Dict , __a :Tuple=None ) -> Optional[Any]: """simple docstrin...
350
import math def __lowerCamelCase ( ) -> None: """simple docstring""" A__ = input("""Enter message: """ ) A__ = int(input(F'Enter key [2-{len(__a ) - 1}]: ' ) ) A__ = input("""Encryption/Decryption [e/d]: """ ...
276
0
def _A ( _lowercase ) -> str: """simple docstring""" __UpperCamelCase = 0 # if input_string is "aba" than new_input_string become "a|b|a" __UpperCamelCase = '''''' __UpperCamelCase = '''''' # append each cha...
310
'''simple docstring''' def __UpperCAmelCase ( A : int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('''The given input must be positive''' ) # get the generated string sequence UpperCAmelCase_ : int = gr...
304
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { "microsoft/biogpt": "https://huggingface.co/microsoft/biogpt/resolve/main/config.json", # See all BioGPT models ...
360
"""simple docstring""" import string from math import logaa def __UpperCAmelCase ( lowercase ,lowercase ): """simple docstring""" _UpperCAmelCase = document.translate( str.maketrans("""""" ,"""""" ,string.punctuation ) ).replace("""\n""" ,"""""" ) ...
30
0
'''simple docstring''' def UpperCamelCase_ ( snake_case_ : int ) -> int: '''simple docstring''' if not isinstance(snake_case_ , snake_case_ ): __lowerCAmelCase = f"""Input value of [number={number}] must be an integer""" raise T...
229
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class _lowercase ( datasets.BuilderConfig ): '''simple docstring...
229
1
"""simple docstring""" __A = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio from .features import ArrayaD, Arraya...
353
"""simple docstring""" import collections import importlib.util import os import re from pathlib import Path __A = "src/transformers" # Matches is_xxx_available() __A = re.compile(r"is\_([a-z_]*)_available()") # Catches a one-line _import_struct = {xxx} __A ...
108
0
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_process...
156
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel __lowerCAmelCase : str = False __lowerCAmelCase : List[str] = True __lowerCAmelCase : Union[str, Any] = False ...
156
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A : Tuple = logging.get_logger(__name__) A : Any = { "edbeeching/decision-transformer-gym-hopper-medium": ( "https://huggingface.co/edbeeching/decision-transformer-gym-hopper-mediu...
305
from ....utils import logging A : List[str] = logging.get_logger(__name__) class lowerCamelCase (SCREAMING_SNAKE_CASE__ ): """simple docstring""" def __init__( self : List[str] , __magic_name__ : Optional[Any] , __magic_name__ : Any=None ...
305
1
"""simple docstring""" from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function a_ = 1.0_5_4_5_7_1_8_1_7e-3_4 # unit of ℏ : J * s a_ = 3e8 # unit of c : m * s^-1 def __lowercase ( snake_case_ ...
179
"""simple docstring""" def __lowercase ( snake_case_ : int ,snake_case_ : list ) ->Any: '''simple docstring''' _enforce_args(snake_case_ ,snake_case_ ) if n == 0: return 0 __A : int = float('''-inf''' ) for i in range(1 ...
179
1
"""simple docstring""" import argparse import datetime def _snake_case ( lowercase__ ): _lowerCamelCase : Dict = { '0': 'Sunday', '1': 'Monday', '2': 'Tuesday', '3': 'Wednesday', '4': 'Thursday', ...
365
"""simple docstring""" import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import A...
12
0
from ... import PretrainedConfig _lowercase: str = { "sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json", } class _lowercase ( lowerCAmelCase ): """simple docstring""" __A = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP __A = ...
227
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 PIL import Image from ..image_utils impor...
227
1
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller _UpperCAmelCase = 3 def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int ) -> List[Any]: print("""Generating primitive root of p""" ) while True: __lowerCAmelCa...
351
import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation _UpperC...
232
0
"""simple docstring""" 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 fr...
106
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE ( metaclass=a_ ): """simple docstring""" lowercase__ = ["speech"] def __init__( self : Tuple ,*lowercase_ : Tuple ,**lowercase_ ...
106
1
'''simple docstring''' import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _a : str = object() # For specifying empty leaf dict `{}` _a : List[str] = object() def ...
354
'''simple docstring''' import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxrun...
46
0
'''simple docstring''' from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def UpperCamelCase( ): UpperCAmelCase , UpperCAmelCase : Tuple = 9, 14 # noqa: F841 UpperCAmelCase : Dict = [ [0, ...
151
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowercase__ = {"processing_layoutxlm": ["Layou...
151
1
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics f...
367
'''simple docstring''' import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device ...
83
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_se...
333
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
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
159
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def _UpperCAmelCase (UpperCamelCase_ : str , UpperCamelCase_ : Tuple=None ): '''simple docstring''' _lowerCAmelCase : List[Any] ...
159
1
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 FlaxMod...
87
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCamelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pa...
87
1
def __lowercase ( lowerCamelCase : int ): if not isinstance(lowerCamelCase , lowerCamelCase ): raise TypeError('only integers accepted as input' ) else: UpperCamelCase_ : Any = str(abs(lowerCamelCase ) ) UpperCamelCase_ : Any = [list(lowerCamelCase ) ...
365
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _lowercase ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self : List[str] ) -> Optional[Any]: """simple docstring"...
50
0
"""simple docstring""" from math import isqrt, loga def _snake_case ( UpperCamelCase : int ): UpperCAmelCase : Any = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , UpperCamelCase , UpperCamelCase ...
109
"""simple docstring""" from __future__ import annotations class SCREAMING_SNAKE_CASE__ : def __init__( self , _SCREAMING_SNAKE_CASE ) -> None: '''simple docstring''' UpperCAmelCase : Any = data UpperCAmelCase : Node | None = None UpperCAmelCase : ...
109
1
"""simple docstring""" import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer _snake_case = logging.getLogger(__name__) def lowerCAmelCase__ ( ): '''simple docstring''' _a : in...
324
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( Channe...
324
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 _A ( __magic_name...
253
import os from typing import Dict, List, Tuple, TypeVar, Union lowerCAmelCase : str = TypeVar('T') lowerCAmelCase : Optional[Any] = Union[List[T], Tuple[T, ...]] lowerCAmelCase : str = Union[T, List[T], Dict[str, T]] lowerCAmelCase : Union[str, Any] = Uni...
253
1
'''simple docstring''' import re def _UpperCAmelCase ( _UpperCamelCase : str ) -> bool: A_ = re.compile( R'''^(?:0|94|\+94|0{2}94)''' R'''7(0|1|2|4|5|6|7|8)''' R'''(-| |)''' R'''\d{7}$''' ) return bool(re.search(_UpperCamelCase, _UpperC...
18
'''simple docstring''' from statistics import mean, stdev def _UpperCAmelCase ( _UpperCamelCase : list, _UpperCamelCase : int = 3 ) -> list: A_ = min(_UpperCamelCase ) A_ = max(_UpperCamelCase ) # normalize data ...
18
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class A_ ( metaclass=SCREAMING_SNAKE_CASE_ ): """simple docstring""" __UpperCamelCase = ["""torch"""] def __init__( self :Any , *lowercase_ :List[...
78
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...sch...
78
1
"""simple docstring""" import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelin...
79
"""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 a : List[str] = logging.get_logger(__name__) a ...
79
1
"""simple docstring""" import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets _a = datasets.logging.get_logger(__name__) _a = '\\n@InProceedings{moosavi2019minimum,\n a...
61
"""simple docstring""" import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) fr...
61
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _snake_case = { '''configuration_convnext''': ['''CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ConvNextConfig''...
342
import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision, slow, torch_devic...
342
1
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class lowercase__( unittest.TestCase ): """simple docstring""" def _l...
30
import logging from transformers.configuration_utils import PretrainedConfig __a = logging.getLogger(__name__) class lowercase__( UpperCAmelCase ): """simple docstring""" a :Optional[int] = 'masked_bert' def __init__( self : Optional[int] , ...
30
1
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, tor...
190
'''simple docstring''' from math import pi, sqrt, tan def _lowerCAmelCase ( __snake_case : float ) -> float: if side_length < 0: raise ValueError('surface_area_cube() only accepts non-negative values' ) return 6 * side_length**2 ...
190
1
"""simple docstring""" import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration A : Dict = { "tiny.en": "https://openaipublic.azureedge.net/main/whispe...
57
"""simple docstring""" import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A : str = logging.get_logger(__name__) class _UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''...
57
1
_UpperCAmelCase : List[Any] = 8.3144598 def A ( lowercase , lowercase ) -> float: '''simple docstring''' if temperature < 0: raise Exception('Temperature cannot be less than 0 K' ) if molar_mass <= 0: raise Exception('Molar mass cannot be less than or equal to 0 kg/mol'...
110
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline _UpperCAmelCase : Optional[Any] = { "n_samples": 64, "horizon": 32, "num_inference_steps": 20, "n_guide_steps": 2, # can set to 0 for faster sampling, does not use value network "sc...
110
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A_ : List[Any] = {"""configuration_yolos""": ["""YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """YolosConfig""", """YolosOnnxConfig"""]} ...
215
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : Any = logging.get_logger(__name__) A_ : Any = { """microsoft/markuplm-base""": """https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json""", """micro...
215
1
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def lowerCamelCase_ ( _a ): """simple docstring""" ...
366
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { '''facebook/dpr-ctx_encoder-single-nq-base''': ( '''https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/main/confi...
211
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch ...
328
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 accelerate import Accelerator, Dist...
328
1
'''simple docstring''' import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def __UpperCAmelCase ( a_: str, a_: Tuple, a_: Optional[Any], a_: Optional[int], a_: int ): # load base model _UpperCAmelCase : Optio...
17
'''simple docstring''' from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'huggingface/time-series-transformer-tourism-monthly': ( 'https://huggingface.co/huggingface...
17
1
from __future__ import annotations import math from collections.abc import Callable def lowerCamelCase__ ( snake_case_ : Callable[[int | float], int | float] , snake_case_ : int | float , snake_case_ : int | float , snake_case_ : int = 100 ...
24
import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_...
24
1
"""simple docstring""" import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class UpperCamelCase_ ( nn.Module ): _A : int _A : int _A : float ...
248
"""simple docstring""" from __future__ import annotations import numpy as np def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' return np.maximum(0 , lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
248
1
def lowerCAmelCase__(__snake_case ) -> str: '''simple docstring''' lowerCamelCase__ = False while is_sorted is False: # Until all the indices are traversed keep looping lowerCamelCase__ = True for i in range(0 ,len(lowercase__ ) - 1 ,2 ):...
209
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __A = logging.get_logger(__name__) __A = { "facebook/convnextv2-tiny-1k-224": "https://...
164
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase : Tuple = {'''configuration_speech_encoder_decoder''': ['''SpeechEncoderDecoderConfig''']} try: if not is_torch_available(): raise OptionalDepende...
361
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logg...
306
0
"""simple docstring""" class __snake_case : """simple docstring""" def __init__( self , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): '''simple docstring''' __A : str = name __A : List[Any] = val...
179
"""simple docstring""" import logging from transformers.configuration_utils import PretrainedConfig a_ = logging.getLogger(__name__) class __snake_case ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" _lowerCamelCase = """masked_bert""" def __init__( self , ...
179
1
'''simple docstring''' 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...
270
'''simple docstring''' from __future__ import annotations import typing from collections import Counter def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE ): _snake_case = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(_SCREAMI...
270
1
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers,...
171
"""simple docstring""" import os import numpy import onnx def UpperCamelCase__ ( lowercase__ : List[str] , lowercase__ : Optional[int] ): snake_case : Any = a.name snake_case : Any = b.name snake_case : str = "" snake_...
148
0
'''simple docstring''' import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _snake_case (__S...
67
'''simple docstring''' from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder _lowerCamelCase = datasets.utils.logging.get_logger(__name__) class _snake_case (folder_based_builder.FolderBasedBui...
67
1
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example A__ : Dict = [ [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, ...
185
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase_ : List[Any] ) -> str: __lowerCamelCase : Tuple = 0 __lowerCamelCase : Optional[int] = len(UpperCAmelCase_ ) for i in range(n - 1 ): for j in range(i + 1 , UpperCA...
185
1
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeatu...
371
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case : Union[str, Any] = logging.get_logger(__name__) snake_case : List[str] ...
281
0
"""simple docstring""" 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_...
301
"""simple docstring""" import math def lowercase (_lowerCAmelCase ): 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 ...
301
1
import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase): SCREAMING_SNAKE_CASE = AutoConfig.from_pretrained(_UpperCAmelCase) SCREAMING_SNAKE_CA...
327
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def lowerCamelCase__ (_UpperCAmelCase): monkeypatch.setattr('datasets.utils.deprecation_utils._emitted_deprecation_warnings' , set()) @pytest.fixture def lowerCamelCase__ (_UpperCAmelCa...
327
1
SCREAMING_SNAKE_CASE_ = 8.314_4598 def __lowercase ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Optional[int]: '''simple docstring''' if temperature < 0: raise Exception("""Temperature cannot be less than 0 K""" ) if mol...
296
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Any = { 'configuration_altclip': [ 'ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', '...
167
0
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def UpperCAmelCase ( _lowerCamelCase = 3 ): if isinstance(_lowerCamelCase , _lowerCamelCase ): raise TypeError("number of qubits must be ...
256
from math import factorial def UpperCAmelCase ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): if successes > trials: raise ValueError("successes must be lower or equal to trials" ) if trials < 0 or successes < 0: raise ValueError("the function is...
256
1
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> List[Any]: SCREAMING_SNAKE_CASE__ : Tuple ...
132
'''simple docstring''' SCREAMING_SNAKE_CASE__ = 8.31_44_62 # Unit - J mol-1 K-1 def lowercase__ ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase )-> float: if moles < 0 or kelvin < 0 or volume < 0: raise ValueError("""Invalid in...
321
0
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE ) ->int: """simple docstring""" lowerCAmelCase__ :list[list[int]] = [[0 for _ in range(_SCREAMING_SNAKE_CASE )] for _ in range(m + 1 )] for i in range(m + 1 ): lowerCAmelCase__ :str ...
363
"""simple docstring""" import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax i...
254
0
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 lowercase__ :List[Any] = get_tests_dir("fixtures/tes...
101
"""simple docstring""" import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _UpperCAmelCase ( U...
286
0
"""simple docstring""" import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py SCREAMING_SNAKE_CASE : str = '''src/transfor...
317
"""simple docstring""" from __future__ import annotations class __lowerCamelCase : def __init__(self , lowerCamelCase , lowerCamelCase ): '''simple docstring''' _lowerCAmelCase , _lowerCAmelCase = text, pattern _lowerCAmelCase , _low...
317
1
from math import factorial def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : float ): """simple docstring""" if successes > trials: raise ValueError("""successes must be lower or equal to trials""" ) if...
302
import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging logging.set_verbosity_info()...
302
1
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import ...
351
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def __UpperCamelCase ( ) -> Tuple: """simple docstring""" A , A : Tuple = 9, 14 # noqa: F841 A : Optional[int] = [ [0, ...
115
0
"""simple docstring""" import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing impor...
84
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { 'face...
84
1
'''simple docstring''' from __future__ import annotations class a__ : """simple docstring""" def __init__(self , __lowercase ): __lowerCAmelCase = TypeError( '''Matrices must be formed from a list of zero or more lists cont...
356
'''simple docstring''' 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 ): ...
9
0
"""simple docstring""" from __future__ import annotations def _snake_case ( lowercase__ ): _lowerCamelCase : str = str(lowercase__ ) return n == n[::-1] def _snake_case ( lowercase__ = 1000000 ): _lowerCamelCase :...
96
from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """huggingface/autoformer-tourism-monthly""": """https://huggingface.co/huggingface/autoformer-tourism-monthly/r...
302
0
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( """The `inpainting.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionInpaintPipeline` instead.""" )
169
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vision_availab...
169
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( ...
200
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse("""3.8"""): import importlib_metadata else: import importlib.metadata as importlib_metadata lowercase : Tup...
99
0
"""simple docstring""" from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline __lowerCamelCase = logging.get_logger(__nam...
154
"""simple docstring""" import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNe...
154
1
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO ) lowe...
130
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__(_UpperCamelCase , _UpperCamelCase ): """simple docstring""" @register_to_config ...
130
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __snake_case = { 'configuration_bridgetower': [ 'BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BridgeT...
369
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case : List[str] = { 'configuration_timesformer': ['TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimesformerConfig'], }...
58
0
import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_logging sys.path.append(os....
12
"""simple docstring""" from __future__ import annotations def lowercase (snake_case__ : list[int] ) -> list[int]: # This function is recursive '''simple docstring''' lowerCAmelCase = len(snake_case__ ) # If the array contains only...
155
0
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format='''%(message)s''') def __UpperCAmelCase ( __a : np.ndarray ) -> np.ndarray: """simple docstring""" return input_array.reshape(...
15
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_uti...
15
1
"""simple docstring""" class UpperCAmelCase_ : def __init__( self ) -> List[str]: lowercase__ : Optional[int] = 0 lowercase__ : int = 0 lowercase__ : List[Any] = {} def _UpperCAmelCase ( self , a ...
77
"""simple docstring""" import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingSt...
77
1
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 snake_case__ ( tf.keras.layers.Layer ): def __init__( self , lo...
138
import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation __magic_na...
138
1
import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def a ( _UpperCAmelCase : Any ): '''simple docstring''' if ( (cp >= 0x4E00 and cp <= 0x9FFF) or (cp >= 0x3400 and ...
226
import qiskit def a ( _UpperCAmelCase : int , _UpperCAmelCase : int ): '''simple docstring''' __UpperCAmelCase : List[str] = qiskit.Aer.get_backend('''aer_simulator''' ) __UpperCAmelCase : Optional[A...
226
1
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, AutoTokeniz...
369
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : Dict = logging.get_logger(__name__) lowerCamelCase__ : Any = { 'facebook/s2t-small-librispeech-asr': ( 'https://huggingface.co/facebook/s2t-small-librispeec...
210
0
'''simple docstring''' import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fssp...
55
'''simple docstring''' from __future__ import annotations def __snake_case ( UpperCAmelCase_ : int ): lowerCamelCase_ = 2 lowerCamelCase_ = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(UpperCAmelCase_ ) if n > 1: fac...
55
1
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 A_ : lowerCAmelCase__ = 42 lowerCAmelCase__ = None # Aut...
350
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ : Tuple = logging.get_logger(__name__) snake_case__ : int = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.j...
250
0
'''simple docstring''' from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Union[str, Any] = logging.get_logger(__name__) lowerCamelCase : Tuple = { "huggingface/autoformer-tourism-monthly": "https://hu...
47
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo UpperCAmelCase__ = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yonghui Wu and...
339
0
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def snake_case_ ( lowerCAmelCase_ : Dict ): __lowercase : Any = ...
306
from __future__ import annotations def snake_case_ ( lowerCAmelCase_ : str , lowerCAmelCase_ : str ): __lowercase : Any = get_failure_array(lowerCAmelCase_ ) # 2) Step through text searching for pattern __lowercase , __lowercase : Op...
306
1
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 im...
127
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils...
128
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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, O...
352
def lowerCamelCase_ ( _UpperCamelCase ) -> str: """simple docstring""" if number > 0: raise ValueError('''input must be a negative integer''' ) snake_case_ : List[str] = len(bin(_UpperCamelCase )[3:] ) snake_case_ : str ...
279
0
def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : int) -> int: '''simple docstring''' if not head: return True # split the list to two parts __UpperCamelCase , __UpperCamelCase : List[Any] = head.next, head while...
232
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar lowercase : Optional[Any] = TypeVar('T') class lowerCamelCase__ ( Generic[T]): '''simple docstring''' _A = 42 # Cache store ...
232
1
import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, require_multi_gpu from ac...
366
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def lowerCamelCase__ ( a__ : Dataset , a__ : Dict[str, str] ) -> int: UpperCamelCase_ ...
261
0