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
from typing import Dict from .base import GenericTensor, Pipeline class _A ( __magic_name__): def UpperCAmelCase ( self , _SCREAMING_SNAKE_CASE=None , _SCREAMING_SNAKE_CASE=None , _SCREAMING_SNAKE_CASE=None , **_SCREAMING_SNAKE_CASE ): "...
253
import math def A_ ( a , a = 0 , a = 0 ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[Any] = end or len(a ) for i in range(a , a ): SCREAMING_SNAKE_CASE_ : List[Any] = i SCREAMING_SNA...
253
1
"""simple docstring""" from typing import TYPE_CHECKING from ..utils import _LazyModule SCREAMING_SNAKE_CASE__ = { "config": [ "EXTERNAL_DATA_FORMAT_SIZE_LIMIT", "OnnxConfig", "OnnxConfigWithPast", "OnnxSeq2SeqConfigWithPast", "PatchingSpec", ], ...
149
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transform...
149
1
'''simple docstring''' import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_pr...
174
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, Stabl...
174
1
import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_checkpoint __A ...
355
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer __A = logging.get_logger(__name__) __A = {'''vocab_file''': '''vocab.json''', '''merges_file''': '''merges.t...
278
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 _UpperCAmelCase : List[Any] = logging.get_logger(__nam...
174
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_...
174
1
"""simple docstring""" from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configurati...
359
"""simple docstring""" import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu,...
182
0
"""simple docstring""" import os # Precomputes a list of the 100 first triangular numbers lowerCamelCase_ : List[str] = [int(0.5 * n * (n + 1)) for n in range(1, 1_01)] def UpperCAmelCase__ ( ): """simple docstring""" A_ : Union[str, Any] = os...
286
"""simple docstring""" import os def UpperCAmelCase__ ( ): """simple docstring""" A_ : Any = os.path.join(os.path.dirname(_UpperCAmelCase ) , 'num.txt' ) with open(_UpperCAmelCase ) as file_hand: return str(sum(int(_UpperCAmelCase ) for...
286
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator class __A : '''simple docstring''' def __init__( self : Any , UpperCAmelCase_ : int ) ->None: """simple docstring""" snake...
364
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def _a ( _SCREAMING_SNAKE_CASE = 8 ) -> str: snake_case_ = ascii_letters + digits + punctuation return "".join(secre...
233
0
import math def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : int) -> Any: '''simple docstring''' __UpperCamelCase : str = [True] * n __UpperCamelCase : List[str] = False __UpperCamelCase : Union[str, Any] = Fal...
232
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, ) fro...
240
0
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_torch class ...
171
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ComputeEnvironment, ...
171
1
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# lowercase__ : Union[str, Any] = [ # (stable-diffusion, HF Diffusers) ('''time_embed.0.weight''',...
187
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Optional[Any] = { '''configuration_rag''': ['''RagConfig'''], '''retrieval_rag''': ['''RagRetriever'''], ...
106
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Dict = { '''configuration_roc_bert''': ['''ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''RoCBertConfig'''], '''tokenization_...
206
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.ut...
206
1
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def __UpperCamelCase ( ) -> int: """simple docstring""" A , A : Optional[int] = 9, 14 # noqa: F841 A : Optional[int] = [ ...
116
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 SCREAMING_SNAKE_CASE_:List[Any] = """▁""" SCREAMING_SNAKE_CASE_:int = {"""vo...
116
1
def lowercase_ ( _lowerCamelCase: List[str] = 1000 ) -> Dict: '''simple docstring''' return sum(e for e in range(3 , _lowerCamelCase ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F"""{solution() = }""")
354
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils im...
64
0
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRC...
98
"""simple docstring""" import functools def a_ ( lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = len(lowerCamelCase ) UpperCAmelCase__ = len(lowerCamelCase ) @functools.cache def min_distance(lowerCamelCase , lo...
98
1
import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers.models.mbart.modeling_mbart imp...
51
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, flip_channel_order, get_resize_output_image_size, rescale, resize, to_channel_dimensi...
51
1
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_forma...
180
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_...
180
1
'''simple docstring''' import os import pytest from transformers.dynamic_module_utils import get_imports __UpperCamelCase = "\nimport os\n" __UpperCamelCase = "\ndef foo():\n import os\n return False\n" __UpperCamelCase = "\ndef foo():\n def bar...
367
'''simple docstring''' from __future__ import annotations def _a ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , ) -> None: """simple docstring""" __snake_case : int ...
13
0
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin class ...
159
import unittest from knapsack import greedy_knapsack as kp class __lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def lowerCAmelCase__ ( self : Any ) -> str: """simple docstring""" snake_case_ ...
159
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 A__ ( SCREAMING_SNAKE_CASE__) -> L...
293
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 OnnxPipeli...
293
1
def UpperCamelCase ( snake_case__ : list , snake_case__ : list ) -> float: _validate_point(lowerCAmelCase__ ) _validate_point(lowerCAmelCase__ ) if len(lowerCAmelCase__ ) != len(lowerCAmelCase__ ): raise ValueError('Both points must be in the same n-dimensional spa...
119
'''simple docstring''' import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class a ( _SCREAMING_SNAKE_CASE ): _lowerCAmelCase = (KDPMaDiscreteScheduler,) _lower...
168
0
import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from acc...
177
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()...
177
1
import unittest from transformers import DonutProcessor SCREAMING_SNAKE_CASE_ = """naver-clova-ix/donut-base""" class UpperCamelCase__ ( unittest.TestCase ): '''simple docstring''' def SCREAMING_SNAKE_CASE__ ( self : Optional[Any] ...
296
from argparse import ArgumentParser from .env import EnvironmentCommand def __lowercase ( ) -> Dict: '''simple docstring''' SCREAMING_SNAKE_CASE = ArgumentParser("""Diffusers CLI tool""" , usage="""diffusers-cli <command> [<args>]""" ) SCREAMING_...
296
1
"""simple docstring""" import unittest import numpy as np from transformers import DistilBertConfig, 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(): ...
149
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import Model...
149
1
"""simple docstring""" import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def A ( snake_case :List[str] , snake_...
316
"""simple docstring""" UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_93_44, "knot": 1.8_52, } UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_77_77_77_78, "mph": 0.6_21_37_11_92, "knot": 0.5_39_95_68_03, } def A ( ...
316
1
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): __UpperCAmelCase : Union[str, Any] = 0 # if input_string is "aba" than new_input_string become "a|b|a" __UpperCAmelCase : Any = "" __UpperCAmelCase : List[Any] = "" # app...
37
'''simple docstring''' # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
37
1
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def _A ( SCREAMING_SNAKE_CASE : dict ): ...
95
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_image_size...
43
0
"""simple docstring""" from timeit import timeit UpperCAmelCase = { '''MALAYALAM''': True, '''String''': False, '''rotor''': True, '''level''': True, '''A''': True, '''BB''': True, '''ABC''': False, '''amanaplanacanalpanama''': True, # "a man a plan a canal panama" } # ...
361
"""simple docstring""" def lowerCamelCase (a_ :int , a_ :int) -> int: while a != 0: lowercase , lowercase :Dict = b % a, a return b def lowerCamelCase (a_ :int , a_ :int) -> int: if gcd(a_ , a_) != 1:...
172
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor _lowerCamelCase : int = logging.get_logger(__name__) class lowercase ( __UpperCAmelCase): def __init__( self : ...
167
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _lowerCamelCase : Union[str, Any] = logging.get_logger(__name__) _lowerCamelCa...
167
1
import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavi...
223
def A__ ( lowerCamelCase , lowerCamelCase ) -> list: UpperCamelCase_: Optional[int] = word.split() def justify(lowerCamelCase , lowerCamelCase , lowerCamelCase ) -> str: UpperCamelCase_: Tuple = max_width - width UpperCamelCase_: ...
223
1
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from da...
26
def A_ ( _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: List[str] = [0] * len(_UpperCAmelCase ) SCREAMING_SNAKE_CASE_: List[Any] = [] SCREAMING_SNAKE_CASE_: str = [] SCREAMING_SNAKE_CASE_: List[str] = 0 for values in graph.values(): ...
13
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_...
92
'''simple docstring''' import logging import os from .state import PartialState class _snake_case ( logging.LoggerAdapter ): @staticmethod def lowerCAmelCase__ ( a__ ) -> Optional[Any]: '''simple docstring''' snake_case_ = Par...
92
1
'''simple docstring''' import flax.linen as nn import jax import jax.numpy as jnp class lowerCAmelCase__ ( nn.Module ): lowerCAmelCase : int lowerCAmelCase : jnp.dtype = jnp.floataa def lowerCAmelCase__ ( self : List[str] ...
234
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase = 50 ): _UpperCAmelCase : Tuple = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(...
234
1
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ : Optional[Any] = logging.get_logger(__name__) snake_case__ : Optional[Any] = {'openai-gpt': 'https://huggingface.co/openai-gpt/resolve/main/config.json'} ...
250
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
1
"""simple docstring""" import numpy as np from transformers import Pipeline def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : List[Any] ): '''simple docstring''' lowerCAmelCase = np.max(SCREAMING_SNAKE_CASE , axis=-1 , keepdims=SCR...
46
'''simple docstring''' import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available ...
168
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings UpperCAmelCase__ = r"\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the model outputs. Read the do...
290
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def A ( ) -> tuple[list[int], int]: '''simple docstring''' _UpperCAmelCase = [randint(-1_000 , 1_000 ) for i in range(10 )] _Up...
290
1
import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor from...
49
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # Initialise PyTorch model ...
49
1
"""simple docstring""" from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from acce...
369
"""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_ ( _lowerCAmelCase : Dict, _lowerCAmelCase : List[str], _lowerCAm...
153
0
'''simple docstring''' _lowerCAmelCase = { '''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''', '''c...
37
'''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_...
37
1
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.c...
9
'''simple docstring''' from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class a__ ( _...
9
1
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) a : Any = logging.getLogger() ...
114
import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion import Stable...
169
0
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Tuple = { 'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox/mvp/resolve/main/confi...
355
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : Tuple = {"configuration_vit_msn": ["VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMSNConfig"]} try: if not is_torch_avai...
264
0
'''simple docstring''' from ...processing_utils import ProcessorMixin class lowerCAmelCase_ ( lowercase__ ): __lowerCamelCase : Union[str, Any] = """SpeechT5FeatureExtractor""" __lowerCamelCase : Tuple = """SpeechT5Tokenizer""" def __init__( self...
158
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase :str = {'''configuration...
331
0
"""simple docstring""" def __lowercase ( _a ): if not numbers: return 0 if not isinstance(_a , (list, tuple) ) or not all( isinstance(_a , _a ) for number in numbers ): raise ValueError('''numbers must be an iterable of integers''' ) snake_case...
155
"""simple docstring""" import math import sys def __lowercase ( _a ): if number != int(_a ): raise ValueError('''the value of input must be a natural number''' ) if number < 0: raise ValueError('''the value of input must not be a negative number''' ) if number == ...
155
1
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 a_ = logging.get_logger(__name__) class ...
340
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased/resolve/main/config.json''', '''xlnet-large-cased''': '''https://huggingface.co/...
340
1
"""simple docstring""" import argparse import math import traceback import dateutil.parser as date_parser import requests def lowerCAmelCase__ ( UpperCamelCase__ ): '''simple docstring''' _a : List[str] = {} _a : List[str] = job["""star...
324
"""simple docstring""" import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_comm...
324
1
class lowercase__ : '''simple docstring''' def __init__( self, __magic_name__ ) -> None: """simple docstring""" UpperCamelCase__ : int = size UpperCamelCase__ : Union[str, Any] = [0] * si...
201
def lowerCAmelCase_ ( __UpperCAmelCase: int ) -> int: if not isinstance(__UpperCAmelCase , __UpperCAmelCase ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) UpperCamelCase__ : Optional[Any] = 0 whil...
201
1
'''simple docstring''' from __future__ import annotations from math import pi, sqrt def UpperCAmelCase_ ( __lowerCamelCase : float ,__lowerCamelCase : float ): if inductance <= 0: raise ValueError("Inductance cannot be 0 or negative" ) elif capacitance <= 0: ...
370
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class a_ ...
147
0
from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase = {"processing_wav2vec2_with_lm": ["Wav2Vec2ProcessorWithLM"]} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys lowercase = _LazyModule(__name__, globals...
178
import collections import importlib.util import os import re from pathlib import Path lowercase = "src/transformers" # Matches is_xxx_available() lowercase = re.compile(r"is\_([a-z_]*)_available()") # Catches a one-line _import_struct = {xxx} lowercase = re.compile(r"^_imp...
178
1
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () lowerCAmelCase__ : Optional[int] =np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function #...
118
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Dict =logging.get_logger(__name__) lowerCAmelCase__ : Optional[int] ={ '''asapp/sew-tiny-100k''': '''https://huggingface.co/asapp/sew-tiny-100k/resolve/m...
118
1
"""simple docstring""" import argparse from collections import defaultdict import yaml _UpperCamelCase : str = 'docs/source/en/_toctree.yml' def _SCREAMING_SNAKE_CASE ( __snake_case : List[Any] ): '''simple docstring''' lowercase = defaultdict(__snake_ca...
220
"""simple docstring""" import argparse import json from tqdm import tqdm def _SCREAMING_SNAKE_CASE ( ): '''simple docstring''' lowercase = argparse.ArgumentParser() # Required parameters parser.add_argument( '--src_path' , type=__snake_case , defaul...
220
1
"""simple docstring""" from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder _a : str = datasets.utils.logging.get_logger(__name__) class __A ( folder_based_builder.FolderBasedBuilderConfig ): ...
126
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Any = logging.get_logger(__name__) _a : Any = { 'uclanlp/visualbert-vqa': 'https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json', 'uclanlp/visualbert-vq...
126
1
import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation _...
9
def _UpperCamelCase ( lowercase__ , lowercase__ , lowercase__=False ): if isinstance(lowercase__ , lowercase__ ) and isinstance(lowercase__ , lowercase__ ): __SCREAMING_SNAKE_CASE : List[str] = len(set_a.intersectio...
9
1
'''simple docstring''' def __a ( _UpperCamelCase: int , _UpperCamelCase: int ) -> str: """simple docstring""" return "\n".join( F"""{number} * {i} = {number * i}""" for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": pri...
350
'''simple docstring''' from __future__ import annotations from typing import Any def __a ( _UpperCamelCase: list[Any] ) -> None: """simple docstring""" create_state_space_tree(_UpperCamelCase , [] , 0 ) def __a ( _UpperCamelCase: ...
142
0
"""simple docstring""" from __future__ import annotations from random import choice def __lowercase ( _a ): return choice(_lowerCAmelCase ) def __lowercase ( _a , _a ): snake_case_ : Any = random_pivot(_lowerCAmelCase ) # partition based on pivot # li...
264
def _lowerCAmelCase (_lowerCAmelCase): UpperCamelCase_ = len(_lowerCAmelCase) UpperCamelCase_ = len(matrix[0]) UpperCamelCase_ = min(_lowerCAmelCase , _lowerCAmelCase) for row in range(_lowerCAmelCase): # Check if diagonal ele...
128
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder impo...
357
import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( "The `image_to_image.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionImg2ImgPipeline` instead." )
293
0
def snake_case_ ( snake_case , snake_case ) -> int: return x if y == 0 else greatest_common_divisor(snake_case , x % y ) def snake_case_ ( snake_case , snake_case ) -> int: return (x * y) // greatest_common_divisor(snake_case ,...
196
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class __a ( __UpperCamelCase ): def __init__( self , lowerCAmelCase__ , lowerCAmelCase__ ) -> Any: '''simple docstring''' lowercase__: Any = ...
196
1
from __future__ import annotations from math import pi def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase, lowerCamelCase ): if (inductance, frequency, reactance).count(0 ) != 1: raise ValueError("One and only one argument must be 0" ) if inductance < 0: raise ValueE...
158
from . import __version__ # Backward compatibility imports, to make sure all those objects can be found in file_utils from .utils import ( CLOUDFRONT_DISTRIB_PREFIX, CONFIG_NAME, DISABLE_TELEMETRY, DUMMY_INPUTS, DUMMY_MASK, ENV_VARS_TRUE_AND_AUTO_VALUES, ENV_VARS_TRUE_VALUES, FEATU...
158
1
'''simple docstring''' from collections.abc import Sequence def UpperCAmelCase ( a_ , a_ ) -> float: """simple docstring""" return sum(c * (x**i) for i, c in enumerate(a_ ) ) def UpperCAmelCase ( a_ , a_ ) -> ...
344
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase__ : Any = { 'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2...
344
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE :Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :Union[str, Any] = { 'weiweishi/roc-bert-base-zh': 'https://huggingface.co/weiweishi/roc-bert-base-zh/resol...
353
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor SCREAMING_SNAKE_CASE :Any = logging.get_logger(__name__) class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self : int ,*A : D...
124
0
UpperCAmelCase_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def lowerCamelCase__ ( ): '''simple docstring''' __lowerCamelCase = input("""Enter message: """ ) __lowerCamelCase = input("""Enter key [alphanumeric]: """ ) __lowerCamelCase = input(...
12
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get...
42
0
'''simple docstring''' import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand A : List[str] = ( '''4S 3H 2C 7S 5H''', '''9D 8H 2C 6S 7H''', '''2D 6D 9D TH 7D''', '''TC 8C 2S JH 6C''', '''JH 8S TH AH QH''', ...
227
'''simple docstring''' class __lowerCamelCase : # Public class to implement a graph """simple docstring""" def __init__( self : Optional[Any] , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : ...
227
1
"""simple docstring""" import inspect import unittest from transformers import BitConfig 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_common imp...
78
"""simple docstring""" import os from typing import Dict, List, Tuple, TypeVar, Union UpperCAmelCase : Union[str, Any] = TypeVar("T") UpperCAmelCase : Dict = Union[List[T], Tuple[T, ...]] UpperCAmelCase : int = Union[T, List[T], Dict[str, T]] UpperCAmelCase : ...
136
0
def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase , UpperCamelCase ) -> int: def update_area_of_max_square(UpperCamelCase , UpperCamelCase ) -> int: # BASE CASE if row >= rows or col >= cols: return ...
367
'''simple docstring''' import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": _A : List[Any] =argparse.ArgumentParser() pars...
129
0
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( _A ): a : List[str] = 0.00 a : List[Any] = 0 for resistor in resistors: if resistor <= 0: a : int = f"""Resistor at index {index} has...
297
import argparse import os import re import packaging.version UpperCamelCase__ = """examples/""" UpperCamelCase__ = { """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), """init""": (re.compile(R"""^__version__\s...
92
0
import os import string import sys __UpperCamelCase : Any = 1 << 8 __UpperCamelCase : Optional[Any] = { "tab": ord("\t"), "newline": ord("\r"), "esc": 27, "up": 65 + ARROW_KEY_FLAG, "down": 66 + ARROW_KEY_FLAG, "right": 67 + ARROW_KEY_FLAG, "left": 68 + ARROW...
371
import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from ...
347
0
import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modelin...
51
from __future__ import annotations import numpy as np def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ , snake_case_ = np.shape(UpperCamelCase__ ) if rows != columns: snake_case_ = ( ...
285
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : List[Any] =logging.get_logger(__name__) lowerCAmelCase__ : Optional[int] ={ 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.json', } ...
162
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def a__ ( ): raise RuntimeError('CUDA out of memory.' ) class __lowercase (nn....
162
1
"""simple docstring""" import math def UpperCAmelCase__ ( ): """simple docstring""" A_ : List[str] = input('Enter message: ' ) A_ : str = int(input(f"""Enter key [2-{len(_UpperCAmelCase ) - 1}]: """ ) ) A_ : Optional[i...
286
"""simple docstring""" from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class _UpperCAmelCase ( UpperCAmelCase__ ): '''simple docstring''' lowercase_ : List[str] = CustomTokenizer pass
286
1
"""simple docstring""" import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): """simple docstring""" def lowercase__ ( self ): ...
368
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py lower...
133
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...
128
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _lowercase (a_ ): '''simple docstring''' lowercase__ = (IPNDMScheduler,) lowercase__ = (("""num_inference_steps""", 50),) def _lowe...
128
1
from math import isqrt def snake_case (UpperCAmelCase__ ) -> bool: return all(number % divisor != 0 for divisor in range(2 , isqrt(UpperCAmelCase__ ) + 1 ) ) def snake_case (UpperCAmelCase__ = 1_0**6 ) -> int: UpperCamelCase_: str = 0 UpperCamelCase_: Union[str...
292
def snake_case (UpperCAmelCase__ ) -> int: assert isinstance(UpperCAmelCase__ , UpperCAmelCase__ ), F'''The input value of [n={number}] is not an integer''' if number == 1: return 2 elif number < 1: UpperCamelCase_: List[Any] = F'''The input value of [n={number}]...
292
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
219
from __future__ import annotations class _snake_case : def __init__( self , _a ): __magic_name__ : Optional[Any] = data __magic_name__ : Node | None = None __magic_name__ : Node | None = None def lowerCAmelCase_ ( _snake_case ...
281
0
"""simple docstring""" A = {'''a''': ['''c''', '''b'''], '''b''': ['''d''', '''e'''], '''c''': [], '''d''': [], '''e''': []} A = ['''a''', '''b''', '''c''', '''d''', '''e'''] def __A ( a_ :Union[str, Any] , a_ :Tuple , a_ :Union[str, Any]) -> ...
188
"""simple docstring""" import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import ...
188
1
"""simple docstring""" def a_ ( lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = len(lowerCamelCase ) + 1 UpperCAmelCase__ = len(lowerCamelCase ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # l...
98
"""simple docstring""" import functools def a_ ( lowerCamelCase , lowerCamelCase ): UpperCAmelCase__ = len(lowerCamelCase ) UpperCAmelCase__ = len(lowerCamelCase ) @functools.cache def min_distance(lowerCamelCase , lo...
98
1
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_u...
189
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWithPoo...
189
1
"""simple docstring""" import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @re...
256
"""simple docstring""" from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class UpperCAmelCase_ : def _UpperCamelCase ( self : List[str] , __UpperCamelCase : Any ) -> Tu...
256
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaV...
228
'''simple docstring''' from __future__ import annotations class a__ : '''simple docstring''' def __init__( self , lowerCamelCase_ ) -> None: lowerCAmelCase__ = order # a_{0} ... a_{k} ...
228
1
import math class UpperCAmelCase : '''simple docstring''' def __init__( self : Optional[int] ,A : Dict=0 ): # a graph with Node 0,1,...,N-1 __A = n __A = [ [math.inf for j in range(0 ,A )] for i in range(0 ,A ) ] # adjacenc...
15
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def __lowerCamelCase ( ...
274
0
import mpmath # for roots of unity import numpy as np class __magic_name__ : def __init__( self , _lowercase=None , _lowercase=None )-> Optional[int]: # Input as list UpperCamelCase_ = list(poly_a or [0] )[:] U...
351
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY i...
60
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __UpperCamelCase = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CON...
113
"""simple docstring""" import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils i...
113
1
import os from math import logaa def SCREAMING_SNAKE_CASE__ ( lowercase = "base_exp.txt" ) -> int: snake_case : float = 0 snake_case : Optional[Any] = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(lowercase ) ,lowercase ) ...
371
def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase ) -> int: return int((input_a, input_a).count(1 ) != 0 ) def SCREAMING_SNAKE_CASE__ ( ) -> None: assert or_gate(0 ,0 ) == 0 assert or_gate(0 ,1 ) == 1 assert or_gate(1 ,0 ) ==...
176
0
'''simple docstring''' from __future__ import annotations from statistics import mean def __lowercase ( __lowercase , __lowercase , __lowercase ) -> list[int]: '''simple docstring''' _A = [0] * no_of_processes _A = [0] * no_of_processes ...
79
'''simple docstring''' from collections.abc import Sequence def __UpperCamelCase ( lowercase__ : Sequence[float], lowercase__ : float ): '''simple docstring''' return sum(c * (x**i) for i, c in enumerate(lowercase__ ) ) def __UpperCamelCase ( lowe...
141
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : List[Any] = logging.get_logger(__name__) _lowerCamelCase : Any = { '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics40...
191
from queue import PriorityQueue from typing import Any import numpy as np def _a ( SCREAMING_SNAKE_CASE__ : dict , SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : set , SCREAMING_SNAKE_CASE__ : set , SCREAMING_SNAKE_CASE__ : dict , ...
191
1
"""simple docstring""" import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test...
291
"""simple docstring""" from __future__ import annotations def a__ ( snake_case__ , snake_case__ ) -> bool: if len(snake_case__ ) == 0: return False lowerCamelCase = len(snake_case__ ) // 2 if a_list[midpoint] == item: return True if item < a...
291
1
'''simple docstring''' 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 fro...
365
'''simple docstring''' import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _A () -> Optional[Any]: '''simple docstr...
104
0
import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import huggingface_hub.utils as hf_hub_...
188
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ra...
188
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase__ = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not is_torch_a...
352
import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test...
121
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig UpperCAmelCase : List[str] = { """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/config.json""", """albe...
95
"""simple docstring""" from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, loggi...
126
0
"""simple docstring""" import operator as op A = '''scaler.pt''' A = '''pytorch_model''' A = '''random_states''' A = '''optimizer''' A = '''scheduler''' A = '''pytorch_model.bin''' A = '''pytorch_model.bin.index.json''' ...
359
"""simple docstring""" def __A ( a_ :int) -> Union[str, Any]: __a : int = [] __a : Dict = [] __a : str = { '''^''': 3, '''*''': 2, '''/''': 2, '''%''': 2, '''+''': 1, ...
188
0
"""simple docstring""" # flake8: noqa # Lint as: python3 _UpperCAmelCase = [ """VerificationMode""", """Version""", """disable_progress_bar""", """enable_progress_bar""", """is_progress_bar_enabled""", """experimental""", ] from .info_utils import VerificationMode from .l...
173
"""simple docstring""" from __future__ import annotations import numpy as np def __magic_name__ ( lowercase ): return np.maximum(0 , lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
173
1
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __lowerCamelCase ( lowerCamelCase__ : Optional[int] , lowerCamelCase__ : List[Any] , lowerCamelCase__ : List[str] = "x" , lowerCamelCase__ : str = 10**-10 ...
359
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : Dict = logging.get_logger(__name__) UpperCAmelCase : Any = { "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json", } class __lowercase ( ...
66
0
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { """microsoft/wavlm-base""": """https://huggingface.co/micro...
40
'''simple docstring''' from __future__ import annotations def __a(SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float ): '''simple docstring''' if days_between_payments <= 0: raise ValueError("days_betwe...
158
0
'''simple docstring''' def __a ( UpperCAmelCase ) ->bool: """simple docstring""" return str(UpperCAmelCase ) == str(UpperCAmelCase )[::-1] def __a ( UpperCAmelCase ) ->int: """simple docstring""" return int(UpperCAmelCase ) + int(str(UpperCAme...
365
'''simple docstring''' import heapq as hq import math from collections.abc import Iterator class __UpperCAmelCase : '''simple docstring''' def __init__(self : Any , _lowerCAmelCase : List[Any] ): A = str(id_ ) A = None A = None A ...
337
0
"""simple docstring""" import cva import numpy as np class UpperCAmelCase : """simple docstring""" def __init__( self , _UpperCAmelCase , _UpperCAmelCase ): if k in (0.04, 0.06): lowercase__: Tuple = k lowercase__: Tuple = ...
177
"""simple docstring""" from __future__ import annotations from math import pi, sqrt def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> tuple: if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: raise Value...
177
1
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class A( UpperCamelCase ): '''simple docstring''' UpperCamelCase = (DDIMParallelScheduler,) UpperCamelCase = (('''eta'''...
208
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings lowerCamelCase : Any = r"\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the m...
208
1
def _A ( SCREAMING_SNAKE_CASE : str ): """simple docstring""" return credit_card_number.startswith(("34", "35", "37", "4", "5", "6") ) def _A ( SCREAMING_SNAKE_CASE : str ): """simple docstring""" a__ : Tuple...
95
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->bool: """simple docstring""" return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
293
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor A: Any = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( UpperCAmelCase__ ): def __init__( self , *_SCREAMING_SNAKE_CASE , **_S...
76
"""simple docstring""" from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class ...
76
1
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusi...
279
'''simple docstring''' def __UpperCamelCase ( lowercase__ : Union[str, Any]=2_81_23 ): '''simple docstring''' __lowercase =[1] * (limit + 1) for i in range(2, int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1, l...
141
0
from typing import List, Union import numpy as np 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 PIL import Image from ..image_utils import load_im...
363
'''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, t...
179
0