code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class __snake_case ( A__ ): ...
388
def lowerCamelCase__ (_UpperCAmelCase = 10 , _UpperCAmelCase = 1000 , _UpperCAmelCase = True): assert ( isinstance(_UpperCAmelCase , _UpperCAmelCase) and isinstance(_UpperCAmelCase , _UpperCAmelCase) and isinstance(_UpperCAmelCase , _U...
73
0
import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class __UpperCAmelCase ( snake_case__ ): """simple docstring""" def __init__( self ...
414
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean __a : int = 0 __a : List[str] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0,...
414
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impor...
37
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_device=False)...
64
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.k...
420
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json''', ...
420
1
"""simple docstring""" import os from datetime import datetime as dt from github import Github _snake_case = [ "good first issue", "good second issue", "good difficult issue", "enhancement", "new pipeline/model", "new scheduler", "wip", ] def sna...
510
"""simple docstring""" import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_atten...
510
1
from maths.prime_factors import prime_factors def __lowercase( UpperCAmelCase__ ): """simple docstring""" if not isinstance(__UpperCamelCase , __UpperCamelCase ): lowerCamelCase = F"""Input value of [number={number}] must be an integer""" rais...
711
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass a_ : Optional[int] = (3, 9, -1_1, 0, 7, 5, 1, -1) a_ : str = (4, 6, 2, 0, 8, 1_0, 3, -2) @dataclass class lowerCamelCase__ : """simple d...
484
0
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: float , lowerCAmelCase: float ) -> float: if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bulk_modulus / density) ** 0.5 if __...
300
from statistics import mean, stdev def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: list , lowerCAmelCase: int = 3 ) -> list: _UpperCAmelCase : Tuple = min(lowerCAmelCase ) _UpperCAmelCase : Optional[Any] = max(lowerCAmelCase ) # normalize data retur...
300
1
'''simple docstring''' import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version im...
712
'''simple docstring''' def _lowerCAmelCase( UpperCAmelCase_ : str ) -> int: assert column_title.isupper() lowerCAmelCase__ = 0 lowerCAmelCase__ = len(UpperCAmelCase_ ) - 1 lowerCAmelCase__ = 0 while index >= 0: ...
211
0
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def lowerCAmelCase ( ): '''simple docstring''' UpperCAmelCase__ : dict[int, int] = {} UpperCAmelCase__ : Optional[int] = 2 while True: Upp...
65
"""simple docstring""" import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers i...
118
0
'''simple docstring''' import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax....
319
'''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 from ...test_con...
319
1
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 _A ( unittest.TestCase): def UpperCAmelCase ( self ): ...
511
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table import ...
511
1
'''simple docstring''' import warnings warnings.warn( """memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: """ """`from accelerate import find_executable_batch_size` to avoid this warning.""", FutureWarning, )
427
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( a , a ): print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(a ): print(f'{i}\t\t{d}' ) def lowerCamelCase__ ( a , a ,...
427
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer _snake_case : Dict = logging.get_logger(__name__) _s...
53
'''simple docstring''' import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) ...
649
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available UpperCamelCase_ = {'tokenization_herbert': ['HerbertTokenizer']} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() excep...
710
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 from transfor...
510
0
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration SCREAMING_SNAKE_CASE__ = HfArgumentParser(InitializationArguments) SCREAMING_SNAKE_CASE__ = parser.parse_args() # Load c...
47
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, ) UpperCamelCase_ = {"configuration_mbart": ["MBART_PR...
256
0
"""simple docstring""" def lowerCamelCase_ ( __lowerCAmelCase , __lowerCAmelCase = False ) -> bool: '''simple docstring''' if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 10 not in (1, 3, 7, 9): # ...
719
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowerCamelCase_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = None ) -> str: '''simple docstring''...
132
0
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.ut...
90
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class _SCREAMING_SNAKE_CASE( A ): @staticmethod @abstractmethod def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ ) -> str: "...
498
0
from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProce...
57
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __UpperCAmelCase : Tuple = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable...
57
1
"""simple docstring""" from __future__ import annotations lowerCamelCase__ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def _SCREAMING_SNAKE_CASE ( UpperCamelCase : list[list[int]] , UpperCamelCase : lis...
574
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase__ = { "configuration_deberta": ["DEBERTA_PRETRAINE...
574
1
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def __magic_name__ ( _lowerCamelCase : str , _lowerCamelCase : str , _lowerCamelCase : Optional[str] = None ): ...
63
"""simple docstring""" import unittest from knapsack import knapsack as k class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): def lowerCAmelCase__(self ): '''simple docstring''' __a : str = 0 __...
63
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a: Optional[int] = {'''configuration_wavlm''': ['''WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''WavLMConfig''']} try: if not is_torch_available(): raise OptionalDependenc...
108
"""simple docstring""" import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_token...
247
0
from ....utils import logging __snake_case :Any = logging.get_logger(__name__) class _A ( __UpperCAmelCase ): def __init__( self : Optional[Any] , __SCREAMING_SNAKE_CASE : str , __SCREAMING_SNAKE_CASE : Optional[Any]=None , __SCREAMING_SNAKE_CASE : Optiona...
60
__snake_case :str = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # ...
60
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor A__: Union[str, Any] = logging.get_logger(__name__) class A__ ( UpperCAmelCase__ ): def __init__( self...
694
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() A__: Union[str, Any] = logging.get_logger('''transformers.models.speecht5''') def SCR...
694
1
import warnings from functools import wraps from typing import Callable def UpperCamelCase_ ( lowerCAmelCase__ ): """simple docstring""" @wraps(lowerCAmelCase__ ) def _inner_fn(*lowerCAmelCase__ , **lowerCAmelCase__ ): warnings.warn( (f"""'{fn.__n...
587
def UpperCamelCase_ ( lowerCAmelCase__ , lowerCAmelCase__ ): """simple docstring""" if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bulk_modulus / density) ** 0....
587
1
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class SCREAMING_SNAKE_CASE__ ( ...
581
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers....
581
1
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils...
710
"""simple docstring""" from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def A__ ( UpperCamelCase__ = "laptop" ): '''simple docstring''' _SCREAMING_SNAKE_CASE = F'''https://www.amazon.in/l...
168
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import...
251
'''simple docstring''' import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test,...
251
1
"""simple docstring""" import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class _UpperCAmelCase (...
87
"""simple docstring""" from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def a__ ( a : float , a : float , a : bool = False ): """simple docstring""" if radian_mode: return [magnitu...
87
1
_snake_case = 65521 def lowerCAmelCase_ ( snake_case_ ): _A : Optional[int] = 1 _A : Tuple = 0 for plain_chr in plain_text: _A : Union[str, Any] = (a + ord(_lowercase )) % MOD_ADLER _A : Dict = (b + a) % MOD_ADLER ...
307
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( _lowercase , _lowercase , _lowercase ): SCREAMING_SNAKE_CASE : List[Any] = OmegaConf.load(_lowercase ) SCREAMING_SNAKE_...
248
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase :Dict = { 'configuration_chinese_clip': [ 'CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ChineseCLIPConfig', 'Chin...
704
import math import sys import cva import numpy as np def __snake_case ( _UpperCamelCase , _UpperCamelCase ) -> np.ndarray: # For applying gaussian function for each element in matrix. _a = math.sqrt(_UpperCamelCase ) _a = 1 / (sigma * math.sqrt(2 * ...
346
0
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ...
57
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _A ( __snake_case :BertModel , __snake_case :str , __snake_case :str ) -> List[str]: """simple docstring""" __SCREAMING_SNAKE_CASE ...
693
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ :List[Any] = {"configuration_sew": ["SEW_PRETRAINED_CONFIG_ARCHIVE_MAP", "SEWConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAva...
705
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowercase ( SCREAMING_SNAKE_CASE__ ): lowercase_ : List[...
633
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if...
466
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class __low...
377
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer UpperCamelCase_ : Any = logging.get_lo...
482
"""simple docstring""" from __future__ import annotations from collections import Counter from random import random class __lowerCAmelCase : """simple docstring""" def __init__( self : int ) -> List[Any]: """simple docstring""" A_ = {} ...
482
1
"""simple docstring""" from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def snake_case ( lowerCAmelCase_ ) -> int: _snake_case = prime_factors(lowerCAmelCase_ ) if is_square_free(lowerCAmelCase_ ): return -1 if l...
103
from __future__ import annotations class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_ ) -> None: '''simple docstring''' __lowercase = order # a_{0} ... a_{k} __lowercase = [1.0]...
639
0
'''simple docstring''' import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() lowerCamelCase :str = lo...
686
'''simple docstring''' from jiwer import compute_measures import datasets lowerCamelCase :int = '''\ @inproceedings{inproceedings, author = {Morris, Andrew and Maier, Viktoria and Green, Phil}, year = {2004}, month = {01}, pages = {}, title = {From WER and RIL to MER...
686
1
'''simple docstring''' import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImageProcessor fr...
44
'''simple docstring''' import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def A_ ( _lowerCAmelCase : Optional[Any] ): ...
44
1
def snake_case (UpperCamelCase : list[int] ): '''simple docstring''' if not nums: # Makes sure that the list is not empty raise ValueError("""List is empty""" ) lowerCamelCase__ = sum(UpperCamelCase ) / len(UpperCamelCase ) # Calculate the average ...
235
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 import is_torch_availab...
235
1
"""simple docstring""" from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": SCREAMING_SNAKE_CASE__ = input("Enter image url: ").strip() print(f'Downloading image from {url} ...') SCREAMING_SNAKE_CASE__ = BeautifulSoup(requests.get...
532
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ = { "configuration_roformer": ["ROFORMER_PRET...
532
1
"""simple docstring""" from __future__ import annotations from collections.abc import Callable lowerCamelCase__ = list[list[float | int]] def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase ): __lowerCAmelCase : int = len(_UpperCamelCase ) __lowerCAmelCase : Matr...
549
"""simple docstring""" import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline lowerCamelCase__ = { """n_samples""": 64, """horizon""": 32, """num_inference_steps""": 20, """n_guide_steps""": 2, # can set to 0 for faster sampling, does not...
549
1
"""simple docstring""" import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, ...
103
"""simple docstring""" from math import sqrt def snake_case ( lowerCAmelCase_ = 1000000 ) -> int: _snake_case = 0 _snake_case = 0 _snake_case = 42 while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2...
103
1
'''simple docstring''' from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowerCAmelCase_ ( __A : Optional[Any] ): '''simple docstring''' return getitem, k def lowerCAmelCase_ ( __A : Any...
692
'''simple docstring''' from queue import PriorityQueue from typing import Any import numpy as np def lowerCAmelCase_ ( __A : dict , __A : str , __A : set , __A : set , __A : dict , __A : dict , __A : PriorityQueue , __A : dict , __...
692
1
'''simple docstring''' import os import sys import unittest UpperCamelCase_ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_f...
28
'''simple docstring''' import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class...
28
1
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"): UpperCamelCase_ = { "linear": PIL.Image.Resampling.BILINEAR, "bilinear": PIL.Ima...
718
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCamelCase_ = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available(): ra...
599
0
"""simple docstring""" lowercase_ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def A_ ( lowercase ) -> bytes: """simple docstring""" if not isinstance(lowercase , lowercase ): UpperCAmelCase_ : Optional[i...
470
"""simple docstring""" class UpperCAmelCase_ : """simple docstring""" def __init__( self : Optional[Any] , a_ : int )-> str: """simple docstring""" UpperCAmelCase_ : Any = n UpperCAmelCase_ : str = [None] * self.n ...
470
1
from __future__ import annotations def A__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> tuple[float, list[float]]: lowerCamelCase : List[str] =list(range(len(SCREAMING_SNAKE_CASE_ ) ) ) lowerCamelCase : List[s...
262
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging snake_case_ = logging.get_logge...
262
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.uti...
306
import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requi...
306
1
def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase ,lowercase=False ) -> Optional[int]: if isinstance(SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ) and isinstance(SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ): snake_case : List[Any] = len(set_a.intersection(SCREA...
715
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowerCamelCase : List[str] = 3 def SCREAMING_SNAKE_CASE__ ( lowercase ) -> int: print("""Generating primitive root of p""" ) while True: snake_case : O...
684
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase :Tuple = logging.get_logger(__name__) __lowerCamelCase :Any = { 'facebook/s2t-wav2vec2-large-en-de': ( 'https://huggingface.co/facebook/s2t-wav2vec2-larg...
222
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def snake_case ( ) -> Generator[int, None, None]: lowerCamelCase : dict[int, int] = {} lowerCamelCase : str = 2 while True: lowerCamelCase ...
222
1
from __future__ import annotations def _a ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ) -> float: if days_between_payments <= 0: raise ValueError('days_between_payments must be > 0' ) if daily_interest_rate < 0: raise ValueError('daily_interest_rate must...
144
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { '''google/umt5-small''': '''https://huggingface.co/google/umt5-small/resol...
144
1
'''simple docstring''' import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, Lis...
640
'''simple docstring''' from collections.abc import Generator def __magic_name__ ( ) -> Generator[int, None, None]: '''simple docstring''' snake_case_ ,snake_case_ = 0, 1 while True: snake_case_ ,snake_case_ = b, a + b y...
640
1
from __future__ import annotations import unittest from transformers import RoFormerConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...
720
from PIL import Image def A__ ( __lowerCamelCase ): SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = image.size SCREAMING_SNAKE_CASE_ = 0 SCREAMING_SNAKE_CASE_ = image.load() for i in range(__lowerCamelCase ): for j in range(__lowerCamelCase ): SCREAMING_SNAKE_CASE_ = ...
597
0
import numpy as np class lowerCamelCase_ : def __init__( self : Dict ): '''simple docstring''' a = (0, 0) a = None a = 0 a = 0 ...
387
import numpy as np class lowerCamelCase_ : def __init__( self : Dict ): '''simple docstring''' a = (0, 0) a = None a = 0 a = 0 ...
387
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE = { """configuration_lxmert""": ["""LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP"""...
534
def SCREAMING_SNAKE_CASE__ ( __a ): if not isinstance(__a , __a ): raise ValueError('Input must be an integer' ) if input_num <= 0: raise ValueError('Input must be positive' ) return sum( divisor for divisor in range(1 , input_num // 2 + 1 ) if input_num % divi...
534
1
'''simple docstring''' import os import sys __UpperCAmelCase = os.path.join(os.path.dirname(__file__), '''src''') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuest...
90
'''simple docstring''' import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class a__ : '''simple docstring''' def __init__( self , lowerCamelCase_=...
90
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : Any = logging.get_logger(__name__) __lowerCamelCase : str = { '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/config.json''', '''google...
316
# 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 by appl...
316
1
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, ...
397
from math import factorial def snake_case_ ( SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ) -> float: if successes > trials: raise ValueError("successes must be lower or equal to trials" ) if trials < 0 or successes...
397
1
'''simple docstring''' import torch from torch import nn class __lowerCamelCase ( nn.Module ): '''simple docstring''' def __init__( self , a__ , a__ , a__ , a__ , a__=1 , a__=False ): super().__init__() ...
564
'''simple docstring''' def __A ( _SCREAMING_SNAKE_CASE : int = 1_0_0_0 ): """simple docstring""" return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
564
1
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance UpperCAmelCase__ : Optional[int] = 6_3_7_8_1_3_7.0 UpperCAmelCase__ : Any = 6_3_5_6_7_5_2.3_1_4_2_4_5 UpperCAmelCase__ : List[str] = 6_37_81_37 def A...
48
'''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 ...
296
0
import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipeline_mixin ...
467
import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) def __SCREA...
467
1
import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtract...
415
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch,...
415
1
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_diffusion_safe imp...
164
import math def a_ (_lowerCAmelCase : list , _lowerCAmelCase : int = 0 , _lowerCAmelCase : int = 0 )-> list: snake_case: List[str] = end or len(_lowerCAmelCase ) for i in range(_lowerCAmelCase , _lowerCAmelCase ): snake_case: Union[s...
164
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, V...
588
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def SCREAMING_SNAKE_CASE ( lowercase_ : np.ndarray , lowercase_ : np.ndarray ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(lowercase_ , ...
588
1
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common i...
701
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _lowerCamelCase...
361
0
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 import BackboneTesterMixi...
117
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _snake_case ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with p...
91
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...
718
def _lowerCAmelCase ( __magic_name__ :int ): UpperCAmelCase_ = int(__magic_name__ ) if decimal in (0, 1): # Exit cases for the recursion return str(__magic_name__ ) UpperCAmelCase_, UpperCAmelCase_ = divmod(__magic_name__ , 2 ) return b...
407
0
'''simple docstring''' import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() _SC...
369
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoToke...
647
0
'''simple docstring''' import warnings from ...utils import is_sklearn_available, requires_backends if is_sklearn_available(): from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef UpperCamelCase__ = ( '''This metric will be remove...
312
'''simple docstring''' def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ) -> str: if not isinstance(lowerCAmelCase__ , lowerCAmelCase__ ): raise ValueError('''iterations must be defined as integers''' ) if not isinstance(lowerCAmelCase__ , lowerCA...
312
1
'''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/LICENS...
135
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE : Optional[Any...
135
1
'''simple docstring''' import sys from collections import defaultdict class A : def __init__( self : Any ) -> Dict: """simple docstring""" _a = [] def __lowerCAmelCase (...
704
'''simple docstring''' import math import unittest def snake_case_ (UpperCamelCase : int ): '''simple docstring''' assert isinstance(UpperCamelCase , UpperCamelCase ) and ( number >= 0 ), "'number' must been an int and positive" ...
377
0
'''simple docstring''' import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_...
427
'''simple docstring''' import argparse import os import re _A : str = '''src/transformers''' # Pattern that looks at the indentation in a line. _A : List[str] = re.compile(r'''^(\s*)\S''') # Pattern that matches `"key":" and puts `key` in group 0. _A : List[str] = ...
427
1
"""simple docstring""" from __future__ import annotations from math import gcd def a_ ( lowerCamelCase , lowerCamelCase = 2 , lowerCamelCase = 1 , lowerCamelCase = 3 , ): # A value less than 2 can cause an infinite loop in the algorithm. if num < 2: ...
711
"""simple docstring""" import random class snake_case : """simple docstring""" @staticmethod def __lowerCAmelCase ( lowerCamelCase__ : str ): UpperCAmelCase__ = [ord(lowerCamelCase__ ) for i in text] UpperCAmelCase__ = [] ...
632
0
def UpperCamelCase( ): for n in range(1 ,1000000 ): yield n * (n + 1) // 2 def UpperCamelCase( __UpperCamelCase : Union[str, Any] ): lowerCAmelCase_ : Optional[Any] = 1 lowerCAmelCase_ : List[Any] = 2 while i * i <= n: lowerCAmelCas...
171
import fire from utils import calculate_rouge, save_json def UpperCamelCase( __UpperCamelCase : str ,__UpperCamelCase : str ,__UpperCamelCase : str=None ,**__UpperCamelCase : Optional[Any] ): lowerCAmelCase_ : int = [x.strip() for x in open(__UpperCa...
171
1
'''simple docstring''' import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available _lowerCAmelCase : Tuple = logging.getLogger(...
646
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() _lowerCAmelCase : List[str] = logging.get_logger('transformers.models.speecht5') def __UpperCamelCase ( _A : Any...
646
1
'''simple docstring''' import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def A ( UpperCamelCase_ : Optional[int] , UpperCamelCase_ ...
48
'''simple docstring''' def A ( UpperCamelCase_ : str , UpperCamelCase_ : int ) -> list: '''simple docstring''' lowerCAmelCase__ = word.split() def justify(UpperCamelCase_ : list , UpperCamelCase_ : int , UpperCamelCa...
48
1
'''simple docstring''' # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer f...
50
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _lowercase : str = logging.get_logger(__name_...
50
1
"""simple docstring""" import copy import os import cva import numpy as np from matplotlib import pyplot as plt class _UpperCAmelCase : def __init__( self : Tuple ): __UpperCAmelCase = '''''' __UpperCAmelCase = '''''' __UpperCAmelCase = []...
49
"""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/LI...
49
1
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, ...
716
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : str = logging.get_logger(__name__) lowerCamelCase : List[str] = { "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/mai...
651
0
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.mo...
653
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __lowerCamelCase : Dict = TypeVar('''KEY''') __lowerCamelCase : int = TypeVar('''VAL''') @dataclas...
653
1
"""simple docstring""" from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse("""3.8"""): import importlib_metadata else: import importlib.meta...
317
"""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_fu...
317
1
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class lowerCAmelCase_ ( __lowercase, __lowercase ): @register_to_config def __init__( self ...
10
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor,...
536
0
import json import sys def __lowercase( __snake_case : Tuple ,__snake_case : Optional[int] ) -> Tuple: with open(UpperCAmelCase__ ,encoding='utf-8' ) as f: __snake_case = json.load(UpperCAmelCase__ ) __snake_case = [...
710
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...utils.dummy_torch_an...
345
0
'''simple docstring''' import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def lowerCamelCase (_SCREAMING_SNAKE_CASE : Optional[Any] ): __a : Dict = [ 'encoder.version', 'decoder.version', ...
476
'''simple docstring''' import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 __lowercase : Tuple = 0b1011001111101100100100000111101...
476
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __UpperCAmelCase : Optional[Any] = { "configuration_mobilevit": ["MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
643
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter __UpperCAmelCase : List[An...
643
1
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vi...
233
"""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 a ...
277
0
import pytest import datasets # Import fixture modules as plugins UpperCamelCase = ["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""] def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): # Mark tests as "unit" by default if...
152
from functools import reduce UpperCamelCase = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" """66...
152
1
'''simple docstring''' import os from datetime import datetime as dt from github import Github UpperCamelCase__ = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''enhancement''', '''new pipeline/model''', '''new scheduler''', '...
75
'''simple docstring''' def __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ ) -> float: return base * power(UpperCamelCase__ , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print("Raise base to the power of exponent using recursion...") ...
546
0
"""simple docstring""" import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet i...
711
"""simple docstring""" from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCamelCase () -> tuple[list[int], int]: lowercase :Any = [randint(-1000 , 1000) for i in range(10)] ...
475
0
"""simple docstring""" import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) __magic_name__ = pytest.mark.integration @pytest.mark.parametrize('pa...
232
"""simple docstring""" from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common...
232
1
"""simple docstring""" import os def UpperCamelCase_ ( SCREAMING_SNAKE_CASE_ = "input.txt" ): with open(os.path.join(os.path.dirname(SCREAMING_SNAKE_CASE_ ), SCREAMING_SNAKE_CASE_ ) ) as input_file: SCREAMING_SNAKE_CASE = [ [int(SCREAMING_S...
406
"""simple docstring""" import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def UpperCamelCase_ ( SCREAMING_SNAKE_CASE_, SCREAMING_SNAKE_CASE_, SCREAMING...
406
1
'''simple docstring''' import cva import numpy as np class _A : def __init__( self : Any , __magic_name__ : float , __magic_name__ : int ) -> Optional[int]: """simple docstring""" if k in (0.04, 0.06): __snake_c...
26
def __a ( SCREAMING_SNAKE_CASE ) -> list: '''simple docstring''' if len(SCREAMING_SNAKE_CASE ) < 2: return collection def circle_sort_util(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> bool: __UpperCAmelCase ...
303
0
'''simple docstring''' from collections import defaultdict from math import gcd def __UpperCAmelCase ( __magic_name__ = 150_0000 )-> int: """simple docstring""" snake_case_ : defaultdict = defaultdict(__magic_name__ ) snake_case_ : Tuple ...
711
'''simple docstring''' from scipy.stats import spearmanr import datasets __lowerCamelCase : str = ''' The Spearman rank-order correlation coefficient is a measure of the relationship between two datasets. Like other correlation coefficients, this one varies between -1 a...
656
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__ ( SCREAMING_SNAKE_CASE_: List[Any] ) -> Dict: ...
514
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_available(): import torch i...
514
1
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer import...
152
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBirdPegasusConfig""", """BigBirdPega...
152
1
"""simple docstring""" def lowercase__ ( snake_case_ :dict ): __UpperCAmelCase = set() # To detect a back edge, keep track of vertices currently in the recursion stack __UpperCAmelCase = set() return any( node not in visited and depth_first_search(snake_cas...
49
'''simple docstring''' # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.vers...
675
0
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig 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_con...
390
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "camembert-base": "https://huggingface.co/camembert-base/r...
390
1
"""simple docstring""" from collections import deque def lowercase_ ( __UpperCAmelCase ) -> int: lowerCAmelCase__ : Optional[int] = len(__UpperCAmelCase ) lowerCAmelCase__ : int = deque() lowerCAmelCase__ : Optional[int] = [False ...
299
"""simple docstring""" from __future__ import annotations import queue class _lowerCamelCase : def __init__( self : Optional[int] , UpperCamelCase : List[Any] ) -> List[str]: """simple docstring""" lowerCAmelCase__ : Union[str, A...
299
1
# 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 ( snake_case__ ...
608
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__snake_case ) class lowerCamelCase ( __snake_case ): """simple docstring""" lo...
608
1
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowercase ( _A ): _a : UNetaDModel ...
385
from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import stable_softmax ...
385
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A__ = { '''configuration_roberta''': ['''ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP'''...
717
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...
219
0