code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, skip_mps, ...
326
import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql import sql...
32
0
from __future__ import annotations def a ( SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : int ): """simple docstring""" UpperCamelCase : Tuple = list(rang...
360
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avail...
315
0
'''simple docstring''' import unittest from transformers import AutoTokenizer, FalconConfig, 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_m...
145
'''simple docstring''' import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, ...
145
1
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> list: lowerCAmelCase__ : int = word.split() def justify(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> str: lowerCAmelCase__ : Any ...
307
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCamelCase__ = { """configuration_blip""": [ """BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", ""...
307
1
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean A__ : Tuple = 0 A__ : Any = [ [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, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0...
207
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 ...
207
1
'''simple docstring''' import unittest from transformers import BertGenerationTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin _lowerCamelCase...
366
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimensio...
337
0
from __future__ import annotations def A ( _UpperCAmelCase : str , _UpperCAmelCase : list[str] | None = None ) -> list[list[str]]: '''simple docstring''' _UpperCAmelCase = word_bank or [] # create a table _UpperCAmelCase = len(_UpperCAme...
339
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_files, create_dummy_object, find_backend, re...
339
1
import random def UpperCamelCase__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase = False ): """simple docstring""" _lowerCAmelCase = {i: [] for i in range(_UpperCamelCase )} # if probability is greater or equal than...
359
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: A__ : Tuple =None try: import msvcrt except ImportError: A__ : str =None try: impo...
220
0
'''simple docstring''' from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass a__ : Union[str, Any] =(3, 9, -11, 0, 7, 5, 1, -1) a__ : Optional[int] =(4, 6, 2, 0, 8, 10, 3, -2) @dataclass class snake_case : """si...
53
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def _snake_case ( _snake_case : list[list[float]] ): lowerCAmelCase : str = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implement...
60
0
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a_ = 6378137.0 a_ = 6356752.314245 a_ = 6_3_7_8_1_3_7 def _a( UpperCamelCase__ : float, UpperCamelCase__ : float, UpperCamelCase__ : float...
222
'''simple docstring''' import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger a_ = get_logger(__name__) a_ = R'\n Args:\n input_ids (`jnp.ndarray` of shape `(batch_size, s...
222
1
"""simple docstring""" from __future__ import annotations import time lowerCamelCase_ = list[tuple[int, int]] lowerCamelCase_ = [ [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, 0, 0], [0, 0, 1, 0, 0, 0,...
191
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = {} class _SCREAMING_SNAKE_CASE( A ): SCREAMING_SNAKE_CASE_ : List[Any] ...
191
1
'''simple docstring''' import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision...
199
'''simple docstring''' import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets _snake_case = '\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Languag...
199
1
'''simple docstring''' from collections.abc import Sequence def _A ( A__ , A__ ): """simple docstring""" return sum(c * (x**i) for i, c in enumerate(A__ ) ) def _A ( A__ , A__ ): """simple docstring""" __lowercase = 0.0 for c...
104
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pip...
214
0
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version snake_case : List[str] = { '''<''': operator.lt, '''<=''': operator.le, '''==''': operator.eq, '''!=''': operator.ne, '''>=''': operator.ge, '''>''...
362
from __future__ import annotations def __lowercase ( __lowerCAmelCase : List[Any] , __lowerCAmelCase : Optional[Any] , __lowerCAmelCase : str , __lowerCAmelCase : List[str] ): # noqa: E741 while r - l > 1: a__ = (l + r...
109
0
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, require_t...
10
"""simple docstring""" import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils im...
315
0
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2...
157
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig 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_configuration_common imp...
157
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logg...
3
'''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 Image ...
258
0
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class UpperCamelCase_ ( __magic_name__ ): lowercase = (DDPMScheduler,) def _lowercase( self , **A ) -> int: UpperCAmelCase ...
356
'''simple docstring''' from math import loga def __lowerCamelCase ( _lowercase ) -> int: if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(_lowercase , _lowercase ): raise TypeError("""Input value must be...
338
0
def a ( _UpperCAmelCase : Optional[Any] = 4_00_00_00 ): '''simple docstring''' __UpperCAmelCase : int = [] __UpperCAmelCase : str = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(_UpperCamel...
226
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 __SCREAMING_SNAKE_CASE ( A__ ): A : Union[List[np....
337
0
import requests from bsa import BeautifulSoup def _A ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : dict ): """simple docstring""" a__ : Optional[Any] =BeautifulSoup(requests.get(SCREAMING_SNAKE_CASE , params=SCREAMING_SNAKE_CASE ).cont...
148
UpperCAmelCase : Dict = [0, 2, 4, 6, 8] UpperCAmelCase : Tuple = [1, 3, 5, 7, 9] def _A ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : list[int] , SCREAMING_SNAKE_CASE : int ): "...
148
1
"""simple docstring""" import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoder...
40
"""simple docstring""" # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class a ( a_ ): def __init__( self , _lowerCamelCase , _lowerCamelCase ): super()...
220
0
"""simple docstring""" import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_co...
38
"""simple docstring""" from __future__ import annotations from collections.abc import MutableSequence class lowerCAmelCase : '''simple docstring''' def __init__( self , lowerCAmelCase__ , lowerCAmelCase__ ) -> None: if len(lowerCAme...
38
1
from collections.abc import Callable def a_ ( _A , _A , _A ) -> float: """simple docstring""" snake_case__ = a snake_case__ = b if function(_A ) == 0: # one of the a or b is a root for the function ...
307
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) warnings.war...
307
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils impor...
355
'''simple docstring''' from ..utils import DummyObject, requires_backends class _snake_case ( metaclass=lowercase_ ): lowerCAmelCase_ : Dict = ["flax"] def __init__( self , *a__ , **a__ ) -> List[Any]: '''simple docstring''' ...
92
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowercase__ : Tuple = logging.get_logger(__name__) class UpperCAmelCase ( lowerCamelCase_ , ...
187
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _UpperCamelCase ( ): '''simple docstring''' import os as original_os from os import path as original_path from os import rename as original_rename from os.path im...
346
0
import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPriorPipeline, PriorTransfo...
355
_UpperCAmelCase = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} _UpperCAmelCase = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :dict[int, list[int]] , SCREAMING_SNAKE_CASE :int , SCREAMING_SNAKE_CAS...
232
0
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 _lo...
14
"""simple docstring""" from __future__ import annotations class SCREAMING_SNAKE_CASE__ : def __init__( self , _SCREAMING_SNAKE_CASE ) -> None: '''simple docstring''' UpperCAmelCase : Any = data UpperCAmelCase : Node | None = None UpperCAmelCase : ...
109
0
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class __A ( a ): def _snake_case ( self , UpperCAmelCase_ ): with open(UpperCAmelCase_ , encoding="""utf-8""" ) as input_file: lowerCamelCase ...
358
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, ...
262
0
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 _snake_case = ( '''This metric will be removed from the library soon, metrics should b...
157
def _UpperCamelCase ( snake_case__ ) -> bool: if not isinstance(snake_case__, snake_case__ ): raise ValueError("check_bouncy() accepts only integer arguments" ) __UpperCAmelCase : Optional[int] = str(snake_case__ ) __UpperCAmelC...
157
1
import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching betwee...
362
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_rou...
282
0
'''simple docstring''' from math import factorial class a__: def __init__( self : Optional[Any] , __snake_case : List[str] , __snake_case : Dict ): a : str = real if isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): ...
297
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...tes...
338
0
"""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():...
356
import argparse import struct import unittest class _snake_case : def __init__( self: Tuple , __lowerCamelCase: bytes ) -> None: __UpperCAmelCase : Tuple = data # Initialize hash values __UpperCAmelCase : An...
342
0
"""simple docstring""" def UpperCamelCase__ ( lowercase__ : int ): snake_case : List[Any] = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def UpperCamelCase__ ( lowercase__ : int = 5000 ): snake_case : Dict = [(i * (3 ...
148
"""simple docstring""" import torch from diffusers import StableDiffusionPipeline __A = "path-to-your-trained-model" __A = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("cuda") __A = "A photo of sks dog in a bucket" __A ...
148
1
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin UpperCAm...
267
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeniz...
267
1
# Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def SCREAMING_SNAKE_CASE_ ( __magic_name__ : Dict ) -> Any: """simple docstring""" return 1...
38
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils im...
38
1
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def A ( snake_case :int , snake_case :int , snake_case :int , snake_case :int , snake_case :int , snake_case :int ) -> np.ndarray...
263
"""simple docstring""" def A ( snake_case :int ) -> int: __UpperCamelCase = abs(snake_case ) __UpperCamelCase = 0 while n > 0: res += n % 1_0 n //= 1_0 return res def A ( snake_case :int ) -> int: __UpperCamelCase = abs(snake_case ) ...
263
1
"""simple docstring""" from math import pi, sqrt def lowercase_ ( _snake_case ): if num <= 0: raise ValueError("""math domain error""" ) if num > 171.5: raise OverflowError("""math range error""" ) elif num - int(_snake_case ) no...
25
import argparse import os import re import packaging.version UpperCamelCase__ = """examples/""" UpperCamelCase__ = { """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), """init""": (re.compile(R"""^__version__\s...
92
0
"""simple docstring""" from __future__ import annotations lowerCamelCase__ = 10 def __lowerCAmelCase (_UpperCamelCase ): __lowerCAmelCase : List[Any] = 1 __lowerCAmelCase : Dict = max(_UpperCamelCase ) while placement <= max_digit: # declare ...
371
"""simple docstring""" lowerCamelCase__ = """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 imp...
182
0
"""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 __magic_name__ ( __lowercase ...
291
import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPriorPipeline, Pr...
232
0
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, require_pytes...
355
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { "facebook/s2t-wav2vec2-large-en-de": ( "https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/config.json" ), # See a...
87
0
"""simple docstring""" from __future__ import annotations UpperCAmelCase__ : Union[str, Any] = list[tuple[int, int]] UpperCAmelCase__ : Any = [ [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, 0...
25
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import to...
262
0
"""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, is_tpu_available from .tra...
73
"""simple docstring""" import argparse from collections import defaultdict def lowerCAmelCase_( lowercase_ : str , lowercase_ : Dict , lowercase_ : Tuple , lowercase_ : str , lowercase_ : str ) -> Optional[int]: _low...
73
1
"""simple docstring""" from collections import deque def UpperCAmelCase ( UpperCAmelCase ) -> int: snake_case_ = len(UpperCAmelCase ) snake_case_ = deque() snake_case_ = [False for _ in range(UpperCAmelCase )] snake_c...
69
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_torch class S...
282
0
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class a ( __lowerCamelCase ): __lowerCAmelCase : ...
44
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, ...
44
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { """mi...
296
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class UpperCamelCase__ ( lowerCAmelCase_ ): '''simple docstring''' def __init__( self : Un...
296
1
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> List[str]: if density <= 0: raise ValueError('Impossible fluid density' ) if bulk_modulus <= 0: raise ValueError('Impossible bulk modulus' ) return (bulk_modulus / density) ** 0.5 if __name__...
370
from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( AutoConfig, ...
113
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) snake_case_ = {"""configuration_encoder_decoder""": ["""EncoderDecoderConfig"""]} try: if not is_torch...
24
import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py _UpperCAmelCase : Optional[int] ="""src/transformers""" _Up...
262
0
import math import os import sys def UpperCamelCase ( _A ): """simple docstring""" __magic_name__ : Dict = """""" try: with open(_A, """rb""" ) as binary_file: __magic_name__ : Optional[int] ...
138
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onn...
138
1
'''simple docstring''' from __future__ import annotations from collections.abc import Callable def __UpperCAmelCase ( A : Callable[[int | float], int | float] , A : int | float , A : int | float , A : int = 1_0_0 , ) -> float: UpperCAm...
304
'''simple docstring''' import logging from transformers.configuration_utils import PretrainedConfig _UpperCamelCase : Any = logging.getLogger(__name__) class snake_case__ ( UpperCamelCase): a_ = "masked_bert" def __init__( self : str , _A : ...
304
1
'''simple docstring''' import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder SCREAMING_SNAKE_CASE_: Union[str, Any] ='__DUMMY_TRANSFORMERS_USER__' SCREAMING_SNAKE_CASE_: Optional[Any] ='Dummy User' SC...
367
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowerCAmelCase_ ( snake_case_ : Union[str, Any] ) -> Optional[int]: '''simple docstring''' UpperCAmelCase_ = FileLock(str(tmpdir / "foo.lock" ...
106
0
"""simple docstring""" import argparse from collections import defaultdict import yaml _lowercase = 'docs/source/en/_toctree.yml' def _snake_case ( snake_case__ : str ): A = defaultdict(_lowercase ) A = [] A = [] for doc in doc_list: ...
74
from math import ceil def A ( _lowercase = 1_001 ): SCREAMING_SNAKE_CASE : Any = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): SCREAMING_SNAKE_CASE : Union[str, Any] = 2 * i + 1 SCREAMING_SNAKE_CASE ...
182
0
'''simple docstring''' import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() A : int = logging.get_logger(__name__) A : List[Any] = {name: getattr(transformers...
367
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A : Optional[int] = { '''configuration_mask2former''': [ '''MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '...
227
0
'''simple docstring''' from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default...
80
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class snake_case_ ( __A ): __A :...
87
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule __SCREAMING_SNAKE_CASE : str = {"tokenization_wav2vec2_phoneme": ["Wav2Vec2PhonemeCTCTokenizer"]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: i...
359
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator class __A : '''simple docstring''' def __init__( self : Any , UpperCAmelCase_ : int ) ->None: """simple docstring""" snake...
233
0
# Copyright 2021 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 requ...
73
from __future__ import annotations import time a =list[tuple[int, int]] a =[ [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, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, ...
73
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCamelCase = { 'configuration_wav2vec2': ['WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Wav2Vec2C...
221
from __future__ import annotations UpperCamelCase = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def _A ( lowerCAmelCase_ : list[list[int]] , lowerCAmelCase_ : list[int] , lowerCAmelCase_ : list[i...
221
1
"""simple docstring""" 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 : Optional[Any] = 'src/transformers' _a ...
44
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Any ) -> List[Any]: # noqa: E741 _lowerCAmelCase : Optional[int] = len(_lowerCamelCase ) _lowerCAmelCase : str = 0 _lowerCAmelCase : Any = [0] * n ...
44
1
# 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 require...
369
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( _a): '''simple docstring''' __UpperCamelCase : int = ["image_processor", "tokenizer"] __UpperCamelCase : List[st...
315
0
class __lowerCamelCase : """simple docstring""" def __init__( self , UpperCAmelCase ): """simple docstring""" _UpperCAmelCase = val _UpperCAmelCase = None _UpperCAmelCase = None def ...
39
"""simple docstring""" def lowercase (SCREAMING_SNAKE_CASE_ : int = 10_00 ) -> int: SCREAMING_SNAKE_CASE = 2**power SCREAMING_SNAKE_CASE = 0 while n: SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = ...
113
0
'''simple docstring''' import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class lowercase : """simple docstring""" UpperCAmelCase = None def _snake_case ( self ) -> ...
360
'''simple docstring''' from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class lowercase ( _lowerCamelCase ): """simple docstring""" de...
349
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : Union[str, Any] = logging.get_logger(__name__) __A : Optional[int] = {...
138
__A : dict[tuple[int, int, int], int] = {} def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ) -> int: '''simple docstring''' if late == 3 or absent == 2: return 0 # if we have no days left, and have not failed any...
138
1
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class _A ( tf.keras.optimizers.schedules.LearningRateSchedule ): ...
116
import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig lowerCAmelCase_ = { 'facebook/maskformer-swin-base-ade': ( ...
116
1
from __future__ import annotations _lowerCamelCase : Optional[Any] = 1.60_21E-19 # units = C def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , ) -> tuple[str, float]: """simple docstring""" if (conductivity, electron_conc, mobilit...
14
"""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 # ...
106
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCamelCase__ ( metaclass=lowercase_ ): """simple docstring""" _SCREAMING_SNAKE_CASE = ["""transformers""", """torch""", """note_seq"""] ...
289
"""simple docstring""" import logging from transformers.configuration_utils import PretrainedConfig lowercase__ : List[Any] = logging.getLogger(__name__) class UpperCamelCase__ ( lowercase_ ): """simple docstring""" ...
289
1
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_ver...
231
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient __UpperCAmelCase = WebClient(token=os.environ["CI_SLACK_BOT_TOKEN"]) def A__ ( __lowerCamelCase ): SCREAMING_SNAK...
299
0
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class UpperCamelCase ( lowercase__ , uni...
252
from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokeni...
252
1
'''simple docstring''' 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_a...
200
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : Optional[int] = { 'google/canine-s': 'https://huggingface.co/google/canine-s/resolve/main/config.json', ...
200
1
'''simple docstring''' import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMSc...
359
'''simple docstring''' import re from filelock import FileLock try: import nltk lowerCAmelCase_ : Optional[int] = True except (ImportError, ModuleNotFoundError): lowerCAmelCase_ : Tuple = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: ...
346
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_li...
221
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCamelCase = { "configuration_chinese_clip": [ "CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "Chinese...
221
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase : int = { 'configuration_blip': [ 'BLIP_PRETRAINED_CONFIG_AR...
251
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Tuple = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', ...
251
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = { 'configuration_mgp_str': ['MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MgpstrConfig'], 'processing_mgp_str': ['MgpstrProcessor'], ...
243
"""simple docstring""" import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor a = logging.getLogger(__name__) a = 50 # max width of layer name...
315
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 required by appl...
366
from math import factorial class __lowerCAmelCase : def __init__( self: Optional[int] , _lowerCAmelCase: List[str] , _lowerCAmelCase: Tuple ): lowercase :str = real if isinstance(_lowerCAmelCase , _lowerCAmelCase ): lowercase ...
158
0
'''simple docstring''' import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, B...
254
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowercase_ ( lowerCAmelCase__ : Union[str, Any] ): """simple docstring""" __UpperCAmelCase : Optional[int] = FileLock(str(tmpdi...
254
1
"""simple docstring""" A_ : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.609344, "knot": 1.852, } A_ : dict[str, float] = { "km/h": 1.0, "m/s": 0.277777778, "mph": 0.621371192, "knot": 0.539956803, } def lowerCamelCase_ ( _lowe...
362
"""simple docstring""" from __future__ import annotations def lowerCamelCase_ ( _lowerCamelCase , _lowerCamelCase ): lowerCamelCase__ : list[list[int]] = [] lowerCamelCase__ : list[int] = [] lowerCamelCase__ : List[str] = ...
316
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE_:Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:Dict = { """facebook...
116
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor impor...
116
1
def lowerCamelCase ( a_ ): lowerCAmelCase_ = [0] * len(a_ ) lowerCAmelCase_ = [] lowerCAmelCase_ = [1] * len(a_ ) for values in graph.values(): for i in values: indegree[i] +...
360
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor lowerCamelCase_ ...
14
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import torc...
289
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_availa...
289
1
'''simple docstring''' import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { ...
43
'''simple docstring''' from collections import deque from math import floor from random import random from time import time class UpperCAmelCase_ : """simple docstring""" def __init__( self : Dict ): snake_case__ : List[str] = {} def lowerCame...
43
1
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor UpperCAmelCase : Optional[Any] = ...
252
from __future__ import annotations def __lowerCamelCase ( lowerCamelCase__ : int , lowerCamelCase__ : int ): '''simple docstring''' if b == 0: return (1, 0) ((lowerCamelCase) , (lowerCamelCase)) = extended_euclid(lowerCamelCase__ , a % b...
252
1
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 ( SegformerConfig, SegformerForImageClassification, SegformerForSemanticSegmentation, S...
367
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase : Union[str, Any] = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} try: ...
70
0
# Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def UpperCAmelCase ( lowercase ): """simple docstring""" return 1 / (1 + np.exp(-z )) ...
210
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __a : int = logging.get_logger(__name__) __a : str = { """ut/deta""": """https://huggingface.co/ut/deta/resolve/main/config.json""", } class _UpperCamelCa...
210
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as...
358
'''simple docstring''' lowerCAmelCase : List[str] = """ # 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...
25
0
'''simple docstring''' import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness UpperCamelCase_ = "\\n@misc{chen2021evalu...
251
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "microsoft/git-base": "https://huggingface...
251
1
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record _lowerCamelCase : Optional[int] = "\\n@article{wang2019superglue,\n title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems},\n author={W...
159
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin _lowerCamelCase : str = "\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenag...
159
1
'''simple docstring''' from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWith...
174
'''simple docstring''' from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder _SCREAMING_SNAKE_CASE = datasets.utils.logging.get_logger(__name__) class lowerCAmelCase_ ( folder_based_builde...
158
0
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def A_( A : List[str]): UpperCamelCase = FileLock(str(tmpdir / 'foo.lock')) UpperCamelCase = FileLock(str(tmpdir / 'foo.lock')) U...
370
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise O...
251
0
"""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 _snake_case : Dict = logging.getLogg...
292
"""simple docstring""" import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL UpperCamelCase : Union[str, Any] = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") def ...
316
0
def UpperCAmelCase ( a_ ) -> float: """simple docstring""" if not nums: # Makes sure that the list is not empty raise ValueError("List is empty" ) __A = sum(a_ ) / len(a_ ) # Calculate the average return sum(abs(x - average ...
124
from math import log from scipy.constants import Boltzmann, physical_constants SCREAMING_SNAKE_CASE :Dict = 300 # TEMPERATURE (unit = K) def UpperCAmelCase ( a_ , a_ , a_ , ) -> float: """simple docstring""" if donor_conc <= 0: r...
124
1
"""simple docstring""" def _snake_case ( lowerCamelCase__ : Union[str, Any] ) -> int: assert column_title.isupper() lowerCamelCase_ : int =0 lowerCamelCase_ : str =len(lowercase_ ) - 1 lowerCamelCase_ : Union[str, ...
144
from ...processing_utils import ProcessorMixin class UpperCamelCase_ ( UpperCAmelCase__ ): '''simple docstring''' UpperCAmelCase__ = '''SpeechT5FeatureExtractor''' UpperCAmelCase__ = '''SpeechT5Tokenizer''' def __init__( self : Any , UpperC...
14
0
"""simple docstring""" from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): from...
361
"""simple docstring""" import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processor...
254
0
import argparse import json from tqdm import tqdm def lowerCamelCase ( ): '''simple docstring''' __UpperCamelCase :Tuple = argparse.ArgumentParser() # Required parameters parser.add_argument( '''--src_path''' , type=SCREAMING_SNAKE_CASE , default='''biencoder-nq-dev...
43
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { '''facebook/wav2vec2-base-960h''': '''https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json''',...
43
1
'''simple docstring''' import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets _UpperCamelCase = datasets.logging.get_logger(__name__) _UpperCamelCase = '''\\n@I...
366
'''simple docstring''' import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configura...
16
0
'''simple docstring''' lowerCamelCase_ = '''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3.7'''): raise ImportWarning( '''To use `datasets`, Python>=3.7 is required, and the current version...
79
'''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 UpperCAmelCase : _lowercas...
70
0
from __future__ import annotations def lowerCAmelCase_ ( __A ) -> float: '''simple docstring''' if not nums: raise ValueError("List is empty" ) return sum(__A ) / len(__A ) if __name__ == "__main__": im...
365
# Lint as: python3 import itertools import os import re UpperCamelCase__ = re.compile(R'([A-Z]+)([A-Z][a-z])') UpperCamelCase__ = re.compile(R'([a-z\d])([A-Z])') UpperCamelCase__ = re.compile(R'(?<!_)_(?!_)') UpperCamelCase__ = re.compile(R'(_{2,})') UpperCamelCas...
143
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ = logging.get_logger(__name_...
96
"""simple docstring""" import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class lowerCAmelCase_ (unittest.TestCase ): """simple docstring""" ...
25
0
'''simple docstring''' import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFl...
8
'''simple docstring''' import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __A : Optional[int] = logging.get_logger(__name__) class __UpperCamelCase ( lowercase__ ): def __init__( self :List[str] ,*_Upp...
8
1
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE :Tuple = logging.getLo...
159
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, ...
159
1
'''simple docstring''' def __UpperCAmelCase ( a_: List[str] = 1_000 ) -> Optional[Any]: _UpperCAmelCase , _UpperCAmelCase : Union[str, Any] = 1, 1 _UpperCAmelCase : str = [] for i in range(1, n + 1 ): _UpperCAmelCase ...
352
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def __UpperCAmelCase ( a_: str ): for param in module.parameters(): _UpperCAmelCase : Any = False def __UpperCAmelCase ( ): _UpperCAmelCa...
17
0
"""simple docstring""" def a__ ( SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' lowerCAmelCase : List[Any] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1...
108
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_...
219
0
from __future__ import annotations def UpperCAmelCase ( UpperCamelCase__ ): """simple docstring""" A__ = str(lowerCAmelCase__ ) return n == n[::-1] def UpperCAmelCase ( UpperCamelCase__ = 1_000_000 ): ...
366
"""simple docstring""" import os def UpperCAmelCase ( ): """simple docstring""" with open(os.path.dirname(UpperCamelCase__ ) + '/grid.txt' ) as f: A__ = [] # noqa: E741 for _ in range(20 ): ...
154
0