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
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Optional[Any] ...
89
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ ) -> float: if not nums: raise ValueError('List is empty' ) return sum(lowerCamelCase_ ) / len(lowerCamelCase_ ) if __name__ == "__main__": import doctest doctest.testmod()
89
1
import collections import os import re from pathlib import Path UpperCamelCase__ = "src/transformers" # Matches is_xxx_available() UpperCamelCase__ = re.compile(r"is\_([a-z_]*)_available()") # Catches a one-line _import_struct = {xxx} UpperCamelCase__ = re.compile(r"^_import_stru...
548
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase__ = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Pix2StructConfig", "Pix2StructTextConf...
548
1
from timeit import timeit def a ( snake_case__: int ): '''simple docstring''' if number < 0: raise ValueError('''the value of input must not be negative''' ) lowercase_ = 0 while number: number &= number - 1 result += 1 return res...
97
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : Dict = 1 __lowerCamelCase : str = 2 while i * i <= n: __lowerCamelCase : int = 0 while n % i == 0: n //= i multiplicity += 1 n_divisors *= multiplicity + 1 i += 1 if n > 1: ...
669
0
def _a ( UpperCamelCase_ : int = 1_000 ) -> int: """simple docstring""" lowerCAmelCase__ = 3 lowerCAmelCase__ = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: ...
115
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class lowercase__ ( nn.Module ): a_ =42 a_ =42 a_ =0.0 a_ =1 a_ =1 a_ ...
115
1
'''simple docstring''' from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : str = logging.get_logger(__name__) lowercase__ : Tuple = { """huggingface/time-series-transformer-tourism-monthly""": ( ...
98
'''simple docstring''' 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 accel...
150
0
'''simple docstring''' import argparse import datetime def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : str ) -> str: UpperCAmelCase_ : List[str] = { '''0''': '''Sunday''', '''1''': '''Monday''', '''2''': '''Tuesday''', ...
644
'''simple docstring''' def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : list[int] ) -> list[list[int]]: UpperCAmelCase_ : int = [] if len(SCREAMING_SNAKE_CASE__ ) == 1: return [nums.copy()] for _ in range(len(SCREAMING_SNAKE_CASE__ ) ...
644
1
from __future__ import annotations class lowerCamelCase_ : def __init__( self , lowerCamelCase_=None ) -> List[Any]: """simple docstring""" _UpperCamelCase = data _UpperCamelCase = None def __repr__( self ) -> int: ...
147
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = {"""vocab_file""": """vocab.txt"""} ...
147
1
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) lowerCamelCase : List[str] = logging.getLogger(__name_...
684
import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require_tf, require_torch from...
684
1
'''simple docstring''' def A (): _lowerCAmelCase = [] _lowerCAmelCase = 1 while len(__lowerCamelCase ) < 1e6: constant.append(str(__lowerCamelCase ) ) i += 1 _lowerCAmelCase = """""".join(__lowerCamelCase ) retur...
5
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tokenization_comm...
37
0
'''simple docstring''' from __future__ import annotations def _lowerCAmelCase ( _lowerCAmelCase , _lowerCAmelCase )-> float: __UpperCAmelCase = sorted(numsa + numsa ) __UpperCAmelCase , __UpperCAmelCase = divmod(len(_lowerCAmelCase ) , 2 )...
617
'''simple docstring''' import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu _A: Union[s...
617
1
'''simple docstring''' import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class UpperCamelCase__ (a ): '''simple docstring''' _UpperCamelCase = (UnCLIPScheduler,) def UpperCamelCase_ ( self ,**_...
50
'''simple docstring''' import operator def A__ ( __lowerCAmelCase : list , __lowerCAmelCase : bool = False , __lowerCAmelCase : list | None = None ): lowerCamelCase__ = operator.lt if reverse else operator.gt lowerCamelCase__ = solution o...
50
1
"""simple docstring""" from __future__ import annotations def _snake_case ( _snake_case : float , _snake_case : float , _snake_case : float , ) -> tuple[str, float]: '''simple docstring''' if (stress, tang...
505
"""simple docstring""" a = 256 # Modulus to hash a string a = 1_000_003 def _snake_case ( _snake_case : str , _snake_case : str ) -> bool: '''simple docstring''' _A = len(_snake_case ) ...
505
1
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _snake_case = logging.get_logger(__name__) class lowerCAmelCase ( lowercase_ ): def __init__( self :Any , *_lowercase :Dict , **_lowercase :List...
655
from __future__ import annotations class lowerCAmelCase : def __init__( self :Union[str, Any] , _lowercase :List[Any]=None ): '''simple docstring''' lowercase__ = data lowercase__ = None def __repr__( self :Dict ...
655
1
def __lowerCAmelCase ( _UpperCamelCase : int ) -> Optional[int]: '''simple docstring''' SCREAMING_SNAKE_CASE = [0] * len(_UpperCamelCase ) SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = [1] * len(_UpperCamelCase ) for values in graph.values(): for i in v...
673
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokeni...
673
1
'''simple docstring''' import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils i...
72
"""simple docstring""" from ..utils import DummyObject, requires_backends class snake_case ( metaclass=__lowercase ): UpperCAmelCase__ = ['''note_seq'''] def __init__(self , *SCREAMING_SNAKE_CASE_ , **SCREAMING_SNAKE_CASE_ ): """simple docstri...
626
0
import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CLIPTokenizerFast from ut...
703
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def A__ ( __lowerCamelCase = "laptop" ): SCREAMING_SNAKE_CASE_ = F'''https://www.amazon.in/laptop/s?k={product}''' SCREAMING_SNAKE_CASE_ = { '''User-Agent''': '''Mozilla/5.0 (X11;...
597
0
def lowerCamelCase_ ( UpperCamelCase_ , UpperCamelCase_ = " " ): _a : List[str] = [] _a : Union[str, Any] = 0 for index, char in enumerate(UpperCamelCase_ ): if char == separator: split_words.append(string[last_index:ind...
471
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase : List[str] = logging.get_logger(__name__) __UpperCAmelCase : Dict = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.json', } class l...
471
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable A : List[Any] = { "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXJapaneseConfig"], "t...
704
from __future__ import annotations def lowercase_ ( _A : str , _A : list[str] | None = None , _A : dict[str, float] | None = None , _A : bool = False , ): """simple docstring""" lowerCamelCase__ : Tuple = ...
5
0
"""simple docstring""" def __UpperCamelCase ( snake_case__ = 100 ): A_ : Any = 0 A_ : Optional[int] = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "__main__": print(...
180
"""simple docstring""" from __future__ import annotations def __UpperCamelCase ( snake_case__ , snake_case__ ): if len(snake_case__ ) == 0: return False A_ : Union[str, Any] = len(snake_case__ ) // 2 if a_list[midpoint] == item: return True if item < a_li...
180
1
import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer __lowerCAmelCase ...
703
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = { "configuration_time_series_transformer": [ "TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimeSeriesTransformerConfig", ...
129
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import loggi...
506
'''simple docstring''' # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def _A ( A ,A ,A ,A ) -> List[Any]: lowercase : Optional[int] = { "en": "Machine learning is great, isn't it?", "ru": "Машинное обучение - это здорово, не...
372
0
"""simple docstring""" def _snake_case ( _snake_case : Tuple ) -> Union[str, Any]: '''simple docstring''' _A = len(__A ) _A = len(matrix[0] ) _A = min(__A , __A ) for row...
701
"""simple docstring""" def _snake_case ( _snake_case : list , _snake_case : list ) -> float: '''simple docstring''' _validate_point(_snake_case ) _validate_point(_snake_case ) if len(_snake_case ) != len(_sna...
505
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer _snake_case : Tuple = ...
22
'''simple docstring''' import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import...
71
0
"""simple docstring""" from __future__ import annotations def __lowerCamelCase ( lowerCAmelCase__ ,lowerCAmelCase__ ,lowerCAmelCase__ ): A__ = list(range(len(lowerCAmelCase__ ) ) ) A__ = [v / w for v, w in zip(lowerCA...
554
"""simple docstring""" import torch from transformers import AutoModel class snake_case_ ( torch.nn.Module ): """simple docstring""" def __init__( self , __a="sayef/fsner-bert-base-uncased" ): """simple docstring""" ...
554
1
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 __magic_name__ (snake_case_ ): '''simple docstring''' def...
33
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __magic_name__ (snake_case_ ): '''simple docstring''' __lowercase : List[str] = ['image_processor', 'tokenizer'] __lowercase :...
33
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeIm...
705
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def _UpperCAmelCase ( a : List[Any] ): snake_case__ = FileLock(str(tmpdir / """foo.lock""" ) ) snake_case__ = FileLock(str(tmpdir / """foo.lock""" ) ) snake_case__ = 0....
99
0
from collections.abc import Sequence def snake_case ( snake_case__ :Sequence[float] , snake_case__ :float) -> float: return sum(c * (x**i) for i, c in enumerate(snake_case__)) def snake_case ( snake_case__ :Sequence[float] , snake_case__ ...
401
from __future__ import annotations def snake_case ( snake_case__ :list[int]) -> int: if not nums: return 0 _A = nums[0] _A = 0 for num in nums[1:]: _A , _A = ( max_excluding + num, ...
401
1
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_f...
237
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase : List[str] =logging.get_log...
237
1
'''simple docstring''' import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel a__ : Dict = HfApi() a__ : List[str] = {} # fmt: off a__ : Dict = torch.tensor([ -0.7_515, -1.6_883, 0.2_420, 0.0_30...
51
import math import random def UpperCamelCase ( snake_case__ : float , snake_case__ : bool = False ) -> float: if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value __UpperCAmelCase = 0.02 def UpperCamelCase ...
40
0
from abc import ABC, abstractmethod from argparse import ArgumentParser class a ( __lowercase ): @staticmethod @abstractmethod def snake_case_ ( _lowerCAmelCase ): """simple docstring""" raise NotImplementedError() @abstractmethod ...
702
from __future__ import annotations from math import pow, sqrt def lowerCAmelCase ( UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float ) -> dict[str, float]: """simple docstring""" if (resistance, reactance,...
146
0
'''simple docstring''' import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate...
284
'''simple docstring''' def snake_case ( snake_case : list , snake_case : list , snake_case : int , snake_case : int , snake_case : int ) -> int: """simple docstring""" if index == number_of_items: return 0 lowerCAmelCase = ...
284
1
from ...configuration_utils import PretrainedConfig _SCREAMING_SNAKE_CASE : Optional[int] = { '''google/tapas-base-finetuned-sqa''': ( '''https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json''' ), '''google/tapas-base-finetuned-wtq''': ( '''htt...
720
import math class UpperCAmelCase__ : """simple docstring""" def lowercase_ ( self : int , __lowerCamelCase : list[list[float]] , __lowerCamelCase : list[int] ) -> int: SCREAMING_SNAKE_CASE__ = 0.0 SCREAMING_SNAKE_CASE__ = 0.0 f...
472
0
def lowercase( UpperCamelCase_ , UpperCamelCase_ ) -> str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) UpperCamelCase = str(bin(UpperCamelCase_ ) )[2:] # remove the leading "0b" UpperCamelCase ...
537
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 import ( MaxLengthCriteria, MaxNewT...
537
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, ...
99
from math import factorial a__ = {str(digit): factorial(digit) for digit in range(1_0)} def _UpperCAmelCase ( a : int ): if not isinstance(a , a ): raise TypeError("""Parameter number must be int""" ) if number < 0: raise ValueError("""Parameter ...
99
1
def lowerCamelCase_ ( _UpperCamelCase ) -> str: """simple docstring""" snake_case_ : str = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def lowerCamelCase_...
60
from __future__ import annotations def __lowercase( UpperCAmelCase__ ): """simple docstring""" lowerCamelCase = 2 lowerCamelCase = [] while i * i <= n: if n % i: i += 1 else: ...
623
0
'''simple docstring''' def a_ ( __UpperCAmelCase ) -> list: """simple docstring""" snake_case: List[Any] =len(__UpperCAmelCase ) for _ in range(__UpperCAmelCase ): for i in range(_ % 2 , arr_size - 1 , ...
347
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transfor...
347
1
from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
328
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_o...
328
1
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor UpperCamelCase : List[str] = logging.get_logger(__name__) class lowerCamelCase__ ( UpperCAmelCase_ ): def __init__( self : Tuple , *_lowercase : ...
709
"""simple docstring""" def __snake_case ( UpperCamelCase__ , UpperCamelCase__ ) -> int: """simple docstring""" while b: A , A = b, a % b return a def __snake_case ( UpperCamelCase__ , UpperCamelCase__ ) -> int: """simple docst...
91
0
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can als...
190
def UpperCamelCase__( UpperCamelCase__ : str = "The quick brown fox jumps over the lazy dog" , )->bool: A__ = set() # Replace all the whitespace in our sentence A__ = input_str.replace(''' ''' , '''''' ) for alpha in input_str: ...
190
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase : Optional[int] = { "configuration_efficientnet": [ "EFFICIENTNET_PRETRAINED_CO...
715
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models impo...
100
0
from __future__ import annotations def __magic_name__ ( lowerCAmelCase_): '''simple docstring''' lowerCamelCase_ : int = str(lowerCAmelCase_) return n == n[::-1] def __magic_name__ ( lowerCAmelCase_ = 100_0000): '''simple d...
250
from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function __magic_name__ = 1.054_571_817E-34 # unit of ℏ : J * s __magic_name__ = 3E8 # unit of c : m * s^-1 def __magic_name...
250
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE : Dict = { '''configuration_longformer''': [ '''LONGFORMER_PRETRAINED_CONFIG_AR...
704
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class UpperCAmelCas...
472
0
# Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # - generate model_cards - ...
12
from __future__ import annotations class snake_case__ : def __init__( self , UpperCamelCase_ ) -> None: """simple docstring""" a_ : Dict = order # a_{0} ... a_{k} a_ : Union[str, Any] = [1.0] + [0.0] * order...
419
0
lowerCAmelCase = 256 # Modulus to hash a string lowerCAmelCase = 1_000_003 def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> bool: '''simple docstring''' __UpperCAmelCase : List[str] = len(lowercase_ ) __UpperC...
675
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup lowerCAmelCase = """https://www.indeed.co.in/jobs?q=mobile+app+development&l=""" def __SCREAMING_SNAKE_CASE ( lowercase_ = "mumbai" ) -> Generator[tuple[str, ...
675
1
"""simple docstring""" import cva import numpy as np class a__ : def __init__( self :Optional[int] , _lowerCamelCase :Dict , _lowerCamelCase :int ): '''simple docstring''' if k in (0.04, 0.06): UpperCamelCase_ : Optional[Any] =k ...
357
from ...processing_utils import ProcessorMixin class __lowercase ( lowerCamelCase__ ): __UpperCAmelCase = '''SpeechT5FeatureExtractor''' __UpperCAmelCase = '''SpeechT5Tokenizer''' def __init__( self , lowercase...
313
0
import math import tensorflow as tf from packaging import version def lowercase_ (A : Optional[int] ): snake_case__ : Optional[Any] = tf.convert_to_tensor(A ) snake_case__ : Any = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 ) , x.dtype ...
705
def lowercase_ (A : list[int] ): snake_case__ : Tuple = [] if len(A ) == 1: return [nums.copy()] for _ in range(len(A ) ): snake_case__ : str = nums.pop(0 ) snake_case__ : Optional[int] ...
243
0
'''simple docstring''' import copy import re class a__: a_ : Any = '''hp''' a_ : Optional[Any] = {} a_ : str = None @classmethod def _lowercase ( cls , _UpperCAmelCase , _UpperCAmelCase ) -> str: snake_...
538
'''simple docstring''' import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONF...
538
1
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging __lowerCAmelCase = logging.get_logger(__name__) def snake_case_ ( snake_case , snake_case ...
704
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger __lowerCAmelCase = '''<<<<<<< This should probably be modified because it mentions: ''' __lowerCAmelCase = ...
335
0
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
109
"""simple docstring""" import numpy as np def A_ ( snake_case_ : Tuple ,snake_case_ : Any ,snake_case_ : str ,snake_case_ : Optional[int] ,snake_case_ : List[str] ): '''simple docstring''' UpperCamelCase : int = int(np...
499
0
"""simple docstring""" from scipy.stats import spearmanr import datasets lowerCAmelCase_ = '\nThe Spearman rank-order correlation coefficient is a measure of the\nrelationship between two datasets. Like other correlation coefficients,\nthis one varies between -1 and +1 with 0 im...
122
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=A_ ) class __A ( A_ ): '''simple docstring''' lowerCAmelCase ...
122
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer SCREAMING_SNAKE_CASE_ = {'''vocab_file''': '''vocab.txt''', '''tokenizer_f...
426
"""simple docstring""" from __future__ import annotations from scipy.special import comb # type: ignore class a : """simple docstring""" def __init__( self , snake_case_ ) -> Union[str, Any]: _UpperCAmelCase = list_of_points # D...
426
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase_ = { '''configuration_clipseg''': [ '''CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CLIPSegConfig''', '''CLIPSegTextConfig''', '''CLIPSegVisionC...
703
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { '''asapp/sew-tiny-100k''': '''https://huggingface.co/asapp/sew-tiny-100k/resolve/main/config.js...
635
0
'''simple docstring''' import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version __lowerCamelCase : Any = version.parse(importlib_metadata.version('nltk')) if NLTK_VERSION >= version.Version('3.6.4'): from nltk import wo...
404
'''simple docstring''' import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class UpperCAmelCase ( lowercase_): """simple docstring""" lowerCAmelCase_ = (UnCLIPScheduler,) def UpperCamelCase__ ( self : ...
404
1
def snake_case ( UpperCAmelCase : int ): A = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def snake_case ( UpperCAmelCase : int = 1_00 ): A = 1 A = 2 for i in range(2, max_n + 1 ...
110
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup lowerCAmelCase_ = 'https://www.indeed.co.in/jobs?q=mobile+app+development&l=' def snake_case ( UpperCAmelCase : str = "mumbai" ): A = BeautifulS...
110
1
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers.models.wavavec...
678
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, ...
678
1
'''simple docstring''' from __future__ import annotations from typing import TypedDict class UpperCamelCase__ ( lowercase_ ): """simple docstring""" SCREAMING_SNAKE_CASE__ = 42 SCREAMING_SNAKE_CASE__ = 42 def __A ( lowerCamelCase_ ): """simple docstring...
713
'''simple docstring''' def __A ( lowerCamelCase_ ): """simple docstring""" return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def __A ( lowerCamelCase_ ): """simple docstring""" SCREAMING_SNAKE_CASE : Optional[Any] = 0 SCREAMING_SNAKE_CASE : ...
79
0
from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand a__ = logging.get_logger(__name__) # pylint: disable=invalid-name def lowercase ( SCREA...
477
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer ...
477
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig UpperCAmelCase_ : List[Any] = { """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/config.json""", """a...
701
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __A ( UpperCamelCase__ ): UpperCamelCase = """Speech2TextFeatureExtractor""" UpperCamelCase = """Speech2TextTokenizer""" def __i...
367
0
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging...
146
from argparse import ArgumentParser from . import BaseTransformersCLICommand def lowerCamelCase__ ( __A :Optional[int] ): """simple docstring""" return DownloadCommand(args.model ,args.cache_dir ,args.force ,args.trust_remote_code ) class __...
268
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransformerConfig...
117
"""simple docstring""" import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, Lis...
117
1
import math def UpperCAmelCase ( UpperCAmelCase )-> bool: '''simple docstring''' SCREAMING_SNAKE_CASE_ = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(UpperCAmelCase ) def UpperCAmelCase ( UpperCAme...
393
"""simple docstring""" from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("socket.socket" ) @patch("builtins.open" ) def __UpperCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> Optional[Any]: """simple docstring""" ...
163
0
'''simple docstring''' 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 FlaxSchedulerM...
710
'''simple docstring''' UpperCamelCase : Tuple = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)] def A__ ( __lowerCAmelCase : int ): lowerCamelCase__ = 0 while number: # Increased Speed Slightly by checking every 5 digits...
9
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowerCamelCase__ ( metaclass=A__ ): a__ : Optional[Any] = ["""flax"""] def __init__( self , *SCREAMING_SNAKE_CASE , **SCREAMING_SNAKE_CASE ): """simple do...
134
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 AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TOKEN, USER, get...
493
0
'''simple docstring''' import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatur...
710
'''simple docstring''' import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) lowercase__ : Tuple = pytest.mark.integration @pytest.mark.parametrize('...
43
0
import re def _lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' return [char.split() for char in re.split(R'''[^ a-z A-Z 0-9 \s]''' , str_ )] def _lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' A_ ...
203
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMix...
203
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Dict = logging.get_logger(__name__) _a : Tuple = { """google/pix2struct-textcaps-base""": ( """https://huggingface.co/google/pix2struct-...
721
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_availa...
111
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 if is_t...
230
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging lowerCAmelCase = logging.get_logger(__name__) def _lowerCamelCase( lowercase__ , lowercase__ ) -> ...
230
1
'''simple docstring''' from graphs.minimum_spanning_tree_kruskal import kruskal def snake_case_ (): UpperCAmelCase = 9 UpperCAmelCase = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], [8, 6, 6], ...
358
'''simple docstring''' def snake_case_ (_a : list[list[int]] , _a : int , _a : int , _a : list[int] ): # 1. Validate that path exists between current and next vertices if graph[path[curr_ind - 1]][next_ver] == 0: return False ...
358
1
# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't be consider...
253
def lowerCAmelCase_ ( __UpperCAmelCase: float ) -> float: return 10 - x * x def lowerCAmelCase_ ( __UpperCAmelCase: float , __UpperCAmelCase: float ) -> float: # Bolzano theory in order to find if there is a root between a and b ...
253
1
from diffusers.utils.testing_utils import require_onnxruntime @require_onnxruntime class UpperCamelCase : """simple docstring""" pass
707
import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def snake_case ( UpperCAmelCase : List[Any] ): A = [ 'encoder.version', 'decoder.version', 'model.encoder.version', ...
110
0
def _UpperCamelCase ( snake_case__ ) -> Optional[Any]: __UpperCAmelCase : Dict = [] if len(snake_case__ ) == 1: return [nums.copy()] for _ in range(len(snake_case__ ) ): __UpperCAmelCase : List[Any] = nums.pop(0 ) ...
382
from __future__ import annotations def lowercase_ ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : list[str] | None = None ): """simple docstring""" snake_case__ : Optional[int] =word_bank or [] # create a table snake_case__ : ...
381
0
import math def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: int ): assert isinstance(__UpperCamelCase , __UpperCamelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or not number % 2: # Ne...
711
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Trai...
601
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = {"""vocab...
384
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _UpperCAmelCase ( _lowerCamelCase : NDArray[floataa] , _lowerCamelCase : NDArray[floataa] , _lowerCamelCase : list[int] , _lowerCame...
384
1
'''simple docstring''' 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 snake_case_ : Optional[int] = logging.get_logger(__name__) sn...
711
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def __snake_case ( _UpperCAmelCase : Optional[int], _UpperCAmelCase : Tuple, _UpperCAmelCase : Any): UpperCamelCase = 0 if start < end:...
350
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _UpperCamelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: _Uppe...
146
import os import jsonlines import numpy as np from tqdm import tqdm _UpperCamelCase = 2048 _UpperCamelCase = 4096 _UpperCamelCase = 42 _UpperCamelCase = os.environ.pop('''PROCESS_TRAIN''', '''false''') _UpperCamelCase = {'''null''': 0, '''short'''...
146
1
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configur...
714
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBi...
211
0
"""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, get_resize_output_image_size, normalize, rescale, res...
19
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _lowerCAmelCase ( ) -> str: """simple docstring""" A = HfArgumentParser(UpperCamelCase__ ) A = parser.parse_args_into_dataclasses()[0] A = Te...
641
0
from torch import nn class _lowerCAmelCase ( nn.Module ): '''simple docstring''' def __init__( self : Union[str, Any] , UpperCamelCase : Optional[Any] , UpperCamelCase : Dict ): '''simple docstring''' super().__init__...
703
from random import randint, random def lowerCamelCase_ ( lowerCAmelCase: int , lowerCAmelCase: int , lowerCAmelCase: int , lowerCAmelCase: bool = False , lowerCAmelCase: bool = False , lowerCAmelCase: int = 5 , )-> list: _snake_case : Dict ...
669
0
"""simple docstring""" import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging __UpperCamelCase : int = logging.get_logger(__name__) def _SCREAMING_SNAKE_CASE (_Upper...
4
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 from utils_ner ...
61
0
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, ...
714
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCamelCase ) class A( UpperCamelCase ): '''simple docstring''' UpperCamelCase = field(...
651
0
import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase ( _A : ...
491
import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) # pylint: disable=invalid-name class UpperCa...
491
1
'''simple docstring''' from collections import deque def snake_case_ (UpperCamelCase : List[str] ): '''simple docstring''' _a = len(UpperCamelCase ) _a = deque() _a = [False for _ in range(UpperCamelCase )] ...
377
'''simple docstring''' _snake_case : Any = tuple[float, float, float] _snake_case : Optional[int] = tuple[float, float, float] def snake_case_ (UpperCamelCase : Pointad , UpperCamelCase : Pointad ): '''simple docstring''' ...
377
1
import numpy as np import qiskit def __SCREAMING_SNAKE_CASE ( lowercase_ = 8 , lowercase_ = None ) -> Any: '''simple docstring''' __UpperCAmelCase : int = np.random.default_rng(seed=lowerCAmelCase__ ) # Roughly 25% of the qubits ...
462
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slo...
428
0
'''simple docstring''' import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common ...
266
'''simple docstring''' from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def _a ( _lowercase : Optional[Any] , _lowercase : List[Any] ): ...
266
1
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class __SCREAMING_SNAKE_CASE ( lowercase__ ): def __init__( self : str ): '''simple docstring''' # test for the above condition self.test() ...
92
'''simple docstring''' def _lowerCAmelCase ( __magic_name__ : int = 600851475143 ) -> int: try: lowercase : Any =int(__magic_name__ ) except (TypeError, ValueError): raise TypeError('''Parameter n must be int or castable to int.''' ...
92
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __A =logging.get_logger(__name__) __A ={ 'shi-labs/nat-mini-in1k-224': 'https://huggingf...
113
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __A ={ 'configuration_nezha': ['NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NezhaConfig'], } try: if not is_torch_available():...
113
1
from abc import ABC, abstractmethod from argparse import ArgumentParser class _lowercase ( _SCREAMING_SNAKE_CASE ): @staticmethod @abstractmethod def UpperCamelCase ( lowerCamelCase__ : List[Any] ) -> Union[str, Any]: """simple docstring""" raise Not...
203
'''simple docstring''' def A (): for n in range(1 , 1000000 ): yield n * (n + 1) // 2 def A (__lowerCamelCase :List[Any] ): _lowerCAmelCase = 1 _lowerCAmelCase = 2 while i * i <= n: _lowerCAmelCase = 0 while ...
5
0
from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __lowercas...
479
from __future__ import annotations from collections.abc import MutableSequence class __lowercase : def __init__( self : Optional[Any] , __lowerCamelCase : int , __lowerCamelCase : MutableSequence[float] ) -> None: '...
479
1
'''simple docstring''' import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): impor...
5
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Config...
493
0
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class __snake_case( ...
237
"""simple docstring""" from ...configuration_utils import PretrainedConfig lowerCamelCase : Optional[Any] ={ '''google/tapas-base-finetuned-sqa''': ( '''https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json''' ), '''google/tapas-base-fine...
237
1
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class UpperCAmelCase_ ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" snake_case = (DDPMScheduler,) def _lowercase ( self , **Up...
508
'''simple docstring''' import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel lowercase__ = HfApi() lowercase__ = {} # fmt: off lowercase__ = torch.tensor([ -0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1.3433, -1.1743, -3.7467, ...
508
1
"""simple docstring""" UpperCamelCase_ : int = { '''Pillow''': '''Pillow''', '''accelerate''': '''accelerate>=0.11.0''', '''compel''': '''compel==0.1.8''', '''black''': '''black~=23.1''', '''datasets''': '''datasets''', '''filelock''': '''filelock''', '''flax''': '''flax>=0...
482
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.u...
482
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __a = { 'configuration_bloom': ['BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BloomConfig', 'BloomOnnxConfig'], } try: if not is_tokenizers_available()...
30
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, MusicgenProcesso...
375
0
def lowerCAmelCase_ ( lowercase: int ) -> int: '''simple docstring''' _UpperCamelCase: str = 1 for i in range(1 , num + 1 ): fact *= i return fact def lowerCAmelCase_ ( lowercase: int ) -> int: '''simple docstring''' _UpperCamelCa...
264
def lowerCAmelCase_ ( lowercase: int = 10**9 ) -> int: '''simple docstring''' _UpperCamelCase: List[Any] = 1 _UpperCamelCase: Dict = 2 _UpperCamelCase: Tuple = 0 _UpperCamelCase: int = 0 _UpperCamelCase: Dict = 0 while perimeter <=...
264
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowercase : int = { 'configuration_graphormer': ['GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GraphormerConfi...
49
'''simple docstring''' import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import ...
685
0
_lowercase : Any ='''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def A__ ( ) -> None: A : Dict =input('Enter message: ' ) A : Union[str, Any] =input('Enter key [alphanumeric]: ' ) A : Any =input('Encrypt/Decrypt [e...
661
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 ...
661
1
import numpy as np def lowercase__ ( A_: np.ndarray ) -> np.ndarray: """simple docstring""" return 1 / (1 + np.exp(-vector )) def lowercase__ ( A_: np.ndarray ) -> np.ndarray: """simple docstring""" return ...
68
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A_ ( unittest.TestCas...
67
0
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multiple repository ch...
718
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ = { '''configuration_blenderbot''': [ '''BLENDERBOT_PRETRAINED_CONFIG...
264
0
import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin SCREAMING_SNAKE_CASE : Any = get_tests_dir("fixtures/test_sentencepiece_wit...
635
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE : Union[str, Any] = { "configuration_bridgetower": [ "BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP", "BridgeTowerConfig...
635
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimen...
704
from bisect import bisect from itertools import accumulate def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): lowercase = sorted(zip(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAK...
565
0