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 unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class _UpperCAmelCase ( unittest.TestCase): def __snake_case ( self ) -> List[Any]: '''simple docstring''' ...
246
"""simple docstring""" from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ...
289
0
from __future__ import annotations def lowerCamelCase__ ( a ) -> bool: _A: List[str] = len(a ) # We need to create solution object to save path. _A: Optional[Any] = [[0 for _ in range(a )] for _ in range(a )] _A: List[Any] = run_maze(a , 0 , 0 ...
301
from __future__ import annotations UpperCAmelCase__ : List[str] = list[list[int]] # assigning initial values to the grid UpperCAmelCase__ : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0]...
301
1
'''simple docstring''' import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever lowerCAmelCase :List[Any] = logging.getLogger(__name__) class _lowerCamelCase ( lowercase__ ...
331
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import requ...
331
1
def _lowercase ( UpperCamelCase_ , UpperCamelCase_ ) -> str: '''simple docstring''' if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) SCREAMING_SNAKE_CASE__ = str(bin(UpperCamelCase_ ) )[2:] # remove the leading "...
350
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class lowercase__ ( _UpperCAmelCase ): A__ : Any =(CMStochasticIterativeScheduler,) A__ : Optional[int] =1_0 def A_ ( self : Dict , ...
169
0
'''simple docstring''' def UpperCamelCase_( snake_case : int ): '''simple docstring''' if isinstance(snake_case , snake_case ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(snake_case ...
85
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Dict = { "BridgeTower/bridgetower-ba...
85
1
'''simple docstring''' from typing import Dict, List, Optional, Tuple, 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, resize, ...
6
'''simple docstring''' def a_ ( __snake_case : int = 1000 ) -> int: """simple docstring""" lowerCamelCase_, lowerCamelCase_ =1, 1 lowerCamelCase_ =2 while True: lowerCamelCase_ =0 lowerCame...
6
1
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable _SCREAMING_SNAKE_CASE : Tuple = {"configuration_gpt_neox": ["GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP",...
85
def SCREAMING_SNAKE_CASE__ ( __a ): if not isinstance(__a , __a ): snake_case_ : int = f"""Input value of [number={number}] must be an integer""" raise TypeError(__a ) if number < 0: return False snake_case_ : Dict = number * number ...
327
0
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_diffusion_sa...
328
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent _UpperCAmelCase = {'UserAgent': UserAgent().random} def lowerCAmelCase_ ( UpperCamelCase_ ) -> dict: UpperCamelCase_ = script.conte...
328
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Union[str, Any] = logging.get_logger(__name__) __lowerCAmelCase : List[str] = { "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json", } ...
156
from typing import Dict from .base import GenericTensor, Pipeline class A ( _UpperCAmelCase ): """simple docstring""" def snake_case__ ( self : int,lowercase_ : Dict=None,lowercase_ : Tuple=None,lowercase_ : List[Any]=None,...
7
0
"""simple docstring""" import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict A : Tuple = namedtuple( "_TestCommandArg...
259
"""simple docstring""" import string def _lowerCamelCase ( _UpperCamelCase ): '''simple docstring''' __lowerCAmelCase = "" for i in sequence: __lowerCAmelCase = ord(_UpperCamelCase ) if 65 <= extract <= 90: output += chr(155 - extract ) ...
259
1
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { "BAAI/AltCLIP": "https://huggingface.co/BAAI/A...
158
'''simple docstring''' from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclas...
158
1
from __future__ import annotations SCREAMING_SNAKE_CASE__ = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] SCREAMING_SNAKE_CASE__ = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def lowerCAmelCase__ ( _UpperCamelCase : str ) -> List[str]: ...
355
"""simple docstring""" 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 transform...
149
0
import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.utils impor...
312
import os from typing import Dict, List, Tuple, TypeVar, Union __a :Any = TypeVar('T') __a :Union[str, Any] = Union[List[T], Tuple[T, ...]] __a :List[str] = Union[T, List[T], Dict[str, T]] __a :Any = Union[str, bytes, os.PathLike]
312
1
import unittest from transformers import GPTSwaTokenizer 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/test_sentencepi...
36
def lowerCAmelCase__ ( _a : dict ): snake_case_ : List[Any] = set() # edges = list of graph's edges snake_case_ : int = get_edges(_a ) # While there are still elements in edges list, take an arbitrary edge # (from_node, to_node) and add his extre...
36
1
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version lowerCAmelCase__ : int ={ '''<''': operator.lt, '''<=''': operator.le, '''==''': operator.eq, '''!=''': operator.ne, '''>=''': operator.ge, '''>''': op...
257
'''simple docstring''' 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 UpperCamelCase__ ( unittest.TestCase ): """simple docs...
323
0
'''simple docstring''' from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class _UpperCamelCase ( A ): '''simple docstring''' def __init__( self : ...
355
'''simple docstring''' 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 ( A ):...
48
0
'''simple docstring''' from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_c...
163
"""simple docstring""" from __future__ import annotations def __A ( a_ :str , a_ :str) -> bool: __a : Optional[Any] = get_failure_array(a_) # 2) Step through text searching for pattern __a , __a : Union[str, Any] = ...
160
0
'''simple docstring''' from math import isqrt def UpperCamelCase_( snake_case : int ): '''simple docstring''' return all(number % divisor != 0 for divisor in range(2 , isqrt(snake_case ) + 1 ) ) def UpperCamelCase_( snake_case : i...
92
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _SCREAMING_SNAKE_CASE : Optional[int] = { "configuration_canine": ["CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP", "CanineConf...
92
1
def lowerCAmelCase__ ( lowerCamelCase_ : int = 1000000): '''simple docstring''' lowerCAmelCase__ : Any = [i - 1 for i in range(limit + 1)] for i in range(2 ,limit + 1): if phi[i] == i - 1: for j in range(2 * i ,limit + 1 ,lowerCam...
129
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __snake_case : Dict =logging.get_logger(__name__) __snake_case : Optional[int] ={ 'facebook/xlm-roberta-xl'...
129
1
"""simple docstring""" from __future__ import annotations from random import random from typing import Generic, TypeVar _UpperCamelCase : int = TypeVar('KT') _UpperCamelCase : Any = TypeVar('VT') class snake_case ( Generic[KT, VT] ): def __init__( se...
186
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCamelCase : Optional[int] = { 'configuration_rag': ['RagConfig'], 'retrieval_rag': ['RagRetriever'], 'tokenization_ra...
186
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) class snake_case__(__lowerCAmelCase ): """simple docstring""" lowercase_ = '''timm_backbone''' def __init__( self : Option...
130
"""simple docstring""" import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased/resolve/main/config.json''', '''xlnet-large-cased''': '''https:/...
315
0
"""simple docstring""" from __future__ import annotations def _a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> bool: if len(_SCREAMING_SNAKE_CASE ) == 0: return False snake_case_ = len(_SCREAMING_SNAKE_CASE ) // 2 if a_list[midpoint] =...
233
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @requ...
233
1
import doctest from collections import deque import numpy as np class lowerCAmelCase__ : '''simple docstring''' def __init__( self) -> Union[str, Any]: _A : List[str] = [2, 1, 2, -1] _A : List[Any] = [1, 2, 3, 4]...
11
"""simple docstring""" import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accelerat...
115
0
'''simple docstring''' def UpperCAmelCase_ ( __lowerCamelCase : Tuple ): lowercase_ :Dict = 0 lowercase_ :Dict = len(__lowerCamelCase ) for i in range(n - 1 ): for j in range(i + 1 ,__lowerCamelCase ): if arr[i] > arr...
147
'''simple docstring''' from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging lowerCAmelCase : Tuple =logging.get_logger(__name__) def UpperCAmelCase_ ( __lowerCamelCase : Union[tf.Tensor, np.ndarray] ): ...
147
1
'''simple docstring''' import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformer...
163
from collections import defaultdict def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): __a = first_str.lower().strip() __a = second_str.lower().strip() # Remove whitespace __a = first_str.replace(''' ''' , '''''' ) __a ...
49
0
'''simple docstring''' import sys __lowercase : Union[str, Any] = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '12540698747158523863050715693290963295227443043557' ...
294
'''simple docstring''' def lowerCamelCase (_SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ): if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise ValueError('iterations must be defined as integers' ) if ...
294
1
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester from ....
5
UpperCAmelCase__ = { '''A''': '''.-''', '''B''': '''-...''', '''C''': '''-.-.''', '''D''': '''-..''', '''E''': '''.''', '''F''': '''..-.''', '''G''': '''--.''', '''H''': '''....''', '''I''': '''..''', '''J''': '''.---''', '''K''': '''-.-''', '''L''': '''.-..''', '''M''': '''--''', '''N''': '''-.''',...
5
1
"""simple docstring""" import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline UpperCAmelCase = { '''n_samples''': 64, '''horizon''': 32, '''num_inference_steps''': 20, '''n_guide_steps''': 2, # can set to 0 for faster sampl...
350
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __magic_name__ ( __UpperCAme...
172
0
"""simple docstring""" 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_i...
33
def A_ ( _UpperCAmelCase , _UpperCAmelCase = False ): if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: str = f"Expected string as input, found {type(_UpperCAmelCase )}" raise ValueError(_UpperCAmelCase ) if not isi...
13
0
"""simple docstring""" _a : Union[str, Any]= "Alexander Joslin" import operator as op from .stack import Stack def __UpperCAmelCase ( UpperCAmelCase_ : str ) -> int: '''simple docstring''' __snake_case : Dict = {'*': op.mul, '/': ...
365
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from tra...
95
0
'''simple docstring''' import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand _lowerCamelCase : Optional[int] = ( "4S 3H 2C 7S 5H", "9D 8H 2C 6S 7H", "2D 6D 9D TH 7D", "TC 8C 2S JH 6C", "JH 8S TH ...
28
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfi...
28
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 ModelMixin...
331
'''simple docstring''' def a__ ( a__ ): """simple docstring""" __SCREAMING_SNAKE_CASE = len(a__ ) while cur > 1: # Find the maximum number in arr __SCREAMING_SNAKE_CASE = arr.index(max(arr[0:cur] ) ) # Reverse from...
331
1
"""simple docstring""" import os UpperCAmelCase__ : List[str] = {'I': 1, 'V': 5, 'X': 1_0, 'L': 5_0, 'C': 1_0_0, 'D': 5_0_0, 'M': 1_0_0_0} def lowercase_ ( _snake_case ): SCREAMING_SNAKE_CASE__ : Tuple = 0 SCREAMING_SNAKE_CASE__ : ...
25
"""simple docstring""" UpperCAmelCase__ : List[str] = [ 9_9_9, 8_0_0, 7_9_9, 6_0_0, 5_9_9, 5_0_0, 4_0_0, 3_9_9, 3_7_7, 3_5_5, 3_3_3, 3_1_1, 2_8_8, 2_6_6, 2_4_4, 2_2_2, 2_0_0, 1_9_9, 1_7_7, 1_...
25
1
'''simple docstring''' import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSequenceC...
361
'''simple docstring''' import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common ...
21
0
"""simple docstring""" def lowercase_ ( __UpperCAmelCase ) -> int: lowerCAmelCase__ : List[str] = [] lowerCAmelCase__ : Union[str, Any] = set({"""(""", """[""", """{"""} ) lowerCAmelCase__ : List[Any] = set({""")""", """]""...
242
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ = { '''configuration_pix2struct''': [ '''PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Pix2Stru...
108
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImageProces...
24
"""simple docstring""" def lowercase ( _snake_case : int ) ->str: """simple docstring""" if number > 0: raise ValueError('''input must be a negative integer''' ) __snake_case : Any = len(bin(_snake_case )[3:] ) __snake_case : List[Any] ...
24
1
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class __UpperCAmelCase ( lowerCamelCase__ ): UpperCamelCase = (PNDMScheduler,) UpperCamelCase = (("""num_inference_steps""", 5_0),) def ...
336
from __future__ import annotations def a__ ( UpperCAmelCase : list[list[int]] ) -> bool: UpperCAmelCase : Union[str, Any] = len(UpperCAmelCase ) # We need to create solution object to save path. UpperCAmelCase : int = [[0 for _ in range(UpperCAmelCase )] fo...
336
1
'''simple docstring''' from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def lowercase__ ( __UpperCamelCase )-> int: UpperCamelCase = prime_factors(__UpperCamelCase ) if is_square_free(__UpperCamelCase ): ...
183
'''simple docstring''' from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def lowercase__ ( __UpperCamelCase )-> int: UpperCamelCase = prime_factors(__UpperCamelCase ) if is_square_free(__UpperCamelCase ): ...
183
1
'''simple docstring''' import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import GradientAccumul...
67
def UpperCAmelCase__ ( ): '''simple docstring''' return [ a * b * (10_00 - a - b) for a in range(1 , 9_99 ) for b in range(_A , 9_99 ) if (a * a + b * b == (10_00 - a - b) ** 2) ][0] if __name__ == "__main__": print(f"""{solution() = }""...
188
0
"""simple docstring""" import math import sys def lowerCamelCase ( _UpperCamelCase : int ) -> int: '''simple docstring''' if number != int(_UpperCamelCase ): raise ValueError("""the value of input must be a natural number""" ) if number < 0...
365
"""simple docstring""" import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from tra...
320
0
'''simple docstring''' import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets lowercase_ = datasets.logging.get_logger(__name__) lowercase_ = """\ @inproceedings{bleurt, title={BLEURT: Learning Robust Metrics for Text Generation}, author={T...
58
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...fe...
26
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a: List[str] = { """configuration_clap""": [ """CLAP_PRETRAINED_MODEL_ARCHIVE_LIST""", """ClapAudioConfig""", """ClapConfig""", ...
214
'''simple docstring''' import numpy as np def __UpperCamelCase ( UpperCAmelCase ): return 1 / (1 + np.exp(-vector )) def __UpperCamelCase ( UpperCAmelCase ): return vector * sigmoid(UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.testmod()
214
1
"""simple docstring""" import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathl...
106
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def __SCREAMING_SNAKE_CASE ( A_ = 1_00_00_00 , A_ = 10 ): lowerCAmelCase__ : defaultdict = defaultdict(A_ ) for outer_width in range(3 , (t_limit // 4) + 2 ): if outer_width * outer_wi...
106
1
"""simple docstring""" def UpperCAmelCase ( a_ ): '''simple docstring''' if number > 0: raise ValueError('input must be a negative integer' ) lowerCamelCase : int = len(bin(a_ )[3:] ) lowerCamelCase : int = bin(abs(a_ ...
205
"""simple docstring""" def UpperCAmelCase ( a_ = 1000 ): '''simple docstring''' lowerCamelCase : Dict = 2**power lowerCamelCase : List[str] = str(a_ ) lowerCamelCase : Dict = list(a_ ) lowerCamelCase : ...
205
1
import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __A =logging.get_logger(__name__) __A ={'''vocab_file''': '''vocab.json'''} __A ={ '''vocab_file''': { '''mgp-str''': '''https://huggingface.co/alibaba-d...
19
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __A ={ '''configuration_bloom''': ['''BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BloomConfig''', '''BloomOnnxConfig'''], } try: if not is_tokenizers_available(): ...
19
1
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKIN...
370
"""simple docstring""" import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def A_ ( snake_case_ : int ): # picklable for...
27
0
"""simple docstring""" from __future__ import annotations import numpy as np def __lowerCamelCase ( __UpperCamelCase ) -> Optional[Any]: """simple docstring""" return np.maximum(0 , __UpperCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5...
241
"""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_avai...
241
1
print((lambda quine: quine % quine)("print((lambda quine: quine %% quine)(%r))"))
359
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _snake_case = { "configuration_roc_bert": ["ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "RoCBertConfig"], "tokenization_roc_bert": ["RoCBertTokenizer"], } try: ...
343
0
'''simple docstring''' import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE : str = logging.get_logger(__name__) __S...
31
'''simple docstring''' import math import unittest from transformers import BioGptConfig, 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_modeli...
31
1
"""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 ( ChannelDimension, PILIm...
370
from __future__ import annotations from typing import Any class _SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__(self : Any , UpperCAmelCase_ : int) ->None: '''simple docstring''' lowerCamelCase__: int =num_of_nodes lowerCamelCase__...
273
0
"""simple docstring""" def snake_case__ ( __lowerCamelCase : list ): """simple docstring""" if len(__lowerCamelCase ) < 2: return collection def circle_sort_util(__lowerCamelCase : list , __lowerCamelCase : int , __lowerCamelCase : int ) -> bool: ...
238
"""simple docstring""" import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_P...
238
1
"""simple docstring""" from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor __A = trans...
64
"""simple docstring""" from __future__ import annotations from collections.abc import Sequence from typing import Literal def lowercase_ ( _lowerCamelCase: str , _lowerCamelCase: str ) -> str | Literal[False]: '''simple docstring''' __lowerCamelCase : Optional[int] ...
64
1
import json import os import shutil import tempfile import unittest from transformers import BatchEncoding, CanineTokenizer from transformers.testing_utils import require_tokenizers, require_torch from transformers.tokenization_utils import AddedToken from transformers.utils import cached_property from ....
156
import numpy as np from PIL import Image def UpperCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> np.ndarray: __lowercase : Optional[int] = np.array(__lowerCAmelCase ) if arr.shape[0] != arr.shape[1]: raise ValueError('''The input ...
156
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 a_ = logging.get_logger(__name__) a_ = { '''facebook/data2ve...
371
"""simple docstring""" import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency a_ = { """E""": 12.70, """T""": 9.06, """A""": 8.17, """O""": 7.51, """I""": 6.97, """N""": 6.75, """S""": 6.33, """H""": 6.09, """R""": 5.99, """D""": 4.25...
291
0
'''simple docstring''' import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": a_ = pd.read_csv('sample_data.csv', header=None) a_ ...
152
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device lowerCamelCase : Optional[int] = False class A__ ( ...
47
0
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp ...
369
# 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 # # Unles...
348
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase : Optional[Any] = { '''configuration_bloom''': ['''BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BloomConfig''', '''BloomOnnxConfig'''], ...
280
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch import nn ...
280
1
"""simple docstring""" from ....utils import logging _lowercase : List[str] = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): '''simple docstring''' def __init__( self : List[str], lowerCamelCase : List[Any], lo...
361
"""simple docstring""" from ..utils import DummyObject, requires_backends class __SCREAMING_SNAKE_CASE ( metaclass=lowerCAmelCase_ ): '''simple docstring''' _a = ['torch', 'torchsde'] def __init__( self : Union[str, Any], *lowerCamelCase ...
272
0
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import Con...
127
def UpperCAmelCase__ (UpperCamelCase_ ,UpperCamelCase_ ): """simple docstring""" snake_case = [1] for i in range(2 ,UpperCamelCase_ ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k out of bounds"...
127
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase : int = logging.get_logger(__name__) __UpperCAmelCase :...
367
'''simple docstring''' def __A ( lowerCAmelCase_ ): _UpperCAmelCase : Optional[Any] = 0 while len(lowerCAmelCase_ ) > 1: _UpperCAmelCase : List[Any] = 0 # Consider two files with minimum cost to be merged for _ in range(2 ): _UpperCAmelCase ...
170
0
"""simple docstring""" from __future__ import annotations def __lowerCAmelCase ( lowercase : List[Any] ) -> bool: """simple docstring""" snake_case : Dict = len(_A ) # We need to create solution object to save path. snake_case : List[An...
203
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow from ..t...
245
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging lowerCamelCase :str = logging.get_logger(__na...
135
'''simple docstring''' import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput...
135
1
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_tokenization_commo...
184
from PIL import Image def lowercase_ ( _A : Image ): """simple docstring""" lowerCamelCase__ , lowerCamelCase__ : List[str] = image.size lowerCamelCase__ : Dict = 0 lowerCamelCase__ : Dict = image.load() for i in range(...
184
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig __lowerCAmelCase = { '''albert-base-v1''': '''https://huggingface.co/albert-base-v1/resolve/main/config.json''', '''albert-large-v1''': '''h...
363
import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from transform...
288
0
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 UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ ...
5
UpperCAmelCase__ = { '''A''': '''.-''', '''B''': '''-...''', '''C''': '''-.-.''', '''D''': '''-..''', '''E''': '''.''', '''F''': '''..-.''', '''G''': '''--.''', '''H''': '''....''', '''I''': '''..''', '''J''': '''.---''', '''K''': '''-.-''', '''L''': '''.-..''', '''M''': '''--''', '''N''': '''-.''',...
5
1
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def _a ( a :Union[str, Any] ) -> Any: if not is_accelerate_available(): return method a = version.parse(accelerate.__version...
26
import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class lowercase_ ( lowercase ): '''simp...
26
1
"""simple docstring""" import os from datetime import datetime as dt from github import Github __A = [ 'good first issue', 'feature request', 'wip', ] def __A () ->int: """simple docstring""" lowerCAmelCase__ :Optional[Any] = Github(os.environ['GI...
293
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _lowerCamel...
63
0
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokeniz...
369
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase ) class _lowercase ( lowerCAmelCase ): """simple docstring""" __A = ...
71
0
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from da...
214
import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --host <host...
214
1
def lowerCAmelCase_ ( __lowerCAmelCase = 50_00_00_00 )-> int: '''simple docstring''' UpperCAmelCase : Union[str, Any] =set() UpperCAmelCase : Optional[int] =int((limit - 24) ** (1 / 2) ) UpperCAmelCase : List[str] =set(range(3...
78
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge __snake_case = [ '''Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell phone video of the''' '''...
78
1
"""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, ...
194
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, resize, to_channel_dimen...
308
0
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { 'huggingface/informer-tourism-monthly': ( 'https://huggingface.co/huggingface/informer-tourism-monthly/resol...
194
import datasets lowercase_ = '\\n@InProceedings{conneau2018xnli,\n author = "Conneau, Alexis\n and Rinott, Ruty\n and Lample, Guillaume\n and Williams, Adina\n and Bowman, Samuel R.\n and Schwenk, Holger\n and S...
194
1
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 snake_case ( SCREAMIN...
317
from ..utils import DummyObject, requires_backends class snake_case ( metaclass=SCREAMING_SNAKE_CASE_ ): '''simple docstring''' snake_case_ : Optional[Any] = ["""torch"""] def __init__( self : Union[str, Any] , *lowerC...
317
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE_:Tuple = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:Optional[Any] = { """ut/deta""": """https://huggingface.co/ut/deta/resolve/main/co...
368
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
115
0
from ..utils import DummyObject, requires_backends class UpperCamelCase_ ( metaclass=UpperCAmelCase__ ): '''simple docstring''' UpperCAmelCase__ = ['''flax''', '''transformers'''] def __init__( self : List[str] , *UpperCAmelCase__ : str , **UpperCA...
14
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def SCREAMING_SNAKE_CASE ( lowercase_ ) -> Dict: """simple docstring""" A__ = args.pruning_method A__ = ar...
14
1
"""simple docstring""" import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accele...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number | (1 << position) def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number & ~(1 << position) def _lowercase ( __lower...
56
1
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def lowerCamelCase__ ( ) -> Optional[int]: __snake_case = ArgumentParser( description=( ...
24
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 SCREAMING_SNAKE_CASE__ ( ...
24
1
import os from datetime import datetime as dt from github import Github lowerCamelCase_ = [ "good first issue", "feature request", "wip", ] def __lowerCamelCase ( ) -> List[str]: __SCREAMING_SNAKE_CASE :Optional[Any] = Github...
369
"""simple docstring""" from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { "microsoft/xprophetnet-large-wiki100-cased": ( "htt...
239
0
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class ...
166
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = { "configuration_layoutlmv2": ["LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "LayoutLMv2Config"], ...
299
0
"""simple docstring""" import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, ...
367
"""simple docstring""" import os def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' UpperCAmelCase = len(grid[0] ) UpperCAmelCase = len(lowerCAmelCase ) UpperCAmelCase = 0 UpperCAmelCase ...
248
0
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.sp...
213
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A__ : Tuple ={ '''configuration_mvp''': ['''MVP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MvpConfig''', '''MvpO...
70
0
def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): lowercase__ = f'Input value of [number={number}] must be an integer' raise TypeError(SCREAMING_SNAKE_CASE ) if number < 0: ...
93
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase = { 'configuration_luke': ['LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LukeConfig'], 'tokenization_luke': ['LukeTokenizer'], } try: if not is_torch_availa...
93
1
from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.schedulers.scheduling_ddpm ...
314
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : List[str] = logging.get_logg...
174
0
import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : dict ): '...
20
from __future__ import annotations import math def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : bool , __SCREAMING_SNAKE_CASE : list[int] , __SCREAMING_SNAKE_CASE : float ): ...
20
1
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 import cached_property from ...test_toke...
328
from __future__ import annotations from collections.abc import Callable def A_ ( snake_case : Callable[[int | float], int | float] , snake_case : int | float , snake_case : int | float , snake_case : int = 100 , ) ...
328
1
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, FlaxT...
257
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_collator...
257
1
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils impor...
316
"""simple docstring""" import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelF...
316
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_model...
355
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-b-16x2-kinetics400/resolv...
239
0
"""simple docstring""" from __future__ import annotations def a__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase = get_failure_array(_SCREAMING_SNAKE_CASE ) # 2) Step through text searching for pattern UpperCamelCase , ...
153
"""simple docstring""" def a__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): """simple docstring""" if exponent == 1: return base if exponent % 2 == 0: UpperCamelCase = _modexpt(_SCREAMING_SNAKE_CASE , exponent // 2 , _SC...
153
1
'''simple docstring''' import datasets from .evaluate import evaluate _lowerCAmelCase = '''\ @article{hendrycks2021cuad, title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review}, author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball}, journal={ar...
184
'''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_inpu...
184
1
"""simple docstring""" from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available fr...
288
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_t...
221
0
import numpy as np import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel from ...utils import logging a : str = logging.get_logger(__name__) class _a ( _lowerCAmelCase ): A = ...
360
import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging a : Tuple = logging.get_logger(__name__) a : Optional[Any] = { 'facebook/encodec_24khz': 'https://huggingface.co/facebo...
82
0
"""simple docstring""" def a__ ( snake_case__ , snake_case__ , snake_case__ ) -> list: lowerCamelCase = len(__A ) lowerCamelCase = [[0] * n for i in range(__A )] for i in range(__A ): lowerCamelCase = y_points[i] for...
291
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. lowercase : Dict = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
42
0
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { 'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json', # See all ...
360
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class A_ (lowercase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE__...
23
0
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils impo...
281
import argparse import collections import json import os import re import string import sys import numpy as np snake_case : Dict = re.compile(R"\b(a|an|the)\b", re.UNICODE) snake_case : Optional[int] = None def lowerCAmelCase_ ( ) -> Union[str, Any]: '''simp...
281
1
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE = 1_000_000 ) -> int: snake_case_ = 1 snake_case_ = 1 snake_case_ = {1: 1} for inputa in range(2 , _SCREAMING_SNAKE_CASE ): snake_case_ = 0 ...
233
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed fro...
233
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_availab...
307
class __SCREAMING_SNAKE_CASE( a_ ): pass class __SCREAMING_SNAKE_CASE( a_ ): pass class __SCREAMING_SNAKE_CASE: def __init__( self: List[str] ) -> Union[str, Any]: snake_case__ = [ [], ...
307
1
import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transformers.testing_utils imp...
371
import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_torchaudio @require...
70
0
"""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 SCREAMING_SNAKE_CASE__ ( datasets.BuilderConfig ): """simple docstring""...
108
"""simple docstring""" import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSam...
108
1
'''simple docstring''' import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase=1024 ): lowercase__ , lowercase__ : List[str...
214
'''simple docstring''' import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PARAMS, UN...
214
1