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 typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A_ : Tuple = { 'configuration_distilbert': [ ...
57
'''simple docstring''' import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def snake_case_ ( __snake_case : Union[str, Any] , __snake_case : Union[str, Any]=False) -> Optional[int]: lowerCAmelCase_ = ...
274
0
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch...
714
'''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 : Optional[int] = logging.get_logger(__name__) __A...
187
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowercase : List[Any] = logging.get_logger(__name__) lowercase : Dict = { """shi-labs/dinat-mini-in1k-22...
302
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.dataclas...
302
1
from string import ascii_lowercase, ascii_uppercase def lowerCamelCase__ ( a : str ) -> str: """simple docstring""" if not sentence: return "" a__ :str = dict(zip(a , a ) ) return lower_to_upper.get(sentence[0] , sentence[0] ) + sentence[1:] if __name_...
373
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
1
"""simple docstring""" def a__ ( lowerCAmelCase , lowerCAmelCase ) -> Optional[int]: UpperCAmelCase__ : Optional[int] = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def a__ ( ...
182
"""simple docstring""" # limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils impo...
182
1
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger __A : int = get_logger(__name__) class UpperCAmelCase_ ( enum.Enum ): '''simple docstring''' a__ = '''all_check...
706
from __future__ import annotations def lowerCamelCase_ ( SCREAMING_SNAKE_CASE ): '''simple docstring''' create_state_space_tree(SCREAMING_SNAKE_CASE , [] , 0 , [0 for i in range(len(SCREAMING_SNAKE_CASE ) )] ) def lowerCamelCase_ ( SCREAMING_SNAKE_CASE , SCREAMIN...
450
0
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...utils...
40
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTConfig''',...
40
1
from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) a = _symbol_database.Default(...
713
from typing import Dict, Iterable, 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, resize, to_channel_dimension_for...
650
0
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class A_ : @property def _lowercase ( self ): '''simple docst...
130
import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extraction_common import SequenceFeatureExtract...
130
1
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import ...
716
"""simple docstring""" import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging __A = logging.get_logger(__name__) def __A (_SCREAMING_SNAKE_CASE=None , _SCREAMING_SNAKE_CASE=...
560
0
import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sentencepiece @slow #...
362
_UpperCAmelCase : Any = 6_5521 def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ = 1 snake_case_ = 0 for plain_chr in plain_text: snake_case_ = (a + or...
362
1
"""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, WavaVecaFeat...
275
"""simple docstring""" # Lint as: python3 import itertools import os import re UpperCAmelCase__ = re.compile(r"""([A-Z]+)([A-Z][a-z])""") UpperCAmelCase__ = re.compile(r"""([a-z\d])([A-Z])""") UpperCAmelCase__ = re.compile(r"""(?<!_)_(?!_)""") UpperCAmelCase__ = re.compile(r"""(_{2,...
275
1
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class snake_case_ ( unittest.TestCase ): def __A ( self ): SCREAMING_SNAKE_CASE_ : Optional[int] = [ 'safety_checker/pytorch_model.bin', 'safety...
345
from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__: Dict = logging.get_logger(__name__) lowerCAmelCase__: Optional[Any] = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research/e...
345
1
import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py __SCREAMING_SNAKE_CASE ="""src/transformers""" # This is to make sure the transformers mo...
89
from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE =logging.get_logger(__name__) __SCREAMING_SNAKE_CASE ={ """google/realm-cc-news-pretrained-embedder""": ( """https://huggingface.co/google/realm-cc-news-pretrained-embedde...
89
1
import random from typing import Any def UpperCamelCase ( _a ) -> list[Any]: '''simple docstring''' for _ in range(len(_a ) ): lowercase_ :Union[str, Any] = random.randint(0 , len(_a ) - 1 ) lowercase_ :...
257
import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBertForMa...
257
1
'''simple docstring''' import numpy as np def __SCREAMING_SNAKE_CASE ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): """simple docstring""" lowercase_ : Optional[int] = int(np.ceil((x_end - xa) / h ...
640
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_tor...
640
1
"""simple docstring""" import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational impor...
4
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase : Dict ={"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]} t...
316
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowercase : List[str] = { "configuration_biogpt": ["BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BioGptConfig"], "tokenization_biogpt": ["BioGptTokenizer"],...
546
from __future__ import annotations import requests def _lowerCAmelCase ( UpperCamelCase__: str ) -> dict: """simple docstring""" A = f'https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty' return requests.get(UpperCamelCase__ ).json() def ...
546
1
'''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, se...
689
'''simple docstring''' from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): impor...
689
1
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2...
39
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase : Union[str, Any] = { '''configuration_distilbert''': ...
39
1
"""simple docstring""" from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_...
88
"""simple docstring""" def lowerCamelCase ( _snake_case ,_snake_case ): return int((input_a, input_a).count(0 ) == 0 ) def lowerCamelCase ( ): assert and_gate(0 ,0 ) == 0 assert and_gate(0 ,1 ) == 0 assert and_gate(1 ,0 ) == 0 assert and_gate(1 ,1 ) == 1 if...
110
0
__lowerCamelCase : Dict = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' __lowerCamelCase : ...
721
from sklearn.metrics import mean_squared_error import datasets __lowerCamelCase : List[str] = '''\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel,...
501
0
'''simple docstring''' import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @req...
51
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, Wava...
92
0
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): impo...
571
from ...processing_utils import ProcessorMixin class UpperCamelCase_ ( __UpperCamelCase ): """simple docstring""" A = ['''image_processor''', '''feature_extractor'''] A = '''TvltImageProcessor''' A = '''TvltFeatureExtractor''' def __init__( self ,...
571
1
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSche...
399
'''simple docstring''' def lowercase__ ( __lowercase : int , __lowercase : Tuple , __lowercase : Tuple ) -> Any: """simple docstring""" if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(__lowerca...
399
1
"""simple docstring""" from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures,...
716
"""simple docstring""" import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def a__ ( lowerCAmelCase : List[str] ): '''simple docstring''' def wrapper(*lowerCAmelCase : Any , ...
660
0
def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case ) -> float: if mass < 0: raise ValueError("""The mass of a body cannot be negative""" ) return 0.5 * mass * abs(__snake_case ) * abs(__snake_case ) if __name__ == "__main__": import doctest docte...
108
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { '''configuration_autoformer''': [ '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AutoformerC...
1
0
"""simple docstring""" from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ : int = logging.get_logger(__name__) # TODO Update this UpperCamelCase_ : Optional[int] = ...
497
"""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 UpperCamelCase_ : Optional[Any] = logging.get_logger(__n...
497
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
662
"""simple docstring""" from __future__ import annotations def __snake_case ( UpperCamelCase__ ) -> list[int]: # This function is recursive """simple docstring""" A = len(UpperCamelCase__ ) # If the array contains only one element, we return it (it's th...
690
0
"""simple docstring""" import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput a__ : Optional[Any] = 'scheduler_config.json' ...
720
"""simple docstring""" from __future__ import annotations import math class UpperCamelCase_ : """simple docstring""" def __init__( self : Union[str, Any] , UpperCAmelCase__ : int ) -> None: __SCREAMING_SNAKE_CASE = size # approximate ...
553
0
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 ...
268
from __future__ import annotations class __snake_case : """simple docstring""" def __init__( self , _UpperCamelCase , _UpperCamelCase ) -> Tuple: """simple docstring""" __snake_case , __snake_case ...
268
1
"""simple docstring""" import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xforme...
491
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { '''abeja/gpt-neox-japanese-2.7b''': '''https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/co...
491
1
"""simple docstring""" import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency SCREAMING_SNAKE_CASE : int = { '''E''': 1_2.7_0, '''T''': 9.0_6, '''A''': 8.1_7, '''O''': 7.5_1, '''I''': 6.9_7, '''N''': 6.7_5, ...
260
"""simple docstring""" # DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import ...
260
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.pipelin...
703
from math import isclose, sqrt def lowerCAmelCase_ (lowercase__ : float , lowercase__ : float , lowercase__ : float ) -> tuple[float, float, float]: '''simple docstring''' lowerCAmelCase__ = point_y / 4 / point_x low...
288
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import ...
19
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def lowerCamelCase__ ( __snake_case ) -> Optional[Any]: """simple docstring""" ...
19
1
'''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 ...
98
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device __UpperCAmelCase = False class a__ ...
98
1
'''simple docstring''' def __lowerCamelCase ( lowerCAmelCase_ = 1000 ) -> int: _a : int = 2**power _a : Any = str(lowerCAmelCase_ ) _a : Any = list(lowerCAmelCase_ ) _a : Union[str, Any] = 0 for i in list_num: sum_of_num += int(lowerCAmelCase_ ...
358
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available __lowerCAmelCase = { '''configuration_ernie''': ['''ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ErnieConfig''', '''ErnieOnnxConfig'...
358
1
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class lowercase ( nn.Module ): def __init__( self , _a = 16 , _a = 88 , _a = None , _a = 1 , _a = 0.0 , _a = 32 , _a = None , _a = False , _a = None , ...
54
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, require_tf...
54
1
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed...
97
# 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 _SCREAMING_SNAKE_CASE = TypeVar("T") class SCREAMING_SNAKE_CASE_ ( Generic[T] ): """simpl...
181
0
"""simple docstring""" from __future__ import annotations import numpy as np def __magic_name__ ( __snake_case : list[float] ) -> int: return np.maximum(0 , UpperCamelCase__ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [...
720
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _A : Union[str, Any] = { """configuration_pix2struct""": [ """PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", "...
518
0
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor lowercase : List[str] = logging.get_logger(__name__) class A__ ( __UpperCAmelCase ): """simple docstring""" def __init__( self , *lowercase , **lowerc...
302
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase : int = logging.get_logger(__name__) lowercase : Dict = { """hustvl/...
302
1
"""simple docstring""" import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDeco...
707
"""simple docstring""" import baseaa def lowerCamelCase__ ( _lowerCamelCase ): '''simple docstring''' return baseaa.aaaencode(string.encode('utf-8' ) ) def lowerCamelCase__ ( _lowerCamelCase ): '''simple docstring''' return baseaa.aaadecod...
16
0
import os def __magic_name__ ( lowerCAmelCase_ = "input.txt"): '''simple docstring''' with open(os.path.join(os.path.dirname(lowerCAmelCase_) , lowerCAmelCase_)) as input_file: lowerCamelCase_ : Dict = [ [int(lowerCAmelCase_) for element in l...
250
import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy a...
250
1
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, ) UpperCAmelCase_ = pytest.mark.integration @pytest.mark.parametrize('''path''' , ['''paws''...
664
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent UpperCAmelCase_ = {"UserAgent": UserAgent().random} def UpperCAmelCase__ ( _SCREAMING_SNAKE_CASE : Dict )->dict: _lowerCAmelCase = script.conte...
664
1
# 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 easier to use for tuning ...
141
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake SCREAMING_SNAKE_CASE : List[str] = numpy.array([0, 0]) SCREAMING_SNAKE_CASE : Tuple = numpy.array([0.5, 0.8660254]) SCREAMING_SNAKE_CASE : Tup...
141
1
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __lowercase (_Uppe...
714
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTe...
583
0
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCamelCase ( _UpperCAmelCase ): lowercase : str = ['image_processor', 'tokenizer'] lowercase : List[Any] = 'ViTImageProces...
499
"""simple docstring""" import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGE...
499
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase ={ "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() ...
255
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger UpperCAmelCase =get_logger(__name__) UpperCAmelCase =R"\n Args:\n input_ids (`jnp.ndarray` of...
255
1
import requests from bsa import BeautifulSoup def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase ): __snake_case : Tuple = BeautifulSoup(requests.get(__lowerCamelCase , params=__lowerCamelCase ).content , "html.parser" ) __...
81
def __lowerCAmelCase ( __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ ): if index == number_of_items: return 0 _lowercase: str = 0 _lowercase: Tuple = 0 _lowercase: int = knapsack(__magic_name__ , __magic...
226
0
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, require_t...
708
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class lowerCAmelCase ( __UpperCamelCase ): UpperCAmelCas...
188
0
def __lowerCamelCase ( __a :int = 1 , __a :int = 1_0_0_0 ) -> int: """simple docstring""" A__ = 1 A__ = 0 for divide_by_number in range(__a , digit + 1 ): A__ = [] A__ = numerator for _ in range(1 ...
176
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class A (SCREAMING_SNAKE_CASE ): '''simple docstring''' ...
176
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : List[str] = { "Intel/dpt-large": "https://huggingfa...
700
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __magic_name__ ( __lowerCAmelCase): A:...
106
0
lowercase_ : str = [ 'DownloadConfig', 'DownloadManager', 'DownloadMode', 'StreamingDownloadManager', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager
64
from __future__ import annotations from collections import deque class _lowerCamelCase : def __init__( self , lowerCAmelCase ) -> Optional[Any]: SCREAMING_SNAKE_CASE__: list[dict]= [] self.adlist.append( {'''value''': '''''', '''next_states''': [], '''fail_state''': 0,...
64
1
import argparse import math import traceback import dateutil.parser as date_parser import requests def lowerCAmelCase_ ( __UpperCAmelCase: Dict ) -> Optional[int]: UpperCamelCase__ : Dict = {} UpperCamelCase__ : Dict = job['...
705
# Lint as: python3 import itertools import os import re UpperCAmelCase_ = re.compile(R'([A-Z]+)([A-Z][a-z])') UpperCAmelCase_ = re.compile(R'([a-z\d])([A-Z])') UpperCAmelCase_ = re.compile(R'(?<!_)_(?!_)') UpperCAmelCase_ = re.compile(R'(_{2,})') U...
369
0
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def lowercase__ ( A_: Dict , A_: Optional[int] , A_: Tuple ) -> Tuple: ...
68
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCAmelCase = { 'configuration_mobilebert': [ 'MOBILEBERT_PRETRAINED_CONFIG_AR...
406
0
from ..utils import DummyObject, requires_backends class A_ ( metaclass=SCREAMING_SNAKE_CASE ): _UpperCAmelCase : List[Any] = ['''torch''', '''transformers''', '''onnx'''] def __init__( self : Optional[Any] ,*SCREAMING_SNAKE_CASE__ : Optional[int] ,**...
337
from ..utils import DummyObject, requires_backends class A_ ( metaclass=SCREAMING_SNAKE_CASE ): _UpperCAmelCase : List[Any] = ['''sentencepiece'''] def __init__( self : Any ,*SCREAMING_SNAKE_CASE__ : List[str] ,**SCREAMING_SNAKE_CASE__ : str): ...
337
1
'''simple docstring''' def _snake_case ( _SCREAMING_SNAKE_CASE : int ) -> int: """simple docstring""" if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) or number < 0: raise ValueError("""Input must be a non-negative integer""" ) low...
433
'''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 SPIECE_UNDERLINE, logging UpperCAmelCase ...
433
1
'''simple docstring''' import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeli...
702
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __lowerCamelCase ( pl.LightningModule ): """simple docstring""" def __init__( self , UpperCAmelCase ) ...
601
0
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def __magic_name__ ( _lowerCamelCase: Optional[Any] ) -> int: '''simple docstring''' lowerCAmelCase = [ '''encoder.version''', ...
535
"""simple docstring""" def __magic_name__ ( _lowerCamelCase: Tuple, _lowerCamelCase: Any ) -> Optional[Any]: '''simple docstring''' lowerCAmelCase = [1] for i in range(2, _lowerCamelCase ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * ...
535
1
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class UpperCAmelCase ( __A ): '''simple docstring''' ...
706
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCAmelCase = { """configuration_biogpt""": ["""BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BioGptConfig"""], """tokenization_biogpt""": ["""BioGptT...
70
0
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property ...
387
import random from typing import Any def __lowerCamelCase ( lowerCamelCase__ : list ): '''simple docstring''' for _ in range(len(lowerCamelCase__ ) ): lowerCamelCase = random.randint(0 , len(lowerCamelCase__ ) - 1 ) lowerCamelCa...
457
0
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : int = 10**9 ) -> int: __lowercase = 1 __lowercase = 2 __lowercase = 0 __lowercase = 0 __lowercase = 0 while perimeter <= max_perimeter: perimeters_sum += perimeter prev_val...
688
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class A__ ( lowerCAmelCase__ ): lowerCAme...
688
1
from __future__ import annotations from fractions import Fraction def A ( _lowercase , _lowercase ): return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def A ( _lowercase ): SCREAMING_SNAKE_CASE : List...
248
def A ( _lowercase , _lowercase ): return int((input_a, input_a).count(0 ) == 0 ) def A ( ): assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_gate(1 , 0 ) == 0 assert and_gate(1 , 1 ) == 1 ...
248
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE : List[str] = { '''configuration_table_transformer''': [ '''TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHI...
710
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE : Optional[Any] = {'configuration_focalnet': ['FOCALNET_PRETRAINED_CONFIG_ARC...
697
0
'''simple docstring''' import string def __lowercase (_SCREAMING_SNAKE_CASE :str ): for key in range(len(string.ascii_uppercase ) ): SCREAMING_SNAKE_CASE : Union[str, Any] = '''''' for symbol in message: if symbol in string.ascii_uppercase:...
507
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { """naver-clova-ix/donut-base""": """https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json""", # See all Donut...
507
1
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundfile_availble, is_to...
720
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO ) lowercase__ =logging.getLogger(__name__) if __name__ == "__main__": lowercase__ ...
326
0
"""simple docstring""" class __lowerCAmelCase : '''simple docstring''' def __init__( self: List[Any] , UpperCamelCase_: Dict , UpperCamelCase_: Any , UpperCamelCase_: List[str] ): UpperCamelCase_ =None UpperCamelCase_ =None ...
391
'''simple docstring''' from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) ...
694
0
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class A__ : @property def a__ ( self : int ) -> List[...
720
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
688
0
'''simple docstring''' 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 ...
349
'''simple docstring''' from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationCon...
349
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_: List[Any] = logging.get_logger(__name__) lowercase_: Union[str, Any] = { 'unc-nlp/lxmert-base-uncased': 'https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json', ...
127
import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_: Optional[int] = logging.get_logger(__name__) lowercase_: Optional[int] = { 'facebook/encodec_24khz': 'https://hugging...
127
1
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LIC...
75
'''simple docstring''' from datetime import datetime as dt import os from github import Github UpperCamelCase__ = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''feature request''', '''new model''', '''wip''', ] def ...
75
1
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 ): """simple docstring""" def ...
714
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from data...
656
0
'''simple docstring''' from __future__ import annotations import queue class a__ : '''simple docstring''' def __init__( self , lowerCamelCase_ ) -> int: lowerCAmelCase__ = data lowe...
90
# 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 # # U...
79
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy UpperCAmelCase = logging.get_logger(__name...
342
"""simple docstring""" from timeit import timeit UpperCAmelCase = { """MALAYALAM""": True, """String""": False, """rotor""": True, """level""": True, """A""": True, """BB""": True, """ABC""": False, """amanaplanacanalpanama""": True, # "a man a plan a canal panama" } # Ens...
342
1
from math import log from scipy.constants import Boltzmann, physical_constants _lowerCamelCase = 300 # TEMPERATURE (unit = K) def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: float , UpperCamelCase__: float , UpperCamelCase__: float , ): if donor_conc <...
6
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils....
83
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) __UpperCamelCase : Dict = { "configuration_trocr": ["TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
106
import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING from ...tokenization_util...
106
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) class UpperCAmelCase ( UpperCAmelCase__ ): '''simple docstring''' SCREAMING_SNAKE_CASE_ = 'timm_backbone' def __init__( self , ...
42
'''simple docstring''' import colorsys from PIL import Image # type: ignore def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ) -> float: lowerCamelCase_ = x lowerCamelCase_ = y for step in range(__UpperCamelCase ): # noqa: B0...
42
1
'''simple docstring''' from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder __lowerCAmelCase : Dict = datasets.utils.logging.get_logger(__name__) class A ( folder_based_bui...
708
'''simple docstring''' import argparse import os import re import packaging.version __lowerCAmelCase : Optional[int] = "examples/" __lowerCAmelCase : Dict = { "examples": (re.compile(r"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_version(\"VER...
654
0
import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor __A =logging.get_logger(__name__) class _SCREAMING_SNAKE_CASE ( snake_case_ ): def __init__( self , *lowercase , **lowercase ) -> None: warnings.warn( "T...
463
from __future__ import annotations import math def lowerCamelCase_ ( lowerCamelCase__ ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not...
463
1
'''simple docstring''' from __future__ import annotations from typing import Generic, TypeVar lowerCAmelCase__ : Any = TypeVar("""T""") class a ( Generic[T] ): """simple docstring""" def __init__( self : Tuple , snake_case_ ...
711
'''simple docstring''' import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def _a ( __lowerCAmelCase : Dict ): """simple docstring""" snake_case__ : int = args.pruning_method ...
502
0
"""simple docstring""" def lowercase ( lowerCAmelCase__ ): lowerCamelCase_ = generate_pascal_triangle(lowerCAmelCase__ ) for row_idx in range(lowerCAmelCase__ ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=''' ''' ) # Pri...
29
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import Batch...
563
0
from __future__ import annotations UpperCamelCase = '''#''' class __UpperCAmelCase : def __init__( self: Optional[Any] ): '''simple docstring''' _SCREAMING_SNAKE_CASE = {} def Uppe...
716
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class ...
569
0
'''simple docstring''' import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( ...
50
"""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=loggi...
510
0
'''simple docstring''' from __future__ import annotations from collections import Counter from random import random class lowerCamelCase_ : def __init__( self : Dict ): """simple docstring""" SCREAMING_SNAKE_CASE : Any ...
464
'''simple docstring''' import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def UpperCAmelCase ( A : Union[str, Any] , A : Optional[int] ...
464
1
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar __magic_name__ = TypeVar('''T''') def UpperCAmelCase__( __UpperCAmelCase : int ): return (position - 1) // 2 def UpperCAmelCase__( __UpperCAmelCase : in...
576
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. __magic_name__ = 10 def UpperCAmelCase__( __UpperCAmelCase : int , __UpperCAmelCase : int...
576
1
from math import isqrt, loga def __SCREAMING_SNAKE_CASE ( lowercase_ ) -> list[int]: '''simple docstring''' __UpperCAmelCase : str = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: ...
675
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = { """bert-base-uncased""": """https://huggingface...
675
1
"""simple docstring""" import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils ...
96
"""simple docstring""" def a ( __UpperCAmelCase : List[Any] ) -> str: __magic_name__: Optional[int] = [0] * len(__UpperCAmelCase ) __magic_name__: str = [] __magic_name__: Any = [] __magic_name__: Union[...
96
1
'''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 transf...
631
'''simple docstring''' import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaCon...
631
1
"""simple docstring""" import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def A ( snake_case__ = 3 ): '''simple docstring''' if isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE...
196
'''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 from ...
476
0
import requests __magic_name__ ='''https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=''' def __UpperCamelCase ( A ): # fetching a list of articles in json format UpperCamelCase__ = requests.get(_NEWS_API + bbc_news_api_key ).json() ...
469
def __UpperCamelCase ( A = 600851475143 ): try: UpperCamelCase__ = int(A ) except (TypeError, ValueError): raise TypeError('''Parameter n must be int or castable to int.''' ) if n <= 0: raise ValueError('''Parameter n must be ...
469
1
from math import ceil def UpperCAmelCase_ ( _UpperCAmelCase , _UpperCAmelCase ): lowerCamelCase_: Any = list(range(0 , __SCREAMING_SNAKE_CASE ) ) lowerCamelCase_: List[Any] = [item for sublist in list(device_map.values() ) for item in sublist...
423
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin UpperCAmel...
410
0
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class _snake_case ( pl.LightningModule ): def __init__( self ,UpperCamelCase ) -> Dict: ...
57
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: fro...
57
1
'''simple docstring''' A__ : List[Any] = [ """DownloadConfig""", """DownloadManager""", """DownloadMode""", """StreamingDownloadManager""", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager impor...
13
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase_ : int = 10_00 ) -> int: __lowerCamelCase : Union[str, Any] = 3 __lowerCamelCase : Dict = 0 while a < n: if a % 3 == 0 or a % 5 == 0: ...
13
1
'''simple docstring''' import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, ...
710
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py a_ =...
92
0
from __future__ import annotations def lowerCamelCase_ ( _UpperCamelCase ) -> list[int]: """simple docstring""" return [ord(_UpperCamelCase ) - 96 for elem in plain] def lowerCamelCase_ ( _UpperCamelCase ) -> str: """simple docstring"""...
60
import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor lowerCAmelCase_ = logging.get_logger(__name__) class _lowerCAmelCase ( UpperCAmelCase_ ): '''simple docstring''' def __init__( self : Any , *UpperCamel...
411
0
'''simple docstring''' import string def __snake_case ( _UpperCAmelCase : str): for key in range(len(string.ascii_uppercase)): UpperCamelCase = '''''' for symbol in message: if symbol in string.ascii_uppercase: UpperCamelCase = strin...
709
'''simple docstring''' def __snake_case ( _UpperCAmelCase : Optional[int]): UpperCamelCase = [] UpperCamelCase = [] UpperCamelCase = { '''^''': 3, '''*''': 2, '''/''': 2, '''%''': 2, '''+''': 1, '''-''': 1, } ...
350
0
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class _lowercase ( unittest.TestCase ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : int = JukeboxTokenizer SCREAMING_SNAKE_CASE__ : List[A...
696
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available():...
466
0
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common imp...
423
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...
423
1
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''' A :Dict = field(default="language-modeling" , meta...
191
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusio...
429
0
# 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 ...
448
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def A__ ( _a : int , _a : Any , _a : Union[str, Any] , _a : ...
448
1