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
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. _lowerCamelCase : List[str] = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of t...
121
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : str = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', ...
121
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE : Tuple = { '''configuration_clipseg''': [ '''CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CLIPSegConfig''', '''CLIPSegTextConfig'...
710
import pytest SCREAMING_SNAKE_CASE : Optional[Any] = "__dummy_dataset1__" SCREAMING_SNAKE_CASE : int = "\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\"\nURLS = {\"train\": REPO_URL + \"w...
354
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
583
from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline snake_case__ = logging.get_logger(__name__) ...
583
1
import math import tensorflow as tf from packaging import version def _lowercase ( UpperCamelCase__ : Union[str, Any] ): __A : Dict = tf.convert_to_tensor(UpperCamelCase__ ) __A : Optional[int] = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 ), x.dtype ) ...
713
'''simple docstring''' import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def ...
540
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dataclass class ...
300
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase : List[str] = { '''configuration_conditional_detr''': [ '''CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Condition...
149
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers impor...
717
'''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 ...
40
0
from typing import Any def UpperCamelCase_( _A :list )-> list[Any]: if not input_list: return [] UpperCamelCase__ = [input_list.count(_A ) for value in input_list] UpperCamelCase__ = max(_A ) # Gets the maximum count in the input list. # Gets values of modes ...
551
import re import string import numpy as np import datasets __UpperCamelCase = '\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 = '\nArgs:\n predictions: List o...
551
1
"""simple docstring""" def a ( __UpperCAmelCase : int = 1_0_0_0 ) -> int: __magic_name__: Any = 2**power __magic_name__: Any = str(__UpperCAmelCase ) __magic_name__: str = list(__UpperCAmelCase ) ...
213
"""simple docstring""" from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __A ( SCREAMING_SNAKE_CASE_ ): UpperCAmelCase__ = "ClapFeatureExtractor" UpperCAmelCase__ = ("RobertaTokenizer", "Rob...
213
1
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn fr...
236
'''simple docstring''' from manim import * class A_ ( lowerCAmelCase_ ): def lowercase ( self : Dict ): _UpperCAmelCase = Rectangle(height=0.5 , width=0.5 ) _UpperCAmelCase = Rectangle(height=0.4_6 , width=0.4_6 ...
236
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging __UpperCAmelCase : Dict = logging.get_logger(__na...
712
import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def lowerCamelCase_ ( UpperCamelCase_ = 8 ): _a : int = ascii_letters + digits + punctuation return "".join(secrets.choice(UpperCamelCase_ ) fo...
249
0
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> str: SCREAMING_SNAKE_CASE_ : list[list[str]] = [[] for _ in range(_a )] SCREAMING_SNAKE_CASE_ : Optional[int] = key - 1 if key <= 0: raise ValueError('Height of grid can\'t be 0 or negative' ) if ...
345
def UpperCamelCase ( _a = 1 , _a = 1_0_0_0 ) -> int: '''simple docstring''' lowercase_ :str = 1 lowercase_ :Union[str, Any] = 0 for divide_by_number in range(_a , digit + 1 ): lowercase_ ...
257
0
def lowerCAmelCase ( UpperCamelCase__ : int ) -> bool: """simple docstring""" __SCREAMING_SNAKE_CASE: Tuple = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))...
715
from sklearn.metrics import recall_score import datasets lowerCAmelCase : str = """ Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true positives and FN is the f...
146
0
"""simple docstring""" from statistics import mean import numpy as np def lowercase (_snake_case ,_snake_case ,_snake_case ,_snake_case ) -> Any: '''simple docstring''' __UpperCamelCase = 0 # Number of processes finished __UpperCamelCase = 0 # Display...
505
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class snake_case ( UpperCamelCase_ ): lowercase_ = ['image_processor', 'tokenizer'] lowercase_ = 'AutoImageProcessor' lowercase_ = 'AutoTokenizer' def __init__( self ...
85
0
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def __UpperCamelCase ( ): __UpperCAmelCase : Optional[Any] = HfArgumentParser(_UpperCAmelCase ) __UpperCAmelCase : List[str] = parser.parse_args_i...
329
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" SCREAMING_SNAKE_CASE = '''ClapFeatureExtractor''' SCREAMING_SNAKE_CASE ...
329
1
from numpy import exp, pi, sqrt def UpperCAmelCase_ ( __UpperCamelCase, __UpperCamelCase = 0.0, __UpperCamelCase = 1.0 ): return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__": import doctest doctest.tes...
151
import argparse 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 Accelerator, ...
151
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCAmelCase_ ( metaclass=lowercase__ ): snake_case_ = ["""torch""", """scipy"""] def __init__( self : Any , *_lowercase : str , **_lowercase : Any ) -> Optional[int]: r...
715
"""simple docstring""" import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) __UpperCame...
227
0
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from t...
109
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def __lowerCAmelCase ( UpperCAmelCase__ : str , UpperCAmelCase__ : str , **UpperCAmelCase__ : List[str] ) -> Tuple: lowerCamelCase_ = AutoConfig.from_...
272
0
'''simple docstring''' def _a (__SCREAMING_SNAKE_CASE ): """simple docstring""" _UpperCamelCase =[] _UpperCamelCase =set({'''(''', '''[''', '''{'''} ) _UpperCamelCase =set({''')''', ''']''', '''}'''} ) _UpperCamelCase ={'''{''': '''}''', '''[''':...
271
'''simple docstring''' import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_...
271
1
import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline, ) from...
570
import pytest import datasets # Import fixture modules as plugins UpperCAmelCase_ : Optional[int] = ['tests.fixtures.files', 'tests.fixtures.hub', 'tests.fixtures.fsspec'] def SCREAMING_SNAKE_CASE_ ( __A : Optional[Any] , __A : Dict ) ...
570
1
'''simple docstring''' from __future__ import annotations import math def __snake_case ( SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : bool , SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : float ) -> int: """simple docstr...
570
'''simple docstring''' def __snake_case ( SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int ) -> int: """simple docstring""" if exponent == 1: return base if exponent % 2 == 0: UpperCAmelCase =...
570
1
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _in...
105
"""simple docstring""" def __UpperCamelCase ( snake_case__ = 200 ): A_ : Union[str, Any] = [1, 2, 5, 10, 20, 50, 100, 200] A_ : int = [0] * (pence + 1) A_ : Tuple = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(snake_cas...
180
0
from timeit import timeit _A = { "MALAYALAM": True, "String": False, "rotor": True, "level": True, "A": True, "BB": True, "ABC": False, "amanaplanacanalpanama": True, # "a man a plan a canal panama" } # Ensure our test data is valid assert all((key == key[::-1]) is value for key,...
711
def lowerCamelCase__ ( __lowerCAmelCase : int ): """simple docstring""" if upper_limit < 0: raise ValueError("Limit for the Catalan sequence must be ≥ 0" ) lowerCAmelCase_ = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 lowerCAmelCase...
279
0
import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class _lowercase ( _A ): def __init__( self , a , a=None , a=True , a=None , **a ): sn...
385
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ..utils....
385
1
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version snake_case__ = version.parse(importlib_metadata.version('''nltk''')) if NLTK_VERSION >= version.Version('''3.6.4'''): from nltk import word_tokenize snake_case__ = ...
718
import datasets from .evaluate import evaluate snake_case__ = '''\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={EMNLP}, year={2016} } ''' snake...
373
0
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLD...
3
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vis...
613
0
'''simple docstring''' import json import os import shutil import tempfile import unittest from transformers import BatchEncoding, CanineTokenizer from transformers.testing_utils import require_tokenizers, require_torch from transformers.tokenization_utils import AddedToken from transformers.utils import cach...
267
'''simple docstring''' from __future__ import annotations import math def UpperCAmelCase ( lowerCamelCase_ :list , lowerCamelCase_ :list ): '''simple docstring''' if len(lowerCamelCase_ ) != 2 or len(a[0] ) != 2 or len(lowerCamelCase_ ) != 2 or len(b[0] ) != 2: raise E...
267
1
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 lowerCamelCase_ : Tuple = logging.get_logger(...
559
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": lowerCamelCase_ : List[Any] = pd.read_csv("""sample_data.csv""", header=None) lowerC...
559
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ : Tuple = logging.get_logger(__name__) lowercase__ : List[str] ...
718
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ : Any = logging.get_logger(__name__) lowercase__ : Tuple = ...
485
0
'''simple docstring''' 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_cas...
436
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowerCamelCase__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: ...
225
0
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxG...
720
"""simple docstring""" # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easi...
91
0
"""simple docstring""" import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import...
353
"""simple docstring""" import os from datetime import datetime as dt from github import Github A__ : Tuple = [ 'good first issue', 'good second issue', 'good difficult issue', 'enhancement', 'new pipeline/model', 'new scheduler', 'wip', ] def _lowerCAmelCase ( ): ...
353
1
'''simple docstring''' import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines....
368
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, p...
368
1
"""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 a ( unittest.TestCase ): def UpperCamelCase__ ( self ): ...
4
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping __UpperCamelCase : Optional[Any] = tuple[int, int] class a : def __init__( self , _snake_case , _snake_case ): """simple docstri...
4
1
"""simple docstring""" 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 imp...
494
"""simple docstring""" import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class lowerCAmelCase (...
494
1
'''simple docstring''' from __future__ import annotations def _SCREAMING_SNAKE_CASE ( lowerCamelCase__ : int , lowerCamelCase__ : int ): '''simple docstring''' A: list[list[int]] = [] create_all_state(1 , lowerCamelCase__ , lowerC...
135
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE : Optional[Any...
135
1
def UpperCAmelCase__ ( lowercase__ , lowercase__ , lowercase__ ) -> int: if exponent == 1: return base if exponent % 2 == 0: __lowercase = _modexpt(lowercase__ , exponent // 2 , lowercase__ ) % modulo_va...
705
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ = { "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_torch_ava...
634
0
"""simple docstring""" import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation...
573
"""simple docstring""" import logging from transformers.configuration_utils import PretrainedConfig lowercase = logging.getLogger(__name__) class lowercase__ ( A ): '''simple docstring''' _UpperCAmelCase = '''maske...
573
1
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class __A (datasets.BeamBasedBuilder): '''simple docstring''' def l...
2
"""simple docstring""" from __future__ import annotations def _a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> list[int]: snake_case_ = 0 snake_case_ = len(_SCREAMING_SNAKE_CASE ) - 1 while i < j: if nums[i] + nums[j...
2
1
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path _snake_case = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) _snake_case = [ord(letter) for letter in string.ascii_lowercase] _snake_case ...
382
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase : list[list[int | float]] ) -> int: lowerCamelCase_ = len(_lowerCamelCase ) lowerCamelCase_ = len(matrix[0] ) lowerCamelCase_ = min(_lowerCamelCase , _lowerCa...
549
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vi...
9
'''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.proces...
9
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_sta...
75
import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCamelCase__ =get_tests_dir('fixtures/test_se...
249
0
def UpperCamelCase_( _A :list , _A :list , _A :int , _A :int , _A :int )-> int: if index == number_of_items: return 0 UpperCamelCase__ = 0 UpperCamelCase__ = 0 UpperCamelCase__ = knapsack(_A , _A , _A ,...
719
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/data2vec-text-base': 'https://hug...
185
0
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 AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_tests_d...
344
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> str: """simple docstring""" if isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(SCREAMING_SNAKE_CASE_ , ...
628
0
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : Optional[int] ) -> Tuple: # encoder.embeddings ...
719
import math import sys import cva import numpy as np def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : np.ndarray , SCREAMING_SNAKE_CASE : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. __lowercase = math.sqrt(SCREAMING_SNAKE_CASE...
688
0
"""simple docstring""" import inspect import unittest from transformers import MobileNetVaConfig 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_configuration_common im...
289
"""simple docstring""" from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class UpperCAmelCase_ ( _UpperCamelCase ): def __lt__( self : int , A : Dict ): return ...
289
1
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase ): """simple docstring""" lowerCAmelCase__ : Dict = len(a_ ) print("""The following activities are selected:""" ) # The first activity is always selecte...
713
'''simple docstring''' from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase , UpperCamelCase = 1 / sqrt(2 ) ): """simple docstring""" lowerCAmelCase__ : Option...
160
0
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) _snake_case : Tuple = models.Sequentia...
441
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) _snake_case : Tuple = models.Sequentia...
441
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Dict = {} class _UpperCAmelCase ( lowerCAmelCase__ ): a__ : int = "llama"...
709
"""simple docstring""" import qiskit def lowercase__ ( snake_case_ :int , snake_case_ :int ): __UpperCAmelCase = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register __UpperCAmelCase = qiskit.QuantumCircu...
397
0
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP __UpperCamelCase : List[Any] = False try: __UpperCamel...
80
"""simple docstring""" import argparse import os # New Code # 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_s...
682
0
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class _lowercase (a_ ): '''simple docstring''' def _lowerCamelCase ( self ): '''simple docstring''' return [ {"col_1": 3, "col_2...
719
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
504
0
'''simple docstring''' 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 i...
531
"""simple docstring""" 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 i...
506
0
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __magic_name__ ( ) -> List[Any]: _lowercase : Dict = ArgumentParser( description=( ...
677
from __future__ import annotations from typing import Any class lowerCAmelCase_ : def __init__( self , _lowerCAmelCase ): _lowercase : Any = num_of_nodes _lowercase : list[list[int]] = [] _lowercase : ...
677
1
from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastapi.routi...
23
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_simplif...
23
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase = {'''configuration_xlnet''': ['''XLNET_...
667
'''simple docstring''' import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class A__ ( _snake_case ): lowercase = (IPNDMScheduler,) lowercase = (("num_inference_steps", 50),) def snake_case_ (...
667
1
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class __lowerCAmelCase ( UpperCAmelCase_ ): """simple docstring""" def __init__( self : List[str] , _snake_case : Optional[int] , _snake_case : ...
9
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { '''xlm-mlm-en-2048''': '''https://huggingfa...
154
0
def a ( lowerCamelCase_ , lowerCamelCase_ ): '''simple docstring''' if digit_amount > 0: return round(number - int(lowerCamelCase_ ) , lowerCamelCase_ ) return number - int(lowerCamelCase_ ) if __name__ == "__main__": print(decimal_isol...
716
import argparse import os import re A__ : Optional[int] = 'src/transformers' # Pattern that looks at the indentation in a line. A__ : Union[str, Any] = re.compile(r'^(\s*)\S') # Pattern that matches `"key":" and puts `key` in group 0. A__ : List[str] = re.compil...
671
0
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor...
486
import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class A ( UpperCAmelCase_ , unittest.TestCase ): __UpperCAmelCase : int = DownBlockaD #...
486
1
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...te...
401
"""simple docstring""" _lowerCamelCase = ''' # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.co...
401
1
'''simple docstring''' import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_...
22
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE__ =(IPNDMScheduler,) SCREAMING_SNAKE_CASE__ =(("""num_inference_steps""", 50),...
693
0
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 .tokenization_cam...
707
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...tes...
409
0
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slo...
93
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_ = { 'YituTech/conv-bert-base': 'https://huggingface.co/YituT...
132
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = { "configuration_convbert": ["CONVBERT_PRETRAINED_CONFI...
65
"""simple docstring""" from __future__ import annotations def lowercase ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ) -> list[str]: if partitions <= 0: raise ValueError('''partitions must be a positive number!''' ) if partitions > number_of_bytes: ...
65
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available lowerCamelCase__ : Union[str, Any] = { """configuration_ernie""": ["""ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ErnieConfig""", ...
33
'''simple docstring''' # Function to print upper half of diamond (pyramid) def _lowercase (SCREAMING_SNAKE_CASE ): '''simple docstring''' for i in range(0 , SCREAMING_SNAKE_CASE ): for _ in range(0 , n - i - 1 ): # printin...
111
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( ...
721
'''simple docstring''' import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute_s...
0
0
'''simple docstring''' from numpy import exp, pi, sqrt def A_ ( _lowerCAmelCase : Any , _lowerCAmelCase : float = 0.0 , _lowerCAmelCase : float = 1.0 ): """simple docstring""" return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (...
44
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Dict = logging.get_logger(__name__) _UpperCAmelCase : Op...
668
0
"""simple docstring""" def lowercase (snake_case__ : Any ) -> Any: '''simple docstring''' if not head: return True # split the list to two parts lowerCAmelCase , lowerCAmelCase = head.next, head while fast and fast.next: lowerCAmelCase ...
529
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tokenization_biogpt': ['BioGptT...
529
1
import argparse import os import re __lowerCamelCase : Any = """src/diffusers""" # Pattern that looks at the indentation in a line. __lowerCamelCase : Dict = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. __lowerCamelCase : Tuple ...
385
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 tf from transformers import TFCame...
385
1
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge _SCREAMING_SNAKE_CASE = [ """Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw a cell...
534
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGen...
534
1
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _A ( ): """simple docstring""" import os as original_os from os import path as original_path from os import rename as original_rename from os.path import di...
41
import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime as ort lowe...
345
0
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup A_ :int = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def A ( a_ = "mumbai" ) -> Generator[tuple[str, str], None, None]: ...
154
from collections.abc import Generator def A ( ) -> Generator[int, None, None]: __UpperCamelCase , __UpperCamelCase : Tuple =0, 1 while True: __UpperCamelCase , __UpperCamelCase : Union[str, Any] =b, a + b yield b ...
154
1
'''simple docstring''' import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): i...
517
'''simple docstring''' import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": SCREAMING_SNAKE_CASE_ = argparse.ArgumentParser() parser.add_argument( "--checkpoint_path", default=No...
517
1
'''simple docstring''' from collections.abc import Iterable from typing import Generic, TypeVar lowerCamelCase__ = TypeVar('_T') class _lowerCAmelCase ( Generic[_T] ): '''simple docstring''' def __init__( self : List[str] , UpperCamelCase_ ...
411
'''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 ...
411
1
"""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 ...
698
"""simple docstring""" from __future__ import annotations import math from collections.abc import Callable def __A ( a_ : Callable[[int | float], int | float] , a_ : int | float , a_ : int | float , a_ : int = 1_00 , )-> float: '''simple docstring''' SCREAMIN...
698
1
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.transforms.functional impo...
704
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": __magic_name__ = argparse.ArgumentParser() parser.add_argument( '''--checkpoint_path''', default=None, type=str, required=True, help=''...
530
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 applic...
81
_snake_case : Optional[int] = {"a": ["c", "b"], "b": ["d", "e"], "c": [], "d": [], "e": []} _snake_case : Dict = ["a", "b", "c", "d", "e"] def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): __snake_case ...
81
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/resolve/main/config.json''', } class A_ ( __lowerCamelCase ): ...
565
# 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 applicab...
565
1
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _UpperCamelCase ( unittest.TestCase , _A ): '''simple docstring''' def lowerCAmelCase__ ( self : Tuple ): UpperCamelCase_: List[Any] = ...
548
import heapq import sys import numpy as np lowerCamelCase_ : Optional[Any] = tuple[int, int] class _UpperCamelCase : '''simple docstring''' def __init__( self : Any ): UpperCamelCase_: Union[str, Any] = [] UpperCamelCase_: str = set...
548
1
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() snake_case_ : Tuple = logging.get_logger(__name__) snake_case_ : Tuple = [ ["attention", "at...
169
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def A (__A : Tuple , __A : List[Any]=None ) -> Optional[int]: """simple docstring""" ...
169
1
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowerCAmelCase_ ( snake_case_ : Union[str, Any] ) -> Union[str, Any]: '''simple docstring''' UpperCAmelCase_ = FileLock(str(tmpdir / "f...
78
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeli...
585
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 UpperCAmelCase_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : Union[st...
440
import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class lowercase__ ( __A ): __UpperCamelCase = """M-CLIP""" def __init__( self , _lowercase=1_024 , _lowercase=768 , **_lowercase ): lowerCAmelCase_ ...
440
1
from typing import Dict from .base import GenericTensor, Pipeline class __A ( snake_case_ ): """simple docstring""" def __snake_case ( self , a__=None , a__=None , a__=None , **a__): """simple docstring""" ...
114
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, nested...
417
0
def _a ( _lowerCAmelCase : float ): if edge <= 0 or not isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): raise ValueError("Length must be a positive." ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def _a ( _lowerCAmelCase ...
704
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.processors import TemplateProcessing c...
552
0
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): lowercase = [0] * len(__SCREAMING_SNAKE_CASE ) lowercase = [] lowercase = [1] * len(__SCREAMING_SNAKE_CASE ) for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(__SCREAMING_SNAK...
84
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 FlaxTimestepEmbedding, FlaxT...
84
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase = { """configuration_llama""...
562
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase__ ( _lowerCAmelCase ...
562
1
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 _lowerCAmelCase ( __UpperCamelCase ): """simple ...
654
def SCREAMING_SNAKE_CASE ( _UpperCAmelCase = 200 ) -> int: lowerCamelCase__ : Dict = [1, 2, 5, 10, 20, 50, 100, 200] lowerCamelCase__ : Union[str, Any] = [0] * (pence + 1) lowerCamelCase__ : List[str] = 1 # base case: 1 way to make 0 ...
295
0
def lowerCamelCase_ ( UpperCamelCase__ : List[Any] = 50 ): '''simple docstring''' UpperCamelCase__ = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2, 5 ): for tile_start in r...
712
from __future__ import annotations def lowerCamelCase_ ( UpperCamelCase__ : list[float], UpperCamelCase__ : int ): '''simple docstring''' print(F"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(UpperCamelCase__ ): ...
591
0
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar UpperCamelCase = TypeVar("T") def A ( lowercase__ : int ) -> int: return (position - 1) // 2 def A ( lowercase__ : int ) -> int: return (2 * position) + 1 def A ...
45
"""simple docstring""" # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping th...
361
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 __magic_name__ : List[Any] = logging.get_logger(__name__) __mag...
602
'''simple docstring''' import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration __magic_name__ : Optional[int] = 50_000 __magic_name__ : Tuple = 5_000 __magic_name__ , __magic_name__ : List[Any] = ...
602
1
from __future__ import annotations class _snake_case : def __init__( self: List[Any] , __lowerCamelCase: Union[str, Any]=None ) -> Dict: __UpperCAmelCase : List[Any] = data __UpperCAmelCase : Tuple = None ...
382
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''MIT/ast-finetuned-audioset-10-10-0.4593''': ( '''https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.js...
382
1
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.checkpo...
661
import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available()...
661
1
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __UpperCamelCase ...
633
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_u...
633
1
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.prepr...
690
"""simple docstring""" from sklearn.metrics import recall_score import datasets lowerCAmelCase__ ="\nRecall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:\nRecall = TP / (TP + FN)\nWhere TP is the true positives ...
690
1
'''simple docstring''' # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar _UpperCAmelCase : int = TypeVar('''T''') class __magic_name__ ( Generic[T] ): ...
72
"""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 A = logging.get_logger(__name__) A ...
52
0
"""simple docstring""" import math def lowercase__ ( snake_case_ :int ): if not isinstance(snake_case_ , snake_case_ ): __UpperCAmelCase = F'''Input value of [number={number}] must be an integer''' raise TypeError(snake_case_ ) if number < 1: __...
717
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : Tuple = { 'microsoft/cvt-13': 'https://huggingface.co/microsoft/cvt-13/resolve/main/config...
397
0
'''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(): ...
28
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required b...
165
0
'''simple docstring''' import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE...
88
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> List[Any]: lowercase : Tuple =HfArgumentParser(__magic_name__ ) lowercase : Union[str, Any] =parser....
88
1
"""simple docstring""" from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. a_ = 2_0_0 # Number of elements selected in every generation of evolution. The selection takes # place from best to wor...
76
'''simple docstring''' import operator as op def lowerCAmelCase_ ( __A : int ): '''simple docstring''' snake_case: List[Any] = [] snake_case: Optional[Any] = lambda __A , __A : int(x / y ) # noqa: E731 integer division opera...
329
0
from PIL import Image def _lowerCamelCase ( snake_case ): _lowerCAmelCase = image.size _lowerCAmelCase = 0 _lowerCAmelCase = image.load() for i in range(snake_case_ ): for j in range(snake_case_ ): ...
703
import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurati...
225
0
"""simple docstring""" def SCREAMING_SNAKE_CASE ( __UpperCAmelCase = 1_000_000 ) -> int: SCREAMING_SNAKE_CASE__ = 1 SCREAMING_SNAKE_CASE__ = 1 SCREAMING_SNAKE_CASE__ = {1: 1} for inputa in range(2 , __UpperCAmelCase ): SCREAMIN...
159
import math snake_case__ = 10 snake_case__ = 7 snake_case__ = BALLS_PER_COLOUR * NUM_COLOURS def lowerCamelCase__ ( a : int = 20 ) -> str: """simple docstring""" a__ :List[str] = math.comb(a , a ) a__ :Optional[int] ...
395
0
from __future__ import annotations import os from collections.abc import Mapping _snake_case = tuple[int, int] class lowerCAmelCase_ : """simple docstring""" def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Union[str, Any]: __Up...
719
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def _a ( ) -> Union[str, Any]: ...
567
0