code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" import 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 transformer...
552
"""simple docstring""" from collections import Counter from timeit import timeit def UpperCAmelCase ( _lowercase : str = "" , ) -> bool: """simple docstring""" return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 de...
552
1
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar UpperCAmelCase_ = TypeVar("""T""") class UpperCamelCase__ ( Generic[T] ): '''simple docstring''' def __init__( self, snake_case...
706
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py UpperCAmelCase_ = """.""" if __name__ == "__main__": UpperCAmelCase_ = os.path.join(REPO_PATH, """utils/docum...
436
0
"""simple docstring""" import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def __UpperCamelCase ( *SCREAMING_SNAKE_CASE ) -> Dict: """simple docstring""" if not isinstance(__UpperCamelCase , __UpperCamelCase )...
163
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
9
0
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor...
249
import requests from bsa import BeautifulSoup def lowerCamelCase_ ( UpperCamelCase_ = "AAPL" ): _a : List[str] = f"""https://in.finance.yahoo.com/quote/{symbol}?s={symbol}""" _a : Any = BeautifulSoup(requests.get(UpperCamelCase_ ).text , '''html.parser''' ...
249
1
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenizerFast, XLMRoberta...
276
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_available(): from trans...
276
1
import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import VOCAB_FILES_NAM...
706
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() lowerCamelCase_ : Dict = logging.get_logger(__name__) lowerCamelCase_ : Optional[int] = {name: getattr(transformers, name...
246
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils im...
95
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 _lowercase = '''src/diffuse...
659
0
import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeqLoggingCallback, get_checkpoint_callback, get_earl...
706
import fire from utils import calculate_rouge, save_json def __lowerCamelCase ( A__ : Union[str, Any] , A__ : Optional[int] , A__ : Dict=None , **A__ : Dict ) -> str: lowerCamelCase_ : Union[str, Any] = [x.strip() for x in open(A__ ).readlines()] lowerCamelCase_ : ...
171
0
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOut...
558
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIGPT...
558
1
"""simple docstring""" 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_IDENTIFIE...
370
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandin...
370
1
'''simple docstring''' import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def _lowerCAmelCase ( __magic_name__ : BertModel , __magic_name__ : str , __magic_name__ : str ) -> List[str]: ...
92
def _A ( __snake_case :int , __snake_case :float , __snake_case :float ) -> float: """simple docstring""" return round(float(moles / volume ) * nfactor ) def _A ( __snake_case :float , __snake_case :float , __snake_case :float ) -> float...
693
0
"""simple docstring""" from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def __snake_case ( SCREAMING_SNAKE_CASE: int ): """simple docstring""" _lowerCAmelCase = prime_factors(SCREAMING_SNAKE_CASE ...
711
"""simple docstring""" import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( SCREAMING_SNAKE_CASE: O...
491
0
"""simple docstring""" 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 PoolFormerConfig, PoolFormerForImageClassification, PoolF...
573
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeli...
573
1
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo _lowerCAmelCase = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yonghui Wu and Mike Sc...
71
import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class lowerCAmelCase_ ( enum.Enum ): U...
71
1
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin lowerCAmelCase: List[Any] ="\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company th...
607
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def __snake_case ( ) -> None: print("""Making key files...""" ) make_key_files("""rsa""" ...
607
1
"""simple docstring""" UpperCamelCase__ = '''Input must be a string of 8 numbers plus letter''' UpperCamelCase__ = '''TRWAGMYFPDXBNJZSQVHLCKE''' def UpperCAmelCase ( snake_case : Optional[Any] ): if not isinstance(__SCREAMING_SNAKE_CASE , __SCREAM...
701
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def UpperCAmelCase ( ): _lowerCAmelCase:Optional[int] = ArgumentParser( description=( ...
439
0
'''simple docstring''' import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def a__ ( _SCREAMING_...
71
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCamelCase_ ( lowerCamelCase ): a__ = ['''image_processor''', '''tokenizer'''] a__ = '''ChineseCLIPImageProcessor''' a__ = ...
0
0
"""simple docstring""" import json import os import shutil import tempfile from unittest import TestCase from transformers import BartTokenizer, BartTokenizerFast, DPRQuestionEncoderTokenizer, DPRQuestionEncoderTokenizerFast from transformers.models.bart.configuration_bart import BartConfig from transformers.models....
703
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from...
668
0
'''simple docstring''' import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( ...
207
'''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...
207
1
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers impor...
707
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator class __SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : str, lowerCamelCase : int )-> None: lowerCamelCase__ : str =value ...
625
0
"""simple docstring""" import collections import importlib.util import os import re from pathlib import Path __A : Optional[int] = 'src/transformers' # Matches is_xxx_available() __A : Union[str, Any] = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import_struct = {xxx} ...
575
"""simple docstring""" # 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 g...
575
1
'''simple docstring''' def lowercase__ ( __lowercase : bytes ) -> str: """simple docstring""" return "".join([hex(__lowercase )[2:].zfill(2 ).upper() for byte in list(__lowercase )] ) def lowercase__ ( __lowercase : str ) -> bytes: ...
717
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_avai...
434
0
"""simple docstring""" from typing import 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 BatchFeatu...
346
'''simple docstring''' import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @requi...
251
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a : Any = { """configuration_squeezebert""": [ """SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIV...
85
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule a : List[str] = {"""processing_wav2vec2_with_lm""": ["""Wav2Vec2ProcessorWithLM"""]} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM ...
85
1
import argparse SCREAMING_SNAKE_CASE :List[str] = '''docs/source/_static/js/custom.js''' def _lowerCAmelCase ( lowerCAmelCase_ :str )->List[str]: '''simple docstring''' with open(lowerCAmelCase_ , encoding="utf-8" , newline="\n" ) as f: s...
283
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { """naver-clova-ix/donut-base""": """https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json""", # See all Donut ...
678
0
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration A = 5_0_0_0_0_0 A ,A = os.path.split(__file__) A = os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENAME.replace('.py', '.json')) @get_duration...
234
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_...
234
1
def UpperCAmelCase__( __UpperCAmelCase : str ): return "".join(chr(ord(__UpperCAmelCase ) - 32 ) if 'a' <= char <= 'z' else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
576
import math import unittest from transformers import BioGptConfig, 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_modeling_common import ModelTeste...
576
1
"""simple docstring""" from __future__ import annotations def snake_case ( UpperCamelCase__ : int ) -> bool: lowerCamelCase : Dict = str(UpperCamelCase__ ) return len(UpperCamelCase__ ) == 9 and set(UpperCamelCase__ ) == set("""123456789""" ) ...
42
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLImga...
42
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from t...
532
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ = { "configuration_roformer": ["ROFORMER_PRET...
532
1
import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weights_in_m...
76
import collections import importlib.util import os import re from pathlib import Path __lowerCAmelCase : int = 'src/transformers' # Matches is_xxx_available() __lowerCAmelCase : Optional[int] = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import_struct = {xx...
76
1
'''simple docstring''' def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ) -> float: if density <= 0: raise ValueError('Impossible fluid density' ) if bulk_modulus <= 0: raise ValueError('Impossible bulk modulus' ) return (bulk_modulus / density) ** 0.5 ...
42
def A__ (snake_case : int ) -> bool: if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
279
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowerCAmelCase_ ( metaclass=lowerCAmelCase ): """simple docstring""" _lowerCAmelCase : Optional[Any] = ["""note_seq"""] def __init__( self , *lowerCAmelCase , **lowerCAmel...
104
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { "weiweishi/roc-bert-base-zh": "https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/co...
104
1
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCamelCase_ : lowerCamelCase_ = 42 lowerCamelCase_ = None lowerCamelCase_ = None _lowerCamelCase ...
6
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _lowerCamelCase = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
6
1
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def __lowerCAmelCase ( ): raise RuntimeError("CUDA out of memory." ) class _UpperCamelCase ...
290
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, resize, to_channel_dimension_format, )...
290
1
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def UpperCAmelCase_ ( ) -> Optional[Any]: __lowercase : List[Any] = { '''repo_name''': ['''test_repo1''', '''test_repo2'''...
509
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_tokenizat...
509
1
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class lowerCamelCase ( unittest.TestCase ): @require_torch def snake...
249
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common...
249
1
import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor __UpperCAmelCase = logging.get_logger(__name__) class lowerCamelCase (_snake_case ): '''simple docstring''' def __init__( self , ...
406
import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def A ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase , _lowerCamelCase=5 ): '''simple docstring''' assert masked_input.count("<mask>" ) == 1 _...
500
0
'''simple docstring''' from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize("""repo_id""" , ["""canonical_dataset_name""", """org-name/dataset-name"""] ) @pytest.mark.parametrize("""path""" , ["""filename.csv""", """filename with blanks.cs...
710
'''simple docstring''' from random import shuffle import tensorflow as tf from numpy import array def SCREAMING_SNAKE_CASE ( lowercase_ : List[str] , lowercase_ : Optional[int] ): lowercase = int(lowercase_ ) assert noofclusters < len(lowercas...
653
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _snake_case : Union[str, Any] = { 'configuration_mega': ['MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegaConfig', 'MegaOnnxConfig'], } try: if not is_t...
53
from __future__ import annotations def _A ( SCREAMING_SNAKE_CASE__ : list[int] , SCREAMING_SNAKE_CASE__ : int ): UpperCamelCase :list[list[int]] = [] UpperCamelCase :list[int] = [] UpperCamelCase :List[str] = 0 UpperCamelCase ...
658
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __magic_name__ : int = { '''configuration_graphormer''': ['''GRAPHORMER_PRETRAINED_CONFIG_AR...
705
__magic_name__ : List[str] = tuple[float, float, float] __magic_name__ : Optional[int] = tuple[float, float, float] def lowercase__ ( _UpperCamelCase , _UpperCamelCase) -> Vectorad: """simple docstring""" UpperCamelC...
410
0
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ) -> List[str]: if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(lowerCamelCase_ , n - 1 , lowerCamelCase_ ) * a) % mod else: _lowercase ...
89
"""simple docstring""" from __future__ import annotations import math from collections.abc import Callable def __A ( a_ : Callable[[int | float], int | float] , a_ : int | float , a_ : int | float , a_ : int = 1_00 , )-> float: '''simple docstring''' SCREAMIN...
698
0
"""simple docstring""" import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py a : Optional[int] = '''src/t...
705
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin ...
31
0
from __future__ import annotations import math def lowerCamelCase_ ( _lowercase ) -> bool: 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 no...
520
'''simple docstring''' import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": a : List[str] = argparse.ArgumentParser() parser.add_argument( '--checkp...
640
0
"""simple docstring""" import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between checkouts and running tests. a_ = abspath(join(dirname(d...
717
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def a__ ( __lowercase ) -> Optional[int]: _A = [ "encoder.version", "decoder.version", "model.enco...
621
0
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 import Con...
387
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class lowerCamelCas...
387
1
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. __SCREAMING_SNAKE_CASE : Optional[int] = 10 def snake_case_ ( lowercase__ : int , lowercase_...
149
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attentio...
149
1
'''simple docstring''' import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def _UpperCamelCase ( UpperCamelCase__ ): """simple docstring...
436
'''simple docstring''' from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def _UpperCamelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ = False ): """simple docstring""...
436
1
"""simple docstring""" from math import pi def __lowercase ( lowerCamelCase_ : int , lowerCamelCase_ : int ): return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 10))
112
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.hugg...
112
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) _lowercase : List[str] ={ "configuration_speech_to_text": ["SPEECH_TO_TEXT_P...
305
'''simple docstring''' from __future__ import annotations def __lowerCamelCase ( A__ , A__ ) -> list[tuple[int, int]]: """simple docstring""" UpperCamelCase , UpperCamelCase = position UpperCamelCase =...
430
0
import numpy as np def a_ ( _A , _A , _A , _A , _A ) -> Optional[Any]: """simple docstring""" snake_case__ = int(np.ceil((x_end - xa) / h ) ) snake_case__ = np.zeros((n + 1,) ) snake_case__ = ...
717
from collections.abc import Sequence def a_ ( _A , _A ) -> float: """simple docstring""" return sum(c * (x**i) for i, c in enumerate(_A ) ) def a_ ( _A , _A ) -> float: """simple docstring""" snake_case__ ...
372
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
113
def lowerCAmelCase__ ( _a : str ): snake_case_ : List[Any] = "" 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__ ( _a : str ): snake_case_ ...
568
0
"""simple docstring""" import numpy as np class _UpperCAmelCase : def __init__( self : List[str] , _lowercase : Dict=None , _lowercase : str=None , _lowercase : str=None , _lowercase : List[str]=None , _lowercase : Opt...
719
"""simple docstring""" import unittest from transformers import DonutProcessor _lowercase : List[str] = 'naver-clova-ix/donut-base' class _UpperCAmelCase ( unittest.TestCase ): def a ( self : Union[str, Any] ): __UpperCAmelCase ...
397
0
"""simple docstring""" from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats...
363
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { "asapp/sew-tiny-100k": "https://huggingface.co/asapp/sew-tiny-100k/resolve/main/config.js...
363
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable UpperCAmelCase : List[str] ={"""configuration_gpt_neox""": ["""GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoXConfig"""]} t...
504
import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional import huggingface_hub.utils as hf_hu...
504
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case__ : Dict = { """configuration_megatron_bert""": ["""MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MegatronBertConfig"""], } try: if ...
23
import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.training.common_...
439
0
"""simple docstring""" import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from dat...
706
"""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 import ModelMixin ...
254
0
"""simple docstring""" import json import os import torch from diffusers import UNetaDModel os.makedirs('hub/hopper-medium-v2/unet/hor32', exist_ok=True) os.makedirs('hub/hopper-medium-v2/unet/hor128', exist_ok=True) os.makedirs('hub/hopper-medium-v2/value_function', exist_ok=True) def snak...
516
"""simple docstring""" 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, ...
516
1
'''simple docstring''' def UpperCAmelCase ( A : int , A : int ): while second != 0: SCREAMING_SNAKE_CASE : List[str] = first & second first ^= second SCREAMING_SNAKE_CASE : Any = c << ...
464
'''simple docstring''' 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 lowerCamelCa...
464
1
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_S...
539
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", ...
539
1
'''simple docstring''' import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def _a (__SCREAMING_SNAKE_CASE ): """simple docstring""" _UpperCamelCase =[ '''encoder.version''', '''decoder.vers...
712
'''simple docstring''' import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorSt...
271
0
from __future__ import annotations import math def __magic_name__ ( SCREAMING_SNAKE_CASE ) -> bool: 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 eve...
66
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets __UpperCAmelCase = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It ...
642
0
'''simple docstring''' 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 PaddingStrate...
496
'''simple docstring''' import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __UpperCamelCase( _A : Optional[Any] ): '''simple doc...
496
1
import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class _UpperCAmelCase ( nn.Module ...
183
def a ( lowerCamelCase_ ): '''simple docstring''' lowercase__ = [] for data in source_data: for i, el in enumerate(lowerCamelCase_ ): if len(lowerCamelCase_ ) < i + 1: data_lists.append([] ) data_lists[i]...
183
1
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert ...
311
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> bool: SCREAMING_SNAKE_CASE_ : Union[str, Any] = len(SCREAMING_SNAKE_CASE ) SCREAMING_SNAKE_CASE_ : Optional[Any] = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each...
311
1
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __UpperCAmelCase ( __a : Any ) -> Dict: """simple...
14
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when...
494
0
from random import randint, random def __lowerCamelCase ( A__ : int , A__ : int , A__ : int , A__ : bool = False , A__ : bool = False , A__ : int = 5 , ) -> list: lowerCamelCase_ : int = [[-1] * number_of_cells] # Create a highway without any car lowerCamelCase_ : ...
721
class SCREAMING_SNAKE_CASE_ : '''simple docstring''' def __init__( self : int ) ->None: lowerCamelCase_ : dict[str, TrieNode] = {} # Mapping from char to TrieNode lowerCamelCase_ : str = False def _lowerCAmelCase ...
171
0
'''simple docstring''' def UpperCAmelCase ( A : bytes ): return "".join([hex(A )[2:].zfill(2 ).upper() for byte in list(A )] ) def UpperCAmelCase ( A : str ): # Check data validity, following RFC3548 # https://www.ietf.org/rfc/r...
527
'''simple docstring''' from math import pow def UpperCAmelCase ( A : int , A : int , A : int , A : int , A : int , ): if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a so...
527
1
'''simple docstring''' from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class A ( _a ): def __init__( self : Any , lowerCAmelC...
377
'''simple docstring''' 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_comm...
377
1
def A__ ( SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : int ) -> list[str]: """simple docstring""" return [sentence[i : i + ngram_size] for i in range(len(SCREAMING_SNAKE_CASE_ ) - ngram_size + 1 )] if __name__ == "__main__": from doc...
32
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ) def UpperCamelCase_( ) -> Any: _lowercase...
89
0
'''simple docstring''' from __future__ import annotations def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_) -> str: # noqa: E741 while r - l > 1: UpperCamelCase__ : List[str] = ...
700
'''simple docstring''' from typing import Union import fire import torch from tqdm import tqdm def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_ = "cpu" , lowerCamelCase_ = None) -> None: UpperCamelCase__ : List[Any] ...
6
0
UpperCamelCase_ = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} UpperCamelCase_ = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def _UpperCAmelCase ( UpperCamelCase: dict[int, list[int]] , UpperCamelCase: int , UpperCamelCase: list[bool] ): """simple ...
611
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "andreasmadsen/efficient_mlm_m0.40": ( ...
611
1
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _UpperCamelCase (...
458
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : Any = { 'facebook/nllb-moe-54B': 'https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json', }...
458
1
import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers.utils.testing_utils import i...
89
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) SCREAMING_SNAKE_CASE : str = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCodeConfig"], } try: if not is_torch_available()...
89
1
'''simple docstring''' import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_avail...
719
'''simple docstring''' # 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 t...
10
0
'''simple docstring''' import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ : List[Any] = logging.get_logger(__name__) UpperCAmelCase__ : List[str] = {"vocab_file": "vocab.json"} Uppe...
48
'''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.0 # ...
48
1
"""simple docstring""" import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARC...
612
"""simple docstring""" import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def lowerCAmelCase ( UpperCamelCase_: Dict ) -> Any: '''simple docstring''' _a = os.path.jo...
612
1
'''simple docstring''' from __future__ import annotations _a : Optional[int] = list[tuple[int, int]] _a : Union[str, Any] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0...
689
'''simple docstring''' import string from math import logaa def a_ ( UpperCamelCase_ , UpperCamelCase_ ): A_ = document.translate( str.maketrans("" , "" , string.punctuation ) ).replace("\n" , "" ) A_ = document_without_punctuation.split(...
452
0
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, g...
185
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTe...
185
1
'''simple docstring''' import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class lowerCamelCase__: def __init__( self , __UpperCAmelCase ): """simple docstring""" ...
566
'''simple docstring''' from typing import Any def A__ ( A_ ) -> list[Any]: if not input_list: return [] _lowercase = [input_list.count(A_ ) for value in input_list] _lowercase = max(A_ ) # Gets the maximum count in the input list. # Gets values of modes ...
497
0
def _lowercase ( SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : int ): """simple docstring""" return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(U...
708
def _lowercase ( SCREAMING_SNAKE_CASE_ : int ): """simple docstring""" assert ( isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) and number_of_steps > 0 ), f'number_of_steps needs to be positive integer, your input {number_of_steps}' if numb...
181
0
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image ...
152
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqCo...
41
0
"""simple docstring""" import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow A = logging.getLogger() @unittest.skip('Temporarily disable the doc tests.' ) @require...
147
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def UpperCamelCase_ ( lowerCamelCase : ndarray ) -> float: """simple docstring""" return np.dot(lowerCamelCase , lowerCamelCas...
147
1
"""simple docstring""" import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_check...
93
"""simple docstring""" import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditi...
93
1
"""simple docstring""" 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 , __a , __a , __a ): A_ = Big...
705
"""simple docstring""" import baseaa def A_ (__a ): '''simple docstring''' return baseaa.aaaencode(string.encode("utf-8" ) ) def A_ (__a ): '''simple docstring''' return baseaa.aaadecode(__a ).decode("utf-8" ) if __name__ == "__main__": i...
482
0
from ..utils import DummyObject, requires_backends class a__ ( metaclass=__snake_case ): A__ : Tuple = ['note_seq'] def __init__( self , *UpperCAmelCase , **UpperCAmelCase ) -> str: requires_backends(self , ['note_seq'] ) ...
559
from __future__ import annotations def lowerCAmelCase( __lowerCamelCase ): if len(__lowerCamelCase ) == 0: return array __a , __a = min(__lowerCamelCase ), max(__lowerCamelCase ) # Compute the variables __a = _max - _min + 1 __a , __a ...
559
1
"""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 lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ ...
702
"""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__ = { '''configuration_blenderbot''': [ ...
544
0
import argparse from collections import defaultdict def lowerCAmelCase_ ( __a , __a , __a , __a , __a ) -> Union[str, Any]: """simple docstring""" lowerCamelCase__: Union[str, Any] =F"""{file}_{class_name}_{test_name}""" d...
59
from typing import List import numpy as np def lowerCamelCase_ ( lowerCAmelCase__ : dict ) -> int: '''simple docstring''' A = {key: len(lowerCAmelCase__ ) for key, value in gen_kwargs.items() if isinstance(lowerCAmelCase__ , lowerCAmelCase__ )} ...
106
0
import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVeca...
704
from argparse import ArgumentParser from .env import EnvironmentCommand def a_ ( ) -> Optional[Any]: """simple docstring""" snake_case__ = ArgumentParser('Diffusers CLI tool' , usage='diffusers-cli <command> [<args>]' ) snake_case__ ...
372
0
'''simple docstring''' def __a(SCREAMING_SNAKE_CASE_ : int = 1 , SCREAMING_SNAKE_CASE_ : int = 1000 ): '''simple docstring''' _lowerCAmelCase = 1 _lowerCAmelCase = 0 for divide_by_number in range(SCREAMING_SNAKE_CASE_ , digit...
18
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
102
0
import argparse import os import re lowercase__ = '''src/diffusers''' # Pattern that looks at the indentation in a line. lowercase__ = re.compile(R'''^(\s*)\S''') # Pattern that matches `"key":" and puts `key` in group 0. lowercase__ = re.compile(R'''^\s*"([^"]+)":''') ...
701
'''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(): import...
420
0
def __lowerCAmelCase ( __snake_case ): def merge(__snake_case , __snake_case ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yield from left yi...
367
from __future__ import annotations import os from typing import Any import requests lowerCamelCase : Tuple = '''https://api.github.com''' # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user lowerCamelCase : int = BASE_URL + '...
367
1
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): _snake_case : Optional[Any] = yaml.safe_load( '\\nname: ""\nallow_empty: false\nallow_empty_text: true\nsubsections:\...
421
import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): impor...
421
1
import argparse from collections import defaultdict import yaml a__ = """docs/source/en/_toctree.yml""" def _UpperCAmelCase ( a : str ): snake_case__ = defaultdict(a ) for doc in model_doc: counts[doc["local"]] += 1 snake_case__ = ...
654
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _lowerCAmelCase ( lowercase_ ): """simple docstring""" _lowercase : int = (IPNDMScheduler,) _lowercase : int = (('''num_inference_steps''', 50...
654
1
'''simple docstring''' def _UpperCAmelCase ( _UpperCamelCase : int = 50 ) -> int: A_ = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2, 5 ): for tile_start in range(row_length - tile_length + 1 )...
703
'''simple docstring''' import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokeniza...
174
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms impo...
541
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available _UpperCamelCase : Tuple = { 'configuration_audio_spectrogram_transformer': [ 'AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAIN...
541
1
'''simple docstring''' __snake_case : Dict = range(2, 20 + 1) __snake_case : Any = [10**k for k in range(ks[-1] + 1)] __snake_case : dict[int, dict[int, list[list[int]]]] = {} def _lowercase ( lowerCamelCase__ : int, lowerCamelCase__ : Optional[Any], l...
718
'''simple docstring''' import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet imp...
691
0
from __future__ import annotations from math import pow, sqrt def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : Any , UpperCAmelCase_ : Optional[int] , UpperCAmelCase_ : Any ) -> Union[str, Any]: if (resistance, reactance, impedance).count(0 ) != 1: ...
443
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _lowerCAmelCase ( A__ ): lowercase__ = SwinConfig(image_size=192 ) if "base" in model_name: lowercase__ = 6 ...
622
0
'''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 UpperCamelCase ="▁" UpperCamelCase ={"vocab_file": "spiece.model"} Upp...
543
'''simple docstring''' import warnings from .generation import TFGenerationMixin class A ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" warnings.warn( '''Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will ''' '''be...
543
1
'''simple docstring''' import numpy as np from PIL import Image def _lowercase ( __A ,__A ,__A ): '''simple docstring''' __UpperCamelCase = np.array(UpperCAmelCase_ ) if arr.shape[0] != arr.shape[1]: raise ValueError("""The input array is not ...
601
import unittest from transformers import BertGenerationConfig, 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_modeling_common import...
648
0
'''simple docstring''' from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def A_ ( _lowerCAmelCase : str = "laptop" ): """simple docstring""" _lowerCamelCase : Dict = F'https://www.amazon.in/lapt...
711
'''simple docstring''' import warnings from ..trainer import Trainer from ..utils import logging UpperCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) class UpperCAmelCase__ ( A ): def __init__( self : int,__A : Any=None,**__A : O...
11
0