code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import 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 transformers.models.switch_transformers.convert_switch_tr...
325
"""simple docstring""" from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, ...
91
0
from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : np.ndarray , SCREAMING_SNAKE_CASE__ : np.ndarray , SCREAMING_SNAKE_CASE__ : np.ndarray , SCREAMING_SNAKE_CASE__ : i...
117
import pprint import requests _A = 'https://zenquotes.io/api' def _UpperCAmelCase ( ): return requests.get(API_ENDPOINT_URL + '/today' ).json() def _UpperCAmelCase ( ): return requests.get(API_ENDPOINT_URL + '/random' ).json() if __name__ == "__main__": _A ...
117
1
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a = False class lowercase_ ( unittest.TestCas...
315
"""simple docstring""" import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils im...
315
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase : int = { 'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'], 'to...
361
'''simple docstring''' import argparse import importlib from pathlib import Path # Test all the extensions added in the setup lowercase : Optional[int] = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/...
311
0
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner im...
230
import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_...
230
1
import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEmbeddings, BertLay...
231
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Any = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: if not is_torch_avai...
231
1
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast UpperCAmelCase : Union[str, Any] = datasets.utils.logging.get_logger(__name__) @dataclass class __low...
252
import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common import SequenceFeatureExtraction...
252
1
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_acceler...
173
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def __lowercase ( _UpperCamelCase ) ->Tuple: """simple docstring""" lowercase : List[str] = [ '''encoder.version''', ...
173
1
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( A_ , A_ ): return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
106
"""simple docstring""" import os from collections.abc import Iterator def __SCREAMING_SNAKE_CASE ( A_ = "." ): for dir_path, dir_names, filenames in os.walk(A_ ): lowerCAmelCase__ : str = [d for d in dir_names if d != '''scripts''' and d[0] not in '''._'''] for filename in filenames: i...
106
1
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 UpperCamelCase__ =datasets.logging.get_logger(__name__) UpperCamelCase__ ='\\n@InProceedings{moosavi2019minimum,\n author = { N...
325
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCamelCase__ ={ 'configuration_swiftformer': [ 'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SwiftFormerConfig', 'SwiftFormerOnnxConfig',...
325
1
"""simple docstring""" from math import isqrt, loga def lowercase (_lowerCAmelCase ): __lowerCAmelCase = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , _lowerCAmelCase , ...
301
"""simple docstring""" from __future__ import annotations def lowercase (_lowerCAmelCase , _lowerCAmelCase ): __lowerCAmelCase = [] create_all_state(1 , _lowerCAmelCase , _lowerCAmelCase , [] , _lowerCAmelCase ) return result def lower...
301
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import RoFormerConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMix...
363
'''simple docstring''' import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
240
0
'''simple docstring''' import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_availab...
89
'''simple docstring''' __lowerCAmelCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE ): # Make sure the supplied data is a bytes-like object if not isinstance(_SCREAMING_SNAKE_CASE , ...
341
0
class __a : def __init__( self , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ) -> Tuple: '''simple docstring''' lowercase__: List[str] = name lowercase__: Any = value lowercase__: ...
288
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 __a ( tf.keras.layers.Layer ): def __init__( self , ...
288
1
from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, vali...
12
from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class __UpperCAmelCase : def __magic_name__ ( self : int, __A : Dict ): raise NotImplementedError() def ...
336
0
'''simple docstring''' import numpy as np def __lowerCamelCase ( _lowercase , _lowercase , _lowercase , _lowercase , _lowercase ) -> Optional[Any]: UpperCAmelCase : Tuple = int(np.ceil((x_end - xa) / h ) ) UpperCAmelCase : Option...
338
'''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 : Union[str, Any] = logging.get_logger(__name__) a : ...
338
1
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ : Optional[int] = logging.get_logger(__name__) snake_case__ : Optional[Any] = { 'google/fnet-base': 'https://huggingface.co/google/fnet-base/resolve...
117
import heapq import sys import numpy as np snake_case__ : Tuple = tuple[int, int] class A_ : def __init__(self :Union[str, Any] )-> Union[str, Any]: __A = [] __A = set() def _lowerCAmelCas...
117
1
"""simple docstring""" 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...
366
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : str = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_torch_available(...
259
0
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mode...
124
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : Union[str, Any] = { "configuration_encodec": [ "ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP", "EncodecConfig", ], "fea...
311
0
"""simple docstring""" import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def _A ( _a : Tuple , _a : Optional[int] , _...
77
"""simple docstring""" from __future__ import annotations import math from collections.abc import Callable def _A ( _a : Callable[[int | float], int | float] , _a : int | float , _a : int | float , _a : int = 1_0_0 , ): """simple docs...
77
1
# Copyright (c) 2021-, NVIDIA CORPORATION. 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 app...
231
from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class _lowerCAmelCase ( __a ): _lowercase ='''megatron-bert''' def _...
231
1
"""simple docstring""" import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import j...
161
"""simple docstring""" from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def __lowerCamelCase ( __UpperCamelCase ) -> Any: """simple docstring""" if not is_accelerate_available(): return method ...
161
1
"""simple docstring""" import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( """split_dict""" , [ SplitDict(), SplitDict({"""train""": SplitInfo(name="""train""" , num_bytes=1337 ...
173
"""simple docstring""" # Lint as: python3 import itertools import os import re _UpperCAmelCase = re.compile(r"""([A-Z]+)([A-Z][a-z])""") _UpperCAmelCase = re.compile(r"""([a-z\d])([A-Z])""") _UpperCAmelCase = re.compile(r"""(?<!_)_(?!_)""") _UpperCAmelCase = re.compile(r"""(_{2,})""") _...
173
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ ={ 'configuration_roberta': ['ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Robe...
325
def lowerCamelCase__ (__lowerCamelCase, __lowerCamelCase ): _SCREAMING_SNAKE_CASE : Tuple = [0 for i in range(r + 1 )] # nc0 = 1 _SCREAMING_SNAKE_CASE : Optional[int] = 1 for i in range(1, n + 1 ): # to compute current row from pre...
325
1
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 SCREAMING_SNAKE_CASE__ = datasets.logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = """\ @InProceedings{moosavi2019minimum, ...
325
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/resolve/main/config.json""", } class A__ ( lowerCAmelCase...
325
1
"""simple docstring""" import math def lowercase__ ( _UpperCAmelCase , _UpperCAmelCase ) -> int: '''simple docstring''' if initial_intensity < 0: raise ValueError('The value of intensity cannot be negative' ) #...
363
"""simple docstring""" def lowercase__ ( _UpperCAmelCase ) -> int: '''simple docstring''' assert isinstance(_UpperCAmelCase , _UpperCAmelCase ), f'''The input value of [n={number}] is not an integer''' if number == 1: ret...
53
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=lowerCamelCase_ ) class _lowercase (lowerCamelCase_ ): '''simple docstring''' lowercase__ ...
128
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 snake_case : List[Any] = datasets.logging.get_logger(__name__) snake_case : List[str] = '''\ @InPro...
240
0
import math def A_ ( _UpperCAmelCase , _UpperCAmelCase ): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(_UpperCAmelCase ) else: if x == 0: # 0 raised to any number is 0 ...
127
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_tokenization_common impo...
127
1
"""simple docstring""" from __future__ import annotations def _UpperCAmelCase ( __lowerCamelCase : int | float | str , __lowerCamelCase : int | float | str ) -> list[str]: if nth_term == "": return [""] _snake_case = int(__lowerCamelCase ) _...
288
"""simple docstring""" from math import pow def _UpperCAmelCase ( __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int , ) -> tuple[int, int]: if current_sum =...
288
1
def __snake_case ( _lowerCAmelCase : int , _lowerCAmelCase : int ) -> int: while b: A_ , A_ : List[str] = b, a % b return a def __snake_case ( _lowerCAmelCase : int , _lowerCAmelCase : int ) -> int: return a if b == 0 else euclidean_gcd_recursive(__lowerC...
353
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path _lowerCAmelCase : Optional[Any] = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa im...
70
0
import numpy as np def SCREAMING_SNAKE_CASE_ ( snake_case__ , snake_case__ , snake_case__ , snake_case__ , snake_case__ ) -> Optional[int]: lowerCAmelCase = int(np.ceil((x_end - xa) / h ) ) lowerCAmelCase = np.zeros((n + 1,) ) lowerCAm...
338
class lowercase_ : """simple docstring""" def __init__( self , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) ->Any: lowerCAmelCase = name lowerCAmelCase = value lowerCAmelCase = weight def __repr__( ...
338
1
"""simple docstring""" import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, ...
157
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE : List[str] = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBi...
157
1
from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch('''socket.socket''' ) @patch('''builtins.open''' ) def lowerCamelCase_ ( _a , _a ): """simple docstring""" lowerCAmelCase__ : Optional[Any] ...
131
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() __snake_case = logging.get_logger(__name__) __snake_case = """https://...
259
0
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets UpperCAmelCase = '\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Translation for Text Simplification},\n authors={Xu, Wei and ...
358
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin UpperCAm...
267
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase : Optional[Any] = logging.get_logger(__name__) _UpperCamelCase : List[str] = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/confi...
77
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase : Tuple = logging.get_logger(__name__) _UpperCamelCase : Union[str, Any] = { "alibaba-damo/mgp-str-base": "https://huggingface.co/alibaba-damo/mgp-str-base/re...
77
1
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class lowerCAmelCase__( __lowercase , unittest.TestCase ...
325
from timeit import timeit def lowerCamelCase__ (__lowerCamelCase ): if number < 0: raise ValueError("the value of input must not be negative" ) _SCREAMING_SNAKE_CASE : str = 0 while number: number &= number - 1 result += 1 return...
325
1
'''simple docstring''' from __future__ import annotations from typing import Any def snake_case ( UpperCAmelCase )-> None: """simple docstring""" create_state_space_tree(UpperCAmelCase , [] , 0 ) def snake_case ...
161
'''simple docstring''' # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase__ ( SCREAMING_SNAKE_CASE): def __init__( self :Optional[int] , _A ...
161
1
'''simple docstring''' import json import pathlib import unittest import numpy as np 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 import ImageProcessingSavingTestMixin, prepa...
106
'''simple docstring''' from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES SCREAMING_SNAKE_CASE_: Any =logging.get_logger(__name__) SCREAMING_SNAKE_CASE_: ...
106
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ = { """configuration_roberta""": ["""ROBERTA_PRETRAINED_CONFIG_ARCHIVE_M...
325
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = {name: getattr(transformers, name + """Fast""") for n...
325
1
from collections.abc import Iterable from typing import Any class SCREAMING_SNAKE_CASE__ : def __init__( self : Optional[int] , SCREAMING_SNAKE_CASE__ : Union[str, Any] = None ) -> str: a_ : Optional[int] = value a_ : Node | None = ...
367
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Any = { 'configuration_mobilebert': [ 'MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_...
120
0
"""simple docstring""" from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_torch_availab...
100
'''simple docstring''' from __future__ import annotations from typing import Any class snake_case ( __lowerCamelCase ): """simple docstring""" pass class snake_case : """simple docstring""" def __init__( self : List[Any] , __A : ...
53
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __A ={ 'configuration_m2m_100': ['M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP', 'M2M100Config', 'M2M100OnnxConfig'], 'tokenizati...
283
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class _snake_case ( a__ ): lowerCAmelCase :Optional[int] = '''''' lowerCAmelCase :str ...
283
1
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow _SCREAMING_SNAKE_CASE : Optional[Any] = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ ...
127
import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class A__ ( snake_case__ , unittest.TestCase )...
127
1
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultiste...
255
"""simple docstring""" import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from...
255
1
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0...
1
'''simple docstring''' def UpperCamelCase__ ( lowerCAmelCase , lowerCAmelCase ): """simple docstring""" _lowerCAmelCase = [0 for i in range(r + 1 )] # nc0 = 1 _lowerCAmelCase = 1 for i in range(1...
70
0
'''simple docstring''' from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split _lowercase : Tuple = datasets.load_iris() _lowercase : List[str] = np.array(data["data"]) _lowercase : Union[str, An...
356
'''simple docstring''' import os import numpy import onnx def lowerCamelCase ( UpperCAmelCase__ : Optional[int] , UpperCAmelCase__ : str ) -> Tuple: lowercase_ : Tuple = a.name lowercase_ : Tuple = b.name lowercase_ : Any ...
21
0
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _snake_case = logging.get_logger(__name__) class _snake_case ( _lowercase ): def __init__( self: int , *__lowerCamelCase: Tuple , **__lowerCamelCase: Optional[...
157
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import T...
157
1
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging lowe...
353
"""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, TableTransfor...
215
0
"""simple docstring""" from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __UpperCamelCase ( a__ ...
105
'''simple docstring''' def a__ ( a__ , a__ ): """simple docstring""" _enforce_args(a__ , a__ ) if n == 0: return 0 __SCREAMING_SNAKE_CASE = float("""-inf""" ) for i in range(1 , n + 1 ): __SCREAMING_SN...
267
0
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def snake_case (__lowercase , __lowercase=False ) -> str: '''simple docstring''' _snake_case : int = OmegaConf.load(__lowercase ) if display: ...
284
import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class lowercase_ ( __snake_case ): _lowerCamelCase = 'M-CLIP' def __init__( self , lowercase_=1_024 , lowercase_=768 , **lowercase_ ): _snake_case ...
284
1
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class A__ ( lowerCAmelCase__ , unittest.TestCase ): lower...
325
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass...
325
1
'''simple docstring''' 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...
365
'''simple docstring''' import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast UpperCAmelCase : List[str] = datasets.utils.logging.get_logger(__name__) @...
331
0
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transforme...
106
"""simple docstring""" import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel __UpperCamelCase : int ...
106
1
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class UpperCamelCase ( ctypes.Structure ): """simple docstring""" # _fields is a specific attr expected by ctypes ...
336
"""simple docstring""" import re from filelock import FileLock try: import nltk UpperCAmelCase: List[str] = True except (ImportError, ModuleNotFoundError): UpperCAmelCase: int = False if NLTK_AVAILABLE: with FileLock(""".lock""") as lock: nltk.download("""...
336
1
"""simple docstring""" import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_com...
102
'''simple docstring''' def UpperCamelCase_ ( A__ : str , A__ : list[str] ): '''simple docstring''' lowerCAmelCase_ : Dict = """""" for word_or_phrase in separated: if not isinstance(A__ , A__ ): raise Exception("...
120
0
def __a ( lowerCAmelCase_ : int = 1_00_00_00 ) -> int: '''simple docstring''' UpperCAmelCase_= [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 ...
277
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __a ( lowerCAmelCase_ : Optional[int] ) -> List[Any]: '''simple docstring''' UpperCAmelCase_= [ """decoder.version"...
277
1
import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( "files" , [ ["full:README.md", "dataset_infos.json"], ["empty:README.md", "dataset_info...
283
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def lowercase_( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' if "model" in orig_key: lowerCamelCase : Dict = orig_key.replace("model." , "" ) if "norm1" in orig_key: ...
283
1
"""simple docstring""" from __future__ import annotations import math def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3...
248
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : Dict = logging.get_logger(__name__) lowerCAmelCase_ : List[str] = { '''microsoft/unispeech-large-1500h-cv''': (...
248
1
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtract...
255
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class a__ ( unittest.TestCase ): def lowercase ( se...
255
1
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": UpperCamelCase = argparse.ArgumentParser( description=( """Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned""" """ Disti...
65
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_available, ) from . import BaseT...
65
1
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class lowerCamelCase__ : def __init__(self , UpperCAmelCase , UpperCAmelCase=sys....
5
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class _lowerCamelCase( unittest.TestCase ): lowercase_ : Dict = JukeboxTokenizer lowercase_ : Dict = { """artist""": """Zac Brown Band""", """ge...
21
0
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowerCamelCase__ = TypeVar("""T""") class A__ ( Generic[T] ): def __init__( self : List[Any] , a : list[T] , a : C...
307
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIG...
307
1
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __SCREAMING_SNAKE_CASE ( unittest.TestCase ): def __magic_name__ ( self : List[Any] ) -> Tuple: SCREAMING_SNAKE_CASE__ : st...
152
'''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 ...
215
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCamelCase__ = { """configuration_longt5""": ["""LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LongT5Config""", """LongT5OnnxConfig"""], } try: if no...
364
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> str: stooge(SCREAMING_SNAKE_CASE_ , 0 , len(SCREAMING_SNAKE_CASE_ ) - 1 ) return arr def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> Dict: ...
307
0
import os from datetime import datetime as dt from github import Github _snake_case : int = [ 'good first issue', 'feature request', 'wip', ] def a_ ( ): __lowerCAmelCase = Github(os.environ['GITHUB_TOKEN'] ) __lowerCAmelCase = g.get_repo('huggingface/acceler...
284
def a_ ( lowerCAmelCase_ : int ): if number < 0: raise ValueError('number must not be negative' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
284
1
def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : list[int] , __UpperCamelCase : list[int] , __UpperCamelCase : int ) -> Dict: """simple docstring""" return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(...
360
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_utils ...
204
0
def a__ ( A_ = 10**9 ): '''simple docstring''' __magic_name__ = 1 __magic_name__ = 2 __magic_name__ = 0 __magic_name__ = 0 __magic_name__ = 0 while perimeter <= max_perimeter: perimeter...
88
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''t5-small''': '''https://huggingface.co/t...
268
0
from numpy import exp, pi, sqrt def UpperCamelCase_( _snake_case : int , _snake_case : float = 0.0 , _snake_case : float = 1.0 ): """simple docstring""" return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ...
370
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMix...
308
0
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class __UpperCAmelCase ( ctypes.Structure ): # _fields is a specific attr expected by ctypes UpperCamelCase = [("""size...
336
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowerCamelCase : Tuple = { "configuration_encodec": [ "ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP", "EncodecConfig", ], "feature_extractio...
336
1
import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def _snake_case( SCREAMING_SNAKE_CA...
282
from __future__ import annotations from typing import Any def _snake_case( SCREAMING_SNAKE_CASE__ : list ) -> int: '''simple docstring''' if not postfix_notation: return 0 A__ = {'+', '-', '*', '/'} A__ = [...
282
1
def lowercase_ (A : Optional[int] ): snake_case__ : str = len(A ) while cur > 1: # Find the maximum number in arr snake_case__ : Dict = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi snake_c...
277
from collections import deque from .hash_table import HashTable class snake_case__ ( lowerCAmelCase_ ): """simple docstring""" def __init__( self : Optional[Any], *_snake_case : Optional[Any], **_snake_case : List[Any] ) ->Optional[int]: super...
277
1
"""simple docstring""" import re def UpperCAmelCase ( a_ ) -> bool: """simple docstring""" __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(a_ , a_ ) ) if __na...
351
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def UpperCAmelCase ( a_ ) -> None: """simple docstring""" __A , __A = analyze_text(a_ ) __A = list(" " + ascii_...
124
0
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet impor...
248
from typing import Any class A__: """simple docstring""" def __init__( self , _lowercase ) -> List[str]: a_ : List[str] = data a_ : Optional[int] = None def __repr__( self ) -> str: return F'''Node({self...
248
1
'''simple docstring''' import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase : ...
352
'''simple docstring''' import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def lowerCAmelCase_ ( snake_ca...
311
0
import math def lowerCAmelCase_ ( __A ) -> bool: '''simple docstring''' return math.sqrt(__A ) * math.sqrt(__A ) == num def lowerCAmelCase_ ( __A ) -> bool: '''simple docstring''' UpperC...
65
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 patch import pya...
65
1
import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, r...
362
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _lowerCAmelCase : int = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailab...
308
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_d...
307
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class __SCREAMING_SNAKE_CASE( ctypes.Structure ): # _fields is a specific attr expected by ctypes _Uppe...
307
1
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_camembert i...
102
import math def _a ( SCREAMING_SNAKE_CASE_ : int ): 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 r...
102
1
"""simple docstring""" import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version __UpperCAmelCase = version.parse(importlib_metadata.version('nltk')) if NLTK_VERSION >= version.Version('3.6.4'): from nltk impo...
84
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import...
307
0
'''simple docstring''' import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging __A : List[Any] = logging.get_logger(__name__) def UpperCAmelCase ( lowerCamelCa...
8
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.ut...
8
1
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def __lowerCAmelCase ( a__ ) -> Tuple: __a ...
6
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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, ...
204
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : str = logging.get_logger(__name__) UpperCAmelCase_ : List[Any] = { 'facebook/dpr-ctx_encoder-single-nq-base': ( 'https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/re...
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
"""simple docstring""" lowerCamelCase__ = { """A""": """.-""", """B""": """-...""", """C""": """-.-.""", """D""": """-..""", """E""": """.""", """F""": """..-.""", """G""": """--.""", """H""": """....""", """I""": """..""", """J""": """.---""", """K""": """-.-""", """L""": """.-..""", """M""": "...
86
import os def snake_case( __magic_name__ = "input.txt" ) -> int: '''simple docstring''' with open(os.path.join(os.path.dirname(__magic_name__ ) , __magic_name__ ) ) as input_file: lowercase : Any = [ [int(...
308
0
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_...
0
'''simple docstring''' from __future__ import annotations A__ : str = '''Muhammad Umer Farooq''' A__ : int = '''MIT''' A__ : Optional[int] = '''1.0.0''' A__ : List[Any] = '''Muhammad Umer Farooq''' A__ : Optional[Any] = '''contact@muhammadumerfa...
0
1
from __future__ import annotations def a_ ( __lowercase : list[int] , __lowercase : list[int] , __lowercase : list[int] , __lowercase : list[list[str]] , __lowercase : int , ) -> None: _snake_case = len(__lowercase ) # If row is...
282
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel _lowerCamelCase : List[Any] = HfApi() _lowerCamelCase : Dict = {} # fmt: off _lowerCamelCase : List[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0...
282
1
"""simple docstring""" import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.util...
296
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ = { '''configuration_llama''': ['''LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP...
296
1
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''google/umt5-small''': '''https:...
108
from typing import List from .keymap import KEYMAP, get_character def SCREAMING_SNAKE_CASE__ ( lowercase ) -> Tuple: def decorator(lowercase ): snake_case : Tuple = getattr(lowercase ,"""handle_key""" ,[] ) handle += [key] setattr(lo...
124
0
'''simple docstring''' import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jn...
371
'''simple docstring''' from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer UpperCamelCase__ = logging.get_l...
299
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { 'facebook/vit-mae-base': 'https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json', # See all ViT MAE models at https://huggi...
24
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class UpperCamelCase__ ( unittest.TestCase )...
311
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase : Union[str, Any] = logging.get_logg...
351
"""simple docstring""" import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, Rober...
168
0
"""simple docstring""" from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig lowerCamelCase_ = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-la...
268
"""simple docstring""" 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, log...
268
1
"""simple docstring""" def snake_case ( A__ ): if number > 0: raise ValueError("input must be a negative integer" ) UpperCAmelCase_ : Union[str, Any] = len(bin(A__ )[3:] ) UpperCAmelCase_ : Union[str, Any] = bin(abs(A__ ) - (1 <...
253
"""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, ...
253
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE : List[str] = { """configuration_time_series_transformer""": [ """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
102
"""simple docstring""" from math import factorial, radians def lowercase ( _snake_case : float , _snake_case : int = 18 , _snake_case : int = 10 ) ->float: """simple docstring""" __snake_case : Any = angle_in_degrees - ((angle_in...
102
1
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def _a ...
355
from __future__ import annotations snake_case__ : Dict = [True] * 1000001 snake_case__ : int = 2 while i * i <= 1000000: if seive[i]: for j in range(i * i, 1000001, i): snake_case__ : str = Fa...
250
0
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging lowerCAmelCase_ = logging.get_logger(__name__) def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMIN...
8
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase_ = {'''configuration_opt''': ['''OPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
8
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer lowerCAmelCase : List[str] ...
168
"""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 transformers.testing_uti...
168
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __A : Dict = { "configuration_data2vec_audio": ["DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP", "Data2VecAudio...
120
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
120
1
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_proce...
185
import json import pathlib import unittest import numpy as np 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 import ImageProcessingSavingTestMixin, prepare_image_inputs if is_t...
185
1
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_availa...
0
from __future__ import annotations UpperCAmelCase__ = "Muhammad Umer Farooq" UpperCAmelCase__ = "MIT" UpperCAmelCase__ = "1.0.0" UpperCAmelCase__ = "Muhammad Umer Farooq" UpperCAmelCase__ = "contact@muhammadumerfarooq.me" UpperCAmelCase__ = "Alpha" impo...
0
1
import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def __lowerCamelCase ( snake_case__ ,snake_case__ ,snake_case__ ,snake_case__=5 ) -> Dict: """simple docstring""" assert masked_input.count("""<mask>""" ) == 1 _S...
351
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask ...
125
0