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''' from __future__ import annotations def __lowercase ( __lowercase ) -> int: '''simple docstring''' if not nums: return 0 _A = nums[0] _A = 0 for num in nums[1:]: _A , _A = ( ...
79
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import Tensor...
157
0
from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf import PTtoTFCommand f...
359
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : List[Any] = { """configuration_trajectory_transformer""": [ """TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TrajectoryTran...
45
0
def _a ( UpperCamelCase_ : int , UpperCamelCase_ : int , UpperCamelCase_ : int ) -> Optional[Any]: """simple docstring""" lowerCAmelCase__ = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for...
340
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case =logging.get_logger(__name__) __snake_case ={ """facebook/s2t-wav2vec2-large-en-de""": ( """https://huggingface.co/facebook/s2t-wav2vec2-large-en-d...
4
0
def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase): if height >= 1: move_tower(height - 1 , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase) move_disk(_UpperCAmelCase , _UpperCAmelC...
368
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 import write_b...
327
0
'''simple docstring''' class lowercase__ : '''simple docstring''' def __init__( self , __snake_case = "" , __snake_case = False ): # Mapping from the first character of the prefix of the node _SCREAMING_SNAKE_CASE : dict[str, RadixNode] ...
200
'''simple docstring''' from sklearn.metrics import fa_score import datasets UpperCAmelCase_ : Optional[int] = '\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n' UpperCAmelCase_ : Tuple...
200
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 if is_torch_available(): import torch if is_vision_...
352
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ =logging.get_logger(__name__) UpperCamelCase__ ={ 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.json', } class lowerCAmelCase__( __lowercase ...
325
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__UpperCAmelCase ) class _A ( __UpperCAmelCase ): # `task` is not a ClassVar since we want it to be part of the `asdict` output ...
49
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import...
124
0
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_available from ...test_confi...
351
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def lowerCAmelCase_ ( __a , __a , __a ) -> List[str]: """simple docstring""" lowerCamelCase__: int =("dense.weight", "attention.self.query"...
273
0
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def lowerCAmelCase_ ( __lowerCAmelCase )-> int: '''simple docstring'''...
348
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineTest...
348
1
"""simple docstring""" import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel UpperCamelCase = HfApi() UpperCamelCase = {} # fmt: off UpperCamelCase = torch.tensor([ -0.7_515, -1.6_883, 0.2_420, 0.0_300, 0...
360
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 .tokeniza...
125
0
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ ( _UpperCAmelCase ): """simple docstring""" A_ : List[str] = str(_UpperCAmelCase ) return len(_UpperCAmelCase ) == 9 and set(_UpperCAmelCase ) == set('123456789' ...
286
"""simple docstring""" from copy import deepcopy class _UpperCAmelCase : '''simple docstring''' def __init__( self , snake_case_ = None , snake_case_ = None ): """simple docstring""" if arr is None and size is not None: A_ : Union[st...
286
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a = { '''configuration_git''': ['''GIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GitConfig''', '''GitVisionConfig'''], '''processing_git''': ['''GitProces...
271
"""simple docstring""" from collections import deque class lowercase_ : '''simple docstring''' def __init__( self : int , _UpperCAmelCase : str , _UpperCAmelCase : int , _UpperCAmelCase : int ): _A = process_name # process name _A = ...
271
1
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_se...
71
import torch from diffusers import StableDiffusionPipeline lowerCamelCase_ = '''path-to-your-trained-model''' lowerCamelCase_ = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to('''cuda''') lowerCamelCase_ = '''A photo of sks dog in a bucket''' lowerCamel...
244
0
import math class __lowercase : """simple docstring""" def __init__( self , A=0 ) -> List[Any]: # a graph with Node 0,1,...,N-1 '''simple docstring''' lowerCamelCase = n lowerCamelCase = [ [math.inf for j in...
66
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) UpperCAmelCase : Optional[int] = logging.getLogger(__...
66
1
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow lowercase : List[Any] = logging.getLogger() @unittest.skip('''Temporarily disable t...
99
def A_ ( A__ , A__ ) -> str: if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) a__ : List[str] = str(bin(A__ ) )[2:] # remove the leading "0b" a__ : Optional[int] = str(bin(A__ ) )[2:] # remove the lea...
99
1
"""simple docstring""" import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder _SCREAMING_SNAKE_CASE : List[Any] = """__DUMMY_TRANSFORMERS_USER__""" _SCREAMING_SNAKE_CASE : Any = """Dummy ...
157
"""simple docstring""" import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin fr...
157
1
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast from ..utils....
43
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device ...
316
0
def UpperCamelCase_( _snake_case : list ): """simple docstring""" if not grid or not grid[0]: raise TypeError('The grid does not contain the appropriate information' ) for cell_n in range(1 , len(grid[0] ) ): grid[0][cell_n] += grid[0...
308
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokenizerFa...
308
1
'''simple docstring''' import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common...
254
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _lowerCAmelCase ( unittest.TestCase ,lowercase ): """simple docstring""" def _lowercase ( self : List[Any] ): __lowercase = ...
17
0
'''simple docstring''' from __future__ import annotations import time import numpy as np __lowercase: str = [8, 5, 9, 7] __lowercase: Optional[int] = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] __lowercase: Dict...
360
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput cl...
31
0
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _snake_case ( __snake_case ): '''simple docstring''' A__ : List[str] = ["image_processor", "tokenizer"] A__ : Optional[Any] = "AutoImageProcessor" ...
345
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging UpperC...
345
1
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
355
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __A : Tuple = {'configuration_glpn': ['GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GLPNConfig']} try: if not is_vision_available(): raise OptionalDependencyNotAvailable...
49
0
"""simple docstring""" import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": lowerCamelCase_ = "%20".join(argv[1:]) if len(argv) > 1 else quote(str(in...
191
"""simple docstring""" import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y ...
191
1
'''simple docstring''' 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 cac...
156
'''simple docstring''' import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device fr...
156
1
import numpy as np def a__ ( snake_case , snake_case ): """simple docstring""" return np.where(vector > 0 , lowerCAmelCase__ , (alpha * (np.exp(lowerCAmelCase__ ) - 1)) ) if __name__ == "__main__": import doctest doctest.testmod()
303
"""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 __lowerCAmelCase ( un...
45
0
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( A_ , A_ ): return number | (1 << position) def __SCREAMING_SNAKE_CASE ( A_ , A_ ): return number & ~(1 << position) def __SCREAMING_SNAKE_CASE ( A_ , A_ ): return number ^ (1 << position) def __SCREAMIN...
74
"""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_squeezebert import SqueezeBertTokenizer __UpperCamelCase : Tuple = loggi...
74
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 snake_case__ : ...
60
"""simple docstring""" import random def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> bool: '''simple docstring''' lowercase_ = num - 1 lowercase_ = 0 while s % 2 == 0: lowercase_ = s // 2 t += 1 for _ in range(5 ...
136
0
"""simple docstring""" 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 : Optional[Any] = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Union[str,...
371
"""simple docstring""" import torch from diffusers import StableDiffusionPipeline _SCREAMING_SNAKE_CASE : Optional[int] = """path-to-your-trained-model""" _SCREAMING_SNAKE_CASE : Optional[Any] = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""") ...
157
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : List[Any] = logging.get_logger(__name__) lowerCamelCase : int = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class __lowerCAmelCase (lo...
2
import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json from tr...
325
0
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> Any: return 1 / (1 + np.exp(-z )) def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) ...
359
"""simple docstring""" SCREAMING_SNAKE_CASE = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] SCREAMING_SNAKE_CASE ...
230
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_...
51
"""simple docstring""" from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import ...
213
0
import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset from transformers import Au...
362
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 lowerCAmelCase_ = get_tests_dir('''fixtures/test_sentencepiece_with_bytefallback.mod...
279
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case : Optional[int] = { "configuration_be...
94
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case_ : Union[str, Any] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix...
125
0
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformer...
64
"""simple docstring""" import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): ...
64
1
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCamelCase__) class _a ( UpperCamelCase__): """simple docstring""" UpperCamelCase__ = fie...
149
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class _UpperCamelCase ( A ): ...
166
0
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common...
363
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class UpperCAmelCase_ ( __lowercase ): def __init__( self : Tuple ) -> Tuple: # test for the above condition self.test() def __UpperC...
55
0
"""simple docstring""" def A_ ( _lowercase = 1000 ): '''simple docstring''' snake_case_ :List[str] = 3 snake_case_ :List[Any] = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: r...
66
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics ...
66
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available snake_case : str = { '''configuration_nezha''': ['''NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NezhaConfig'''], } try: if not is_torch_ava...
362
from __future__ import annotations def __lowercase ( __lowerCAmelCase : List[Any] , __lowerCAmelCase : Optional[Any] , __lowerCAmelCase : str , __lowerCAmelCase : List[str] ): # noqa: E741 while r - l > 1: a__ = (l + r...
109
0
"""simple docstring""" 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 , u...
74
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer if TYPE_CHECKIN...
133
0
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> bool: return str(SCREAMING_SNAKE_CASE_ ) == str(SCREAMING_SNAKE_CASE_ )[::-1] def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> int: return int(SCREAMING_SNAKE_CASE_ ) + int(str(SCREAMING_SNAKE_CASE_ )[::-1] ...
307
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class A__ ( __magic_name__ ): lowercase ...
307
1
def snake_case( __magic_name__ ) -> int: '''simple docstring''' if not grid or not grid[0]: raise TypeError('''The grid does not contain the appropriate information''' ) for cell_n in range(1 , len(grid[0] ) ): grid[0][cell_n] ...
308
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
1
__UpperCAmelCase = { """Pillow""": """Pillow<10.0.0""", """accelerate""": """accelerate>=0.20.3""", """av""": """av==9.2.0""", """beautifulsoup4""": """beautifulsoup4""", """black""": """black~=23.1""", """codecarbon""": """codecarbon==1.2.0""", """cookiecutter""": """cookiecutter...
355
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 ...tes...
139
0
import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import disable_progress_bar, enable_...
195
'''simple docstring''' import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from ....
31
0
'''simple docstring''' lowercase__ = [ "Audio", "Array2D", "Array3D", "Array4D", "Array5D", "ClassLabel", "Features", "Sequence", "Value", "Image", "Translation", "TranslationVariableLanguages", ] from .audio import Audio from .features import Ar...
83
'''simple docstring''' import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device ...
83
1
"""simple docstring""" import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def lowercase ( _SCREAMING_SNAKE_CASE...
260
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def __snake_case ( ): __a , __a = 9, 14 # noqa: F841 __a = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, ...
49
0
from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMix...
293
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase : str = logging.get_logger(__name__) __UpperCAmelCase : int = { "RWKV/rwkv-4-169m-pile": "https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json", "RWKV/rwkv-...
293
1
"""simple docstring""" from math import isclose, sqrt def lowercase (SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float ) -> tuple[float, float, float]: SCREAMING_SNAKE_CASE = point_y / 4 / point_x ...
113
"""simple docstring""" __UpperCamelCase = frozenset( [ '''prompt''', '''height''', '''width''', '''guidance_scale''', '''negative_prompt''', '''prompt_embeds''', '''negative_prompt_embeds''', '''cross_attention_kwargs'...
113
1
'''simple docstring''' import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation...
358
'''simple docstring''' from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ ...
83
0
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller _lowercase = 3 def _snake_case ( snake_case__ : int ): print('Generating primitive root of p' ) while True: A = random.randrange(...
74
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor _lowercase = logging.get_logger(__name__) class lowerCAmelCase_ ( _lowercase ): '''simple docstring''' def __init__( self : Union[str, ...
74
1
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py SCREAMING_SNAKE_CASE :Dict = """src/transformers""" ...
358
from ...processing_utils import ProcessorMixin class __magic_name__ ( snake_case ): UpperCamelCase_ :str = """SpeechT5FeatureExtractor""" UpperCamelCase_ :Optional[int] = """SpeechT5Tokenizer""" def __init__( self , ...
60
0
'''simple docstring''' __SCREAMING_SNAKE_CASE : int = """Alexander Joslin""" import operator as op from .stack import Stack def UpperCamelCase_ ( _UpperCAmelCase : str ) -> int: """simple docstring""" _UpperCAmelCase : Tuple = {"...
31
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = ...
166
0
'''simple docstring''' import math from numpy import inf from scipy.integrate import quad def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : float ): '''simple docstring''' if num <= 0: raise ValueError("""math domain error""" ) return quad(SCREAMING_SNAKE_CASE__ , 0 , SCREAMIN...
61
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { 'google/pix2struct-textcaps-base': ( 'https://huggingface.co/goog...
61
1
'''simple docstring''' 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...
250
from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, is_v...
230
0
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pi...
94
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __snake_case : Optional[int] ={ 'configuration_vision_text_dual_encoder': ['VisionTextDualEncoderConfig'], 'processing_vi...
94
1
import re from filelock import FileLock try: import nltk lowercase__ =True except (ImportError, ModuleNotFoundError): lowercase__ =False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) def __UpperCamelCase ( lowerC...
216
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_dimension_format, ) from ...
216
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake...
124
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) SCREAMING_SNAKE_CASE :int = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not is_torch_avai...
124
1
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (snake_case__ : list[int] , snake_case__ : int ): """simple docstring""" if len(snake_case__ ) < k or k < 0: raise ValueError("""Invalid Input""" ) _snake_case ...
64
"""simple docstring""" import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaV...
64
1
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech...
309
"""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 , num_examples...
309
1
"""simple docstring""" from ... import PretrainedConfig snake_case_ = { """sijunhe/nezha-cn-base""": """https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json""", } class A_ ( SCREAMING_SNAKE_CASE_ ): """simple docstring""" ...
78
'''simple docstring''' import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCase...
55
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
365
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def _UpperCamelCase (a__ :Dict[str, torch.Tensor] ): """simple docstring""" UpperCamelCase__ = [] ...
87
0
import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json from...
345
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): ...
166
0
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also ...
221
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __lowerCamelCase ( UpperCamelCase__ ): """simple docstring""" snake_case__ = "Speech2TextFeatureExtractor" snake_case__ = "Speech2TextTokenizer" ...
221
1
'''simple docstring''' import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn #...
83
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy snake_case_ : Dict = logging.get_logger(__...
83
1
def SCREAMING_SNAKE_CASE_ ( __A : str , __A : str ) -> bool: """simple docstring""" a_ : Any = len(__A ) a_ : Tuple = len(__A ) a_ : Any = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] a_ ...
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""" 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, ...
102
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't ...
102
1
"""simple docstring""" from __future__ import annotations def _A ( lowercase , lowercase , lowercase ): """simple docstring""" if (voltage, current, resistance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0''' ) if re...
215
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING lowerCamelCase_ : int = logging.get_logger(__name__) class __A ( _SCREAMING_...
215
1
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accele...
152
'''simple docstring''' from __future__ import annotations def _a( UpperCamelCase__ : list[int] ): '''simple docstring''' if not nums: return 0 SCREAMING_SNAKE_CASE__ : Dict =nums[0] SCREAMING_SNAKE_CAS...
152
1
'''simple docstring''' import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class ...
274
'''simple docstring''' import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datas...
274
1
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE ) ->list: """simple docstring""" if len(_SCREAMING_SNAKE_CASE ) <= 1: return [tuple(_SCREAMING_SNAKE_CASE )] lowerCAmelCase__ :Optional[Any] = [] def generate(_SCREAMING_SNAKE_CASE , _SCREAMING_SNA...
293
"""simple docstring""" import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->...
293
1
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path _lowerCAmelCase = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) _lowerCAmelCase = [ord(letter) for letter i...
359
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils ...
98
0
"""simple docstring""" import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import skle...
144
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels lowerCAmelCase__ = object() # For specifying empty leaf dict `{}` lowerCAmelCase__ = object() def _UpperCAmelCase (Upp...
11
0
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ : Optional[int] = logging.get_logger(__name__) UpperCAmelCase__ : int = ...
369
def lowerCamelCase__ ( a = 10**9 ) -> int: _A: Dict = 1 _A: Union[str, Any] = 2 _A: List[str] = 0 _A: List[Any] = 0 _A: int = 0 while perimeter <= max_perimeter: perimeters_sum += perimeter prev_value += 2 * value value +...
301
0
"""simple docstring""" import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_x...
78
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/resolve/main/config.json""", } ...
78
1
"""simple docstring""" import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increa...
351
"""simple docstring""" from collections.abc import Generator from math import sin def UpperCAmelCase__ (snake_case__ : bytes ): """simple docstring""" if len(snake_case__ ) != 32: raise ValueError("""Input must be of length 32""" ) _snake_case : Optional[int] ...
132
0
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @...
283
def lowercase_( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' if divisor % 5 == 0 or divisor % 2 == 0: return 0 lowerCamelCase : List[Any] = 1 lowerCamelCase : Union[str, Any] = 1 while repunit: lowerCamelCase : Union[str, Any] = (10 * repunit + 1)...
283
1
"""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 __lowerCamelCase ( __U...
351
"""simple docstring""" import argparse import os import re lowercase__ = """src/transformers""" # Pattern that looks at the indentation in a line. lowercase__ = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. lowercase__ = re.compile(r"""^\s*\...
161
0
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets SCREAMING_SNAKE_CASE = "\\n@inproceedings{snover-etal-2006-study,\n title = \"A Study of Translation Edit Rate with Targeted Human Annotation\",\n author = \"Snover, Matthew ...
247
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
239
0
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class A ( __snake_case ): def _...
311
'''simple docstring''' from __future__ import annotations def lowerCAmelCase_ ( snake_case__ ): '''simple docstring''' A : List[str] = 2 A : Dict = [] while i * i <= n: if n % i: i += 1 else:...
311
1
import os import pytest from transformers.dynamic_module_utils import get_imports __lowerCAmelCase : Any = "\nimport os\n" __lowerCAmelCase : str = "\ndef foo():\n import os\n return False\n" __lowerCAmelCase : str = "\ndef foo():\n def bar():\n ...
156
def UpperCAmelCase_ ( __lowerCAmelCase ) -> int: if not isinstance(__lowerCAmelCase , __lowerCAmelCase ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) __lowercase : List[str] = 0 while number: # This way we arrive at n...
156
1
'''simple docstring''' import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device f...
357
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCamelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDep...
334
0
from ...configuration_utils import PretrainedConfig class snake_case_ (lowerCamelCase_ ): UpperCAmelCase__ : List[Any] = '''bert-generation''' def __init__( self :Any ,__snake_case :Optional[Any]=5_03_58 ,__snake_case :Optional[Any]=10_24 ,__snake_cas...
240
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, slo...
240
1
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common i...
335
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _UpperCamelCase = Lock() def UpperCamelCase_( snake_case__: Optional[Any] , snake_case__: Optional[int] , snake_case__: Tuple , snake_case__: Tuple ...
335
1
'''simple docstring''' from ...processing_utils import ProcessorMixin class UpperCamelCase_ ( __magic_name__ ): lowercase = 'SpeechT5FeatureExtractor' lowercase = 'SpeechT5Tokenizer' def __init__( self , A , A ) -> Tuple: super().__init__(A , A ) ...
265
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 #...
265
1
"""simple docstring""" import math import flax.linen as nn import jax.numpy as jnp def snake_case__ ( __lowerCamelCase : jnp.ndarray , __lowerCamelCase : int , __lowerCamelCase : float = 1 , __lowerCamelCase : float = 1 , __lowerCamelCase :...
272
"""simple docstring""" from ...processing_utils import ProcessorMixin class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): '''simple docstring''' _a = 'SpeechT5FeatureExtractor' _a = 'SpeechT5Tokenizer' def __init__( self : D...
272
1
"""simple docstring""" def lowercase ( A_ = 1_000 )-> int: '''simple docstring''' a : List[str] = 3 a : List[str] = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: ...
40
'''simple docstring''' import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=loggi...
311
0
# Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
364
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration _lowercase: List[Any] = { "tiny.en": "https://openaipublic.azureedge.net/main/whisper/models/d3dd...
71
0
'''simple docstring''' from __future__ import annotations from collections.abc import Sequence from typing import Literal def _UpperCamelCase ( __A , __A ) -> int: '''simple docstring''' UpperCamelCase__ = list(__A ) UpperCamelCase__ ...
80
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion impo...
85
0
'''simple docstring''' import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py lowerCamelCase_ = '''src/tr...
174
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''camembert-base''': ...
174
1
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common i...
328
def A_ ( snake_case : int ) -> None: '''simple docstring''' __UpperCamelCase = generate_pascal_triangle(snake_case ) for row_idx in range(snake_case ): # Print left spaces for _ in range(num_rows - row_idx - 1 )...
328
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, ...
175
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers...
175
1
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase : int , _lowerCamelCase : int ) -> str: if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) lowerCamelCase_ = str(bin(_lowerCamelCase ) ...
183
"""simple docstring""" from math import pow, sqrt def lowerCamelCase__ ( *_lowerCamelCase : float ) -> bool: lowerCamelCase_ = len(_lowerCamelCase ) > 0 and all(value > 0.0 for value in values ) return result def ...
183
1
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets UpperCAmelCase_ : str = """\ @inproceedings{snover-etal-2006-study, title = \"A Study of Translation Edit Rate with Targeted Human Annotation\", author = \...
318
"""simple docstring""" 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, ...
318
1
"""simple docstring""" from __future__ import annotations import bisect def lowerCAmelCase__ ( _UpperCamelCase : list[int] , _UpperCamelCase : int , _UpperCamelCase : int = 0 , _UpperCamelCase : int = -1 ) -> int: """simple docstring""" ...
150
"""simple docstring""" import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient SCREAMING_SNAKE_CASE__ = WebClient(token=os.environ["CI_SLACK_BOT_TOKEN"]) def ...
150
1
'''simple docstring''' import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor cl...
365
'''simple docstring''' from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ...
9
0
def a( ) -> int: """simple docstring""" a = 0 for i in range(1 , 1001 ): total += i**i return str(A )[-10:] if __name__ == "__main__": print(solution())
227
# limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class _lowercase ( lowerCAmelCase ): """simple docstring""" def __init__(self , lowerCamelCase_ , lowerCamelCase_ ): ""...
227
1
"""simple docstring""" import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class lowercase__ ( unittest.TestCase ): '''simple docstring''' def lowerc...
356
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licen...
241
0
'''simple docstring''' from collections.abc import Sequence def UpperCAmelCase__ ( UpperCAmelCase__ = None ) -> int: if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) A_ = nums[0] for i in range(1, len(UpperCAmelC...
162
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { '''studio-ousia/luke-base''': '''https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json''', ...
162
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A : List[str] ={"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"...
352
'''simple docstring''' 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 HfArgumentPar...
129
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 __magic_name__ = namedtuple( "_TestCommandArgs", [...
100
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json', # See all ViT MSN models at https://hug...
24
0
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
10
def UpperCamelCase ( __lowerCamelCase : str ): snake_case : Union[str, Any] = 0 # if input_string is "aba" than new_input_string become "a|b|a" snake_case : Tuple = "" snake_case : Optional[int] = "" # ap...
10
1