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""" import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from tr...
91
from __future__ import annotations def a__ ( snake_case__ : list[int] ): if len(snake_case__ ) == 0: return array _UpperCAmelCase,_UpperCAmelCase : List[str] = min(snake_case__ ), max(snake_case__ ) # Compute the variables _UpperCAmelCase : T...
643
0
"""simple docstring""" from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split __lowercase : int = datasets.load_iris() __lowercase : Union[str, Any] = np.array(data["data"]) __lower...
93
"""simple docstring""" def SCREAMING_SNAKE_CASE ( snake_case): return 1 if digit in (0, 1) else (digit * factorial(digit - 1)) def SCREAMING_SNAKE_CASE ( snake_case): __snake_case = 0 __snake_case = number while duplicate > 0: ...
93
1
from typing import TYPE_CHECKING from ...utils import _LazyModule lowercase__ : Tuple = {"tokenization_wav2vec2_phoneme": ["Wav2Vec2PhonemeCTCTokenizer"]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys lowerca...
376
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class UpperCAmelCase ( ...
376
1
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'RUCAIBox/mvp': 'https://huggingface.co/RUCAIBox/mvp/resolve/main/config.json', } class snake_c...
510
def _UpperCAmelCase ( A , A ): '''simple docstring''' _validate_point(A ) _validate_point(A ) if len(A ) != len(A ): raise ValueError("Both points must be in the same n-dimensional space" ) return float(sum(abs(a - b ) for a...
510
1
import os def a_ ( ): __lowerCAmelCase = os.path.dirname(os.path.realpath(lowerCAmelCase_ ) ) __lowerCAmelCase = os.path.join(lowerCAmelCase_, 'triangle.txt' ) with open(lowerCAmelCase_ ) as f: __lowerCAmelCase = f.r...
53
'''simple docstring''' import copy import random from transformers import CLIPTokenizer class SCREAMING_SNAKE_CASE ( lowercase_ ): '''simple docstring''' def __init__( self : int , *snake_case : Optional[Any] , **snake_case : Optional[int]...
517
0
'''simple docstring''' import operator as op def __SCREAMING_SNAKE_CASE ( _UpperCamelCase ): """simple docstring""" lowercase_ : Optional[Any] = [] lowercase_ : List[Any] = lambda _UpperCamelCase , _UpperCamelCase : int(x / y ) ...
701
'''simple docstring''' def __SCREAMING_SNAKE_CASE ( _UpperCamelCase = 200 ): """simple docstring""" lowercase_ : Optional[int] = [1, 2, 5, 10, 20, 50, 100, 200] lowercase_ : str = [0] * (pence + 1) lowercase_ : Dict = 1 # base cas...
640
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase__ : Any = { 'configuration_graphormer': ['GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GraphormerConfig'], } try: ...
98
'''simple docstring''' import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class __lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def snake_case__ ( self : str ) ...
98
1
'''simple docstring''' from math import factorial class __UpperCAmelCase : def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ ): """simple docstring""" _snake_case = real if isinstance(lowerCAmelCase_ , lowerCAmelCase_ ...
542
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler...
542
1
'''simple docstring''' from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class lowerCAmelCase__ : """simple docstring""" lowerCAmelCase__ ...
627
"""simple docstring""" from math import pi, sqrt, tan def __UpperCAmelCase ( __UpperCamelCase ): if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def __UpperCAmelCase ...
76
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_: Tuple = logging.get_logger(__name__) lowerCAmelCase_: str = { "transfo-xl-wt103": "https://huggingface.co/transfo-xl-wt103/resolve/main/config.json", } class ...
720
"""simple docstring""" from collections import deque class a__ : def __init__( self, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): '''simple docstring''' lowercase__ = process_name # process name lowercase__ = arrival_time # arriva...
668
0
"""simple docstring""" 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...
200
"""simple docstring""" 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...
200
1
"""simple docstring""" from pathlib import Path import fire def UpperCAmelCase ( A__: Optional[Any] , A__: Dict , A__: Tuple ) -> List[str]: __lowerCamelCase : str = Path(lowercase_ ) __lowerCamelCase : int = Path(lowercase_...
707
"""simple docstring""" import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedD...
263
0
import numpy class _UpperCamelCase : def __init__( self , __UpperCamelCase , __UpperCamelCase )-> None: __lowerCAmelCase = input_array # Random initial weights are assigned where first argument is the # numbe...
367
class SCREAMING_SNAKE_CASE_ : '''simple docstring''' def __init__( self : Tuple , __a : int ) ->Optional[int]: lowerCamelCase_ : Optional[Any] = n lowerCamelCase_ : Dict = [None] * self.n lowerCamelCase_ : in...
278
0
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 lowerCamelCase__ ( _A , _A , _A ): '''simple docstring''' snak...
139
from __future__ import annotations def lowerCamelCase__ ( _A ): '''simple docstring''' snake_case_ = len(_A ) # We need to create solution object to save path. snake_case_ = [[0 for _ in range(_A )] for _ in range(_A )] snake_cas...
139
1
"""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 A__ : Tuple = ( '''This metric will be remove...
153
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE ( lowercase_ : int , lowercase_ : Union[str, Any] , lowercase_ : str , lowercase_ : Optional[Any] ): # noqa: E741 while r - l > 1: lowercase = (l + r) // 2 ...
588
0
"""simple docstring""" import os import re import shutil import sys import tempfile import unittest import black lowerCAmelCase_ = 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_copies # noqa: E402 # Thi...
635
"""simple docstring""" import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class _snake_case ( __snake_case ): """simple docstring""" a = "M-CLIP" def __init__( self : Optional[Any] , _A : List[s...
635
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : int = logging.get_logger(__name__) lowerCamelCase__ : Dict = { "facebook/dpr-ctx_encoder-single-nq-base": ( "https://huggingface.co/faceboo...
698
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
698
1
def UpperCamelCase_( lowerCamelCase_ ) -> list: _lowercase : Any = len(lowerCamelCase_ ) for i in range(1 , lowerCamelCase_ ): _lowercase : Tuple = collection[i] _lowercase : str = 0 _lowercase : Optional[int] = i - 1...
354
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _lowerCamelCase( _a ): lowercase_ : List[Any] = ...
354
1
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, slow, ) from ...
30
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __A ( SCREAMING_SNAKE_CASE_ ): _Upper...
213
0
'''simple docstring''' import datasets from .evaluate import evaluate __lowerCamelCase : Optional[Any] = "\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Lia...
713
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : Optional[Any] = logging.get_logger(__name__) __lowerCamelCase : Optional[Any] = { "facebook/vit-mae-base": "https://huggingface.co/facebook/vit-mae-base/resolv...
459
0
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch import pyarrow as pa imp...
670
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } cla...
224
0
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput UpperCamelCase__ = "scheduler_config.json" class __SCREAMING_SNAKE_CASE ( _a ): snake_case : ...
548
def _UpperCamelCase (a__ :int ): """simple docstring""" if divisor % 5 == 0 or divisor % 2 == 0: return 0 UpperCamelCase__ = 1 UpperCamelCase__ = 1 while repunit: UpperCamelCase__ = (10 * repuni...
548
1
"""simple docstring""" def snake_case_ ( A_ : dict ): '''simple docstring''' _lowerCamelCase : int = set() # edges = list of graph's edges _lowerCamelCase : Optional[int] = get_edges(A_ ) # While there are st...
83
'''simple docstring''' import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset SCREAMING_SNAKE_CASE__ = {1: (1, 1), 2: (2,...
267
0
"""simple docstring""" import numpy as np import datasets __a : Any = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean dist...
702
"""simple docstring""" class _SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self: Any ): '''simple docstring''' a__ = {} def lowercase ( self: Optional[int] ): '''simple docstr...
200
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ : Optional[Any] = { '''configuration_whisper''': ['''WHISPER_PRETRAINE...
105
from decimal import Decimal, getcontext from math import ceil, factorial def _UpperCAmelCase ( UpperCamelCase: int ): """simple docstring""" if not isinstance(UpperCamelCase , UpperCamelCase ): raise TypeError("Undefined for non-integers" ) elif precision < 1: raise ValueError("Und...
611
0
"""simple docstring""" from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { '''microsoft/xprophetnet-large-wiki100-cased''': ( '''https://huggingface.co/microsoft/xpro...
48
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : list ): """simple docstring""" snake_case_ : Optional[int] = len(SCREAMING_SNAKE_CASE__ ) for i in range(1 , SCREAMING_SNAKE_CASE__ ): snake_case_ : Tuple ...
48
1
'''simple docstring''' import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, Robert...
495
'''simple docstring''' import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging lowercase : Dict = logging.get_logger(__name__) def SCREAMING_SNAKE_CASE__ ( __A=None , ...
495
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) _lowercase : Tuple ={ """configuration_speech_to_text""": ["""SPEECH_TO_TEXT_PRE...
715
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.te...
412
0
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature ...
39
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class lowercase ( A__ ): """simple doc...
189
0
"""simple docstring""" def _A (__a = 50 ) -> Optional[Any]: """simple docstring""" SCREAMING_SNAKE_CASE_ : Any = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_st...
719
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers...
176
0
'''simple docstring''' def lowerCAmelCase_ ( ) -> Union[str, Any]: """simple docstring""" for n in range(1 , 1_00_00_00 ): yield n * (n + 1) // 2 def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ ) -> Union[str, Any]: """simple docstring""" _SCREAMING_SNAKE_CA...
591
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .to...
591
1
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 UpperCAmelCase_ : Union[str, Any] = 0b101_100_111_110_110_010_010_000_011...
713
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : int = {"""configuration_plbart""": ["""PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP""",...
440
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
70
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py _a : ...
479
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase__ = { "configuration_squeezebert": [ "SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "SqueezeBertConfig", "SqueezeBertOnnxConf...
720
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(">=", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint.default...
594
0
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase = 100 ): """simple docstring""" lowerCAmelCase__ : Any = set() lowerCAmelCase__ : Optional[Any] = 0 lowerCAmelCase__ : List[str] = n + 1 # maximum limit for a in r...
565
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase = 600851475143 ): """simple docstring""" try: lowerCAmelCase__ : Union[str, Any] = int(UpperCamelCase ) except (TypeError, ValueError): raise TypeError("""Parameter n must be int or...
565
1
import string import numpy def lowerCamelCase( a__ ,a__): return b if a == 0 else greatest_common_divisor(b % a ,a__) class A__ : UpperCAmelCase = string.ascii_uppercase + string.digits # This cipher takes alphanumerics into account # i.e. a total o...
191
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def lowerCamelCase( a__ ,a__=() ,a__=None ,a__="no" ,a__="29500"): _SCREAMING_SNAKE_CASE =False _SCREAMING_SNAKE_C...
191
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_atte...
451
'''simple docstring''' import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def A_ ( SCREAMING_SNAKE_CASE_ ) ->List[Any]: lowercase_ = [ """encoder.version""", """decoder.version""", """mo...
451
1
import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin SC...
629
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"""): SCREAMING_SNAKE_CASE__ : int = { """linear""": PIL.Image.Resampling.BILINEAR, """bilinear""": P...
629
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json',...
114
import copy import random from transformers import CLIPTokenizer class __A ( lowerCamelCase__ ): """simple docstring""" def __init__( self , *a__ , **a__): """simple docstring""" super().__init__(*a__ , **a__) ...
114
1
import argparse import os import torch from transformers.utils import WEIGHTS_NAME __lowerCamelCase = ['small', 'medium', 'large'] __lowerCamelCase = 'lm_head.decoder.weight' __lowerCamelCase = 'lm_head.weight' def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE , _SCR...
712
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor __lowerCamelCase = logging.get_logger(__name__) class _UpperCamelCase( SCREAMING_SNAKE_CASE ): def __init__( self : List[Any] , *_lowerCamelCase : int , **_lowerCamelCase ...
328
0
"""simple docstring""" import argparse import importlib from pathlib import Path # Test all the extensions added in the setup __A : Dict = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/deformable_detr/cuda/ms_deform_im...
575
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Imag...
153
0
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def lowerCAmelCase_( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> Union[str, Any]: ...
713
"""simple docstring""" 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_...
20
0
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, ge...
36
from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_backbone import TimmBackboneConfig ...
302
0
import inspect import unittest from transformers import ConvNextConfig 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 BackboneTesterMixin from ...test_...
710
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils i...
671
0
'''simple docstring''' import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available...
152
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a: Optional[Any] = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBirdPegasusConfig""", ...
152
1
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py A_ : str = 'src/transformers' A_ : Union[str, Any] = 'docs/so...
705
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_availabl...
64
0
"""simple docstring""" from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm...
498
"""simple docstring""" def __lowerCamelCase ( a_ : int = 50 ) -> int: __SCREAMING_SNAKE_CASE :List[str] = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in ...
498
1
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def _lowerCAmelCase ( A__ , A__ ): lowercase__ = F'''{sampling_rate}''' lowercase__ = '1' lowercase__ = 'f32le' lowercase__ = [ 'ffmpe...
708
import heapq import sys import numpy as np a__ : Dict = tuple[int, int] class UpperCAmelCase__: '''simple docstring''' def __init__( self : List[str]) -> Any: """simple docstring""" lowercase__ = [] lowercase__ = set() def ...
642
0
'''simple docstring''' import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on ...
275
'''simple docstring''' from collections.abc import Callable class __snake_case : """simple docstring""" def __init__( self : Tuple , lowerCamelCase : Callable | None = None ) -> None: # Stores actual heap items. ...
275
1
"""simple docstring""" import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# lowercase = [ # (stable-diffusion, HF Diffusers) ("time_embed.0.weig...
703
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase = { '''configuration_mvp''': ['''MVP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MvpConfig''', '''MvpOnnxCo...
24
0
import numpy as np def lowerCAmelCase_ ( __a , __a , __a = 1e-12 , __a = 100 , ) -> tuple[float, np.ndarray]: """simple docstring""" assert np.shape(__lowerCamelCase )[0] == np.shape(__lowerCamelCase )[1] # Ensure proper dime...
59
"""simple docstring""" import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, ...
560
0
"""simple docstring""" def __UpperCAmelCase ( __lowerCamelCase ) -> bool: lowercase__ : List[str] = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def __UpperCAmelCase ( __lowerCamelCase = 50_00 ) -> int: lowercase__ : ...
122
"""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...
122
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor UpperCAmelCase = logging.get_logger(__name__) class __snake_case( lowercase__ ): '''simple docstring''' def __init__( self , ...
433
"""simple docstring""" from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_torch_available(...
594
0
'''simple docstring''' import numpy as np def A ( _UpperCAmelCase : str ) -> np.array: '''simple docstring''' return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
703
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer...
123
0
'''simple docstring''' def _lowerCAmelCase ( lowerCamelCase_ : Optional[Any] , lowerCamelCase_ : int ): print('''\nThe shortest path matrix using Floyd Warshall algorithm\n''' ) for i in range(lowerCamelCase_ ): for j in range(lowerCamelCase_ ):...
502
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowercase ( lowerCAmelCase__ ): '''simple docstring''' a : List[Any] = ["image...
502
1
'''simple docstring''' 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...
718
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Con...
445
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = { '''configuration_autoformer''': [ '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AutoformerConfig''', ]...
40
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class lowerCAmelCase_ ...
40
1
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbeddi...
712
import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVec...
71
0
"""simple docstring""" import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...tes...
353
"""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, Vi...
353
1
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 accelerate import A...
714
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate _lowerCamelCase : Optional[Any] = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow("", ...
196
0
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class __lowercase (datasets.BuilderConfig ): """simple docstring""" ...
101
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowerCAmelCase: Optional[Any] = { 'configuration_swiftformer': [ 'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SwiftFormerConfig', 'S...
20
0
from __future__ import annotations def lowerCamelCase_ ( lowercase__): return len(set(lowercase__)) == len(lowercase__) if __name__ == "__main__": import doctest doctest.testmod()
702
'''simple docstring''' class lowercase : '''simple docstring''' def __init__( self : Any , __lowerCamelCase : Union[str, Any] , __lowerCamelCase : Optional[int] ) -> Optional[int]: '''simple docstring''' lowerCamel...
187
0
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch import nn f...
332
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { "facebook/xmod-base": "https://huggingface.co/f...
332
1
import random from .binary_exp_mod import bin_exp_mod def _snake_case ( __snake_case , __snake_case=1000 ): if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd _UpperCamelCase = n - 1 _UpperCamelCase = 0 while d % 2...
71
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase = { "configuration_jukebox": [ "JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP", "JukeboxConfig", "JukeboxPriorConfig", "JukeboxVQVAEConfig", ], ...
71
1
"""simple docstring""" def UpperCAmelCase ( _lowercase : list[list] ) -> list[list]: """simple docstring""" lowerCAmelCase_ = current_set.copy() for row_index, row in enumerate(a_ ): lowerCAmelCase_ = row[0] for column_index, column ...
552
"""simple docstring""" UpperCAmelCase = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def lowerCam...
677
0
"""simple docstring""" _lowercase : Dict = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.g...
397
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import...
397
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available A_ = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not is_torch_available(): raise Option...
393
'''simple docstring''' from __future__ import annotations def UpperCamelCase_ ( snake_case_ : list[int | float] , snake_case_ : int , snake_case_ : int ) -> int | float: '''simple docstring''' if len(snake_case_ ) == 0: raise ValueError("""find_max() ...
427
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
567
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _snake_case = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvNextConfig', 'ConvNextOnnxCon...
567
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ = {'configuration_reformer': ['REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ReformerConfig']} try: if not ...
25
'''simple docstring''' 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, EfficientFormerForImageClassificationWithTe...
24
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __snake_case :Optional[Any] ={ 'configuration_graphormer': ['GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GraphormerConfig'], } try: if not is_torch_avail...
224
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __snake_case :Any ={ 'configuration_llama': ['LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LlamaConfig'], } tr...
224
1
'''simple docstring''' import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ...
41
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : Optional[Any] = logging.get_logger(__name__) _a : Tuple = { "camembe...
56
0
UpperCamelCase__ : str = [ (1_000, "M"), (900, "CM"), (500, "D"), (400, "CD"), (100, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] def _UpperCAmelCase ( _SCREAMING_SNAKE_CASE : List[str]...
715
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline UpperCamelCase__ : Optional[int] = datasets.utils.log...
620
0
'''simple docstring''' import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import Token...
13
"""simple docstring""" __A : Optional[int] = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' ...
499
0
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging snake_case_ = logging.get_logger(__name__)...
701
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model fr...
262
0
def lowerCamelCase__ ( __lowerCamelCase : float , __lowerCamelCase : int ): if digit_amount > 0: return round(number - int(__lowerCamelCase ) , __lowerCamelCase ) return number - int(__lowerCamelCase ) if __name__ == "__main__": ...
63
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path _lowerCamelCase : Union[str, Any] = Path(__file__).resolve().parents[3] / '''src''' sys.path.insert(1, str(git_repo_path)) import dataclasses # n...
686
0
def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: int = 1 , __lowerCamelCase: int = 1000 ): lowercase_ = 1 lowercase_ = 0 for divide_by_number in range(__lowerCamelCase , digit + 1 ): lowercase_ = [] lowercase_ = numerator for _ in range(1 , digit + 1 ): ...
711
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Trai...
601
0
def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : str ) -> bool: SCREAMING_SNAKE_CASE_ : Optional[Any] =0 for ch in input_str: SCREAMING_SNAKE_CASE_ : List[Any] =ord(UpperCAmelCase_ ) SCREAMING_SNAKE_CASE_ : str =pow(2...
443
from math import ceil, sqrt def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : int = 1_0_0_0_0_0_0 ) -> int: SCREAMING_SNAKE_CASE_ : List[Any] =0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: ...
443
1
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ...
714
from __future__ import annotations def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = list(range(len(SCREAMING_SNAKE_CASE ) ) ) lowercase__ = [v / w for v, w in zip(SCREAMING_SNAKE_CASE , ...
429
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a = {} try: if not is_sentencepiece_available(): raise OptionalDependenc...
109
'''simple docstring''' import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modelin...
109
1
'''simple docstring''' from __future__ import annotations import typing from collections import Counter def __UpperCAmelCase ( UpperCamelCase__ :int ) -> typing.Counter[int]: snake_case__ : typing.Counter[int] = Counter() for base in range(1 , ...
574
'''simple docstring''' import argparse import os import re _lowercase : str ="src/transformers" # Pattern that looks at the indentation in a line. _lowercase : List[Any] =re.compile(R"^(\s*)\S") # Pattern that matches `"key":" and puts `key` in group 0. _lowercase : Optional[Any] ...
574
1
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers....
16
from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE ( metaclass=__snake_case ): """simple docstring""" __A = ["""flax""", """transformers"""] def __init__( self , *__UpperCamelCase , **__UpperCamelCase ): """simple docstring""" req...
187
0
def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : list ) -> list: SCREAMING_SNAKE_CASE_ : Tuple =False while is_sorted is False: # Until all the indices are traversed keep looping SCREAMING_SNAKE_CASE_ : Optional[Any] =True ...
717
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multipl...
431
0
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 im...
2
def _A ( SCREAMING_SNAKE_CASE ): stooge(SCREAMING_SNAKE_CASE ,0 ,len(SCREAMING_SNAKE_CASE ) - 1 ) return arr def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ): if i >= h: return # If first element is smaller than the last then swap them if arr[i...
113
0
_a : Any = """0.21.0""" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader import skip_first_batches fro...
111
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : str = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable(...
111
1
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, 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, r...
333
import os def __UpperCamelCase ( ): """simple docstring""" with open(os.path.dirname(_lowerCAmelCase ) + "/grid.txt" ) as f: UpperCAmelCase = [] # noqa: E741 for _ in range(20 ): l.append([int(_lowerCAmelCase ) for x in f.readline().split()] ) ...
333
1
"""simple docstring""" def UpperCamelCase_ ( lowerCamelCase : str = "The quick brown fox jumps over the lazy dog" , ) -> bool: __magic_name__ : Union[str, Any] = set() # Replace all the whitespace in our sentence __magic_name__ : List[Any] = input_...
706
"""simple docstring""" import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast fr...
147
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf __a = logging.get_logger(__name__) @datacla...
30
'''simple docstring''' import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImagePr...
294
0
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation...
439
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class a__ ( UpperCamelCase_ ): sna...
439
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import TensorType, l...
287
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_onnx_available, is_torc...
287
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE =logging.get_logger(__name__) __SCREAMING_SNAKE_CASE ={ "microsoft/git-base": "https://huggingface.co/microsoft/git...
712
"""simple docstring""" from math import sqrt def lowercase__( __SCREAMING_SNAKE_CASE : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3...
477
0
from collections import defaultdict class UpperCamelCase__ : '''simple docstring''' def __init__( self , UpperCamelCase__ , UpperCamelCase__ ) -> str: lowerCamelCase : str = total # total no of tasks (N) # DP table will h...
311
class lowercase : # Public class to implement a graph def __init__( self : Union[str, Any] , _UpperCamelCase : int , _UpperCamelCase : int , _UpperCamelCase : list[list[bool]] ) -> None: '''simple docstring''' ...
403
0
import operator as op def _lowercase ( lowercase__ ): __lowerCAmelCase : Union[str, Any] = [] __lowerCAmelCase : Optional[int] = lambda lowercase__ , lowercase__ : int(x / y ) # noqa: E731 integer division operation __lowerCAmelCase : Optio...
711
from __future__ import annotations from math import ceil, floor, sqrt def _lowercase ( lowercase__ = 2_0_0_0_0_0_0 ): __lowerCAmelCase : list[int] = [0] __lowerCAmelCase : int for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_nu...
583
0
"""simple docstring""" import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( Autoenco...
102
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) snake_case_ : List[Any] = {"configuration_vit_mae": ["VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMAEConfig"]} try: if not ...
488
0
'''simple docstring''' def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : int ) -> int: return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : Dict ) -> bool: UpperCAmelCase_ : Optiona...
716
'''simple docstring''' import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __a (unittest.Te...
644
0
import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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(): import jax....
17
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar _UpperCAmelCase = TypeVar("T") class _UpperCAmelCase ( Generic[T] ): '''simple docstring''' def __init__( self : Tuple , UpperCamelCase__ : T )...
699
0
import re import string import numpy as np import datasets __UpperCamelCase : List[str] = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' __UpperCamelCase : Optional[Any] = '\nArgs:\n...
34
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import A...
34
1
'''simple docstring''' snake_case = 9.80665 def UpperCAmelCase_ ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ = g ): """simple docstring""" if fluid_density <= 0: raise ValueError("Impossible fluid density" ) if volume < 0: raise ValueError("Impossible Ob...
378
'''simple docstring''' def UpperCAmelCase_ ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ): """simple docstring""" if height >= 1: move_tower(height - 1 , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) move_disk(lowe...
378
1
'''simple docstring''' import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weig...
58
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase_ = {'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMAEConfig''']...
58
1
"""simple docstring""" from math import isclose, sqrt def _SCREAMING_SNAKE_CASE ( UpperCamelCase : float , UpperCamelCase : float , UpperCamelCase : float ): A__ = point_y / 4 / point_x A__ = 2 * normal_gradient...
574
"""simple docstring""" import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertS...
574
1
from __future__ import annotations import math class _a : """simple docstring""" def __init__( self , _snake_case ): _UpperCAmelCase =size # approximate the overall size of segment tree with given value _UpperCAmelCase =[0 for i ...
715
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict" , [ SplitDict(), SplitDict({"train": SplitInfo(name="train" , num_bytes=1337 , num_examples=42 , dataset_name="my_dataset" )} ), Spli...
592
0