code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, require_torch_multi_gpu, ) loggin...
186
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS...
186
1
import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel _snake_case = { """text_branch""": """text_model""", """audio_branch""": """audio_model.audio_encoder""", """attn""": """attention.self""", """s...
363
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, ...
201
0
def _A ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : list ): _enforce_args(UpperCamelCase__ , UpperCamelCase__ ) if n == 0: return 0 UpperCamelCase :List[str] = float('''-inf''' ) for i in range(1 , n + 1 ): ...
259
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping _lowerCAmelCase :Tuple = tuple[int, int] class _UpperCAmelCase : '''simple docstring''' def __init__( self , A , A ) -> None: _Upper...
263
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : str = { "configuration_deberta": ["DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP", "DebertaConfig", "Deber...
159
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATURE...
159
1
'''simple docstring''' a_ : Tuple = "Tobias Carryer" from time import time class a : def __init__( self , __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__=int(time() ) ) -> int: # noqa: B008 _a = ...
168
'''simple docstring''' import sys a_ : Dict = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" ...
168
1
"""simple docstring""" def A_ ( _lowerCAmelCase : int = 4_00_00_00 ): """simple docstring""" _a = [] _a , _a = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(_lowerCAmelCase ) _a , _a = b, a + b ...
356
"""simple docstring""" import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import Nes...
153
0
"""simple docstring""" import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, ...
290
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class SCREAMING_SNAKE_CASE__ ( tf.keras.optimizers.schedules.LearningRateSchedule ...
116
0
'''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 @dataclass class ...
349
'''simple docstring''' A_ : Optional[Any] = """0.21.0""" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from ...
349
1
"""simple docstring""" import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin lowerCAmelCase__ : Optional[int] = get...
98
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowercase : int =logging.get_logger(__name__) _lowercase : Union[str, Any] ={ "vocab_file": "voc...
170
0
"""simple docstring""" def _snake_case ( lowerCamelCase__ : list ) -> list: lowerCamelCase_ : List[Any] =len(lowerCamelCase__ ) for _ in range(lowerCamelCase__ ): for i in range(_ % 2 , arr_size - 1 , 2 ): ...
209
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) A__ : Optional[int] = { 'configuration_speech_to_text': ['SPE...
209
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCamelCase : Tuple = { 'configu...
307
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowerCamelCase_ : int = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDepend...
286
0
def snake_case_ ( snake_case = 10_00 ) -> int: return sum(e for e in range(3 , snake_case ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F'''{solution() = }''')
359
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets __lowerCAmelCase = '''\ @inproceedings{popovic-2015-chrf, title = "chr{F}: character n-gram {F}-score for automatic {MT} evaluation", author = "Popovi{\'c}, Maja", booktitle = "Proceeding...
288
0
'''simple docstring''' from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function A__: str = 1.054571817E-34 # unit of ℏ : J * s A__: int = 3E8 # unit of c : m...
276
'''simple docstring''' import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as ...
276
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import ...
141
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, ...
141
1
import math from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { "facebook/data2vec-base-960h": "https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main/config.json", # See all ...
339
def lowerCAmelCase_ ( __UpperCAmelCase: int ) -> bool: return str(__UpperCAmelCase ) == str(__UpperCAmelCase )[::-1] def lowerCAmelCase_ ( __UpperCAmelCase: int ) -> int: return int(__UpperCAmelCase ) + int(str(__UpperCAmelCase )[::-...
201
0
"""simple docstring""" from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def _lowerCamelCase(__UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 1 / sqrt(2 ) ) -> IIRFilter: _lowerCAmelCase =tau * frequency / samplerate _lowerCAmelCase ...
341
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = {} class lowerCamelCase__ ( __magic_name__ ): '''simple docstring''' lowerCamelCase = '''llama''' lowe...
341
1
from __future__ import annotations import numpy as np def _lowerCAmelCase ( lowerCAmelCase_ :np.ndarray )->tuple[np.ndarray, np.ndarray]: '''simple docstring''' snake_case_ , snake_case_ = np.shape(lowerCAmelCase_ ) if rows != columns: ...
159
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer if ...
159
1
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict fro...
356
import requests _UpperCAmelCase : Union[str, Any] = """https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=""" def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ = requests.get(_NEWS_API + bbc_news_api_key ...
200
0
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Optional[int] = logging.get_logger(__name__) __A : int = { "huggingface/informer-tourism-monthly": ( ...
260
"""simple docstring""" from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _lowerCamelCase ( _lowercase ...
153
0
from collections import namedtuple import requests from lxml import html # type: ignore lowercase : int = namedtuple("""covid_data""", """cases deaths recovered""") def _snake_case( SCREAMING_SNAKE_CASE__ = "https://www.worldometers.info/coronavirus/" ) -> covid_data: lowe...
285
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 BatchFeature from ....file_utils import Padding...
285
1
'''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 @datacl...
349
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig a__ : Union[str, Any] = { 'albert-base-v1': 'https://huggingface.co/albert-base-v1/resolve/main/config.json', ...
349
1
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE_ ( __A : float , __A : float , __A : float , ) -> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 va...
366
'''simple docstring''' import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset lowerCamelCase_ = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5,...
111
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_fnet import ...
209
def lowerCAmelCase__(__snake_case ) -> str: '''simple docstring''' return "".join(chr(ord(__snake_case ) - 32 ) if '''a''' <= char <= '''z''' else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
209
1
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerT...
357
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, requi...
113
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENE...
289
"""simple docstring""" import warnings warnings.warn( """memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: """ """`from accelerate import find_executable_batch_size` to avoid this warning.""", FutureWarning, )
289
1
'''simple docstring''' from pathlib import Path import fire from tqdm import tqdm def __UpperCAmelCase ( a_: int="ro", a_: str="en", a_: str="wmt16", a_: Dict=None ): try: import datasets except (ModuleNotFoundError, ImportError): raise ImportError("run pip install data...
17
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __a = { 'configuration_layoutlmv2': ['LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Layo...
17
1
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.uti...
141
'''simple docstring''' import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_aut...
141
1
UpperCamelCase__ : int = 256 # Modulus to hash a string UpperCamelCase__ : Any = 1_000_003 def SCREAMING_SNAKE_CASE__ ( snake_case_, snake_case_ ) -> Any: """simple docstring""" a = len(lowerCamelCase_ ) a = len(low...
358
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : Optional[int] = logging.get_logger(__name__) UpperCamelCase__ : Dict = { """facebook/vit-mae-base""": """https://huggingface.co/facebook/vit-mae-base/resolve/main/config.js...
330
0
from __future__ import annotations import time import numpy as np UpperCAmelCase__ = [8, 5, 9, 7] UpperCAmelCase__ = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] UpperCAmelCase__ = [ [3, 2, 1, 4], [0, 2, 5, 2]...
0
'''simple docstring''' from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent lowerCamelCase__ = {'UserAgent': UserAgent().random} def __lowerCAmelCase (__lowerCAmelCase ): _UpperCAme...
234
0
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _A = logging.get_logger(__name__) _A = {"""vocab_file""": """vocab.json"""} _A = { """voca...
212
"""simple docstring""" import os from collections import deque import torch from torch.utils.data import Dataset class _lowerCamelCase ( a_ ): def __init__( self : Tuple , UpperCamelCase : List[Any]="" , UpperCamelCase : List[str]="train" ) -> Li...
212
1
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLI...
46
'''simple docstring''' class lowercase__ : '''simple docstring''' def __init__( self , __snake_case = "" , __snake_case = False ): # Mapping from the first character of the prefix of the node _SCREAMING_SNAKE_CASE : dict[str, RadixNode] ...
200
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor UpperCamelCase : List[str] = logging.get_logger(__name__) class UpperCamelCase ( a_ ): """simple docstring""" def __init__( self ...
345
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( snake_case : list[int | float] , snake_case : int , snake_case : int ) -> int | float: """simple docstring""" if len(snake_case ) =...
345
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, requir...
285
from __future__ import annotations import collections import pprint from pathlib import Path def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' return "".join(sorted(UpperCamelCase__ ) ) def __lowerCamelCase ( UpperCamelCase__ ): ...
285
1
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class a ( lowerCamelCase__ ): '''simple docstring''' lowerCAmelCase : List[str] = (DDPMScheduler,) def lowerCamelCase_ ( self : Union[s...
362
import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def SCREAMING_SNAKE_CASE ( __UpperCamelCase : Union[str, Any] , __UpperCamelCase : int , __UpperCamelCase : Union[str, Any] , __UpperCamelCase : List[str]=5 ) ...
177
0
import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils import require_toke...
192
def A__ ( SCREAMING_SNAKE_CASE__ = 200) -> int: __snake_case: Optional[int] = [1, 2, 5, 10, 20, 50, 100, 200] __snake_case: List[Any] = [0] * (pence + 1) __snake_case: int = 1 # base case: 1 way to make 0 pence for coin in coins: for i in range(SC...
111
0
"""simple docstring""" import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learn...
353
"""simple docstring""" import warnings from functools import wraps from typing import Callable def __lowerCAmelCase (_UpperCamelCase ): @wraps(_UpperCamelCase ) def _inner_fn(*_UpperCamelCase , **_UpperCamelCase ): warnings.warn( (F"'{fn.__name__}' is experimental and might be subject to br...
182
0
import functools def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ) -> int: lowerCamelCase : Tuple = len(_SCREAMING_SNAKE_CASE ) lowerCamelCase : List[str] = len(_SCREAMING_SNAKE_CASE ) @functools.cache def min_distan...
48
"""simple docstring""" import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils i...
113
0
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) class UpperCamelCase ( lowercase__ ): '''simple docstring''' ...
361
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings("ignore", category=UserWarning, module="torch.optim.lr_scheduler") class UpperCamelCas...
252
0
"""simple docstring""" from pathlib import Path import fire from tqdm import tqdm def _A ( UpperCamelCase_ : Optional[Any]="ro", UpperCamelCase_ : str="en", UpperCamelCase_ : Union[str, Any]="wmt16", UpperCamelCase_ : Tuple=None) -> None: '''simple d...
17
"""simple docstring""" import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import...
17
1
'''simple docstring''' import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state im...
367
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging snake_case_ : Optional[int] = logging.get_logger(__name__) snake_case_ : List[Any] = { 'face...
236
0
import operator as op lowerCAmelCase_ = '''scaler.pt''' lowerCAmelCase_ = '''pytorch_model''' lowerCAmelCase_ = '''random_states''' lowerCAmelCase_ = '''optimizer''' lowerCAmelCase_ = '''scheduler''' lowerCAmelCase_ = '''pytorch_model.bin''' lowerCAmelCase_ ...
8
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class __lowerCAmelCase ( lo...
330
0
"""simple docstring""" import sys _a = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '12540698747158523863050715693290963295227443043557' '6689664895044524452316173185640...
363
"""simple docstring""" import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class A_ (unittest.TestCase ): '''simple docstring''' def Upp...
23
0
import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrogram_diffusi...
212
from __future__ import annotations lowerCamelCase__ = list[list[int]] # assigning initial values to the grid lowerCamelCase__ = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0...
212
1
# 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 r...
191
def _a ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : str ) -> int: '''simple docstring''' if len(SCREAMING_SNAKE_CASE__ ) != len(SCREAMING_SNAKE_CASE__ ): raise ValueError("String lengths must match!" ) ...
191
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 .tokeni...
296
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProc...
296
1
'''simple docstring''' import datasets from .evaluate import evaluate _lowercase : List[str] = "\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball...
264
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Dict = { "EleutherAI/gpt-neox-20b": "https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/con...
264
1
'''simple docstring''' from __future__ import annotations import math def a_ ( __snake_case : int , __snake_case : int , __snake_case : bool , __snake_case : list[int] , __snake_case : float ) -> int: ...
75
"""simple docstring""" from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "snap-research/efficientformer-l1-300": ( "https://huggingface.co/snap-research/efficientformer-l1-300/resolve/main/c...
177
0
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def SCREAMING_SNAKE_CASE_ ( ) -> Any: _SCREAMING_SNAKE_CASE = ArgumentParser( description=( "PyTorch TPU distributed tr...
350
'''simple docstring''' import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel lowerCamelCase_ = { ...
111
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer A_ : Dict = logging.get_logger(__n...
215
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __UpperCamelCase : Tuple = { 'configuration_swiftformer': [ 'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SwiftFormerConfig', ...
182
0
import copy import re class __a : __lowercase : Dict = 'hp' __lowercase : List[Any] = {} __lowercase : Tuple = None @classmethod def SCREAMING_SNAKE_CASE__ ( cls , lowerCAmelCase__ , lowerCAmelCase_...
353
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json''', # See all PEGASUS models ...
288
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a__ = { """configuration_pix2struct""": [ """PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Pix2StructConfig""", """Pix2StructTex...
317
import pprint import requests a__ = """https://zenquotes.io/api""" def lowercase ( ) -> list: return requests.get(API_ENDPOINT_URL + """/today""" ).json() def lowercase ( ) -> list: return requests.get(API_ENDPOINT_URL + """/random""" ).json() ...
317
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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_featur...
202
"""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_roform...
202
1
import os from typing import Dict, List, Tuple, TypeVar, Union __snake_case :Tuple = TypeVar('''T''') __snake_case :int = Union[List[T], Tuple[T, ...]] __snake_case :Union[str, Any] = Union[T, List[T], Dict[str, T]] __snake_case :str = Union[str, by...
49
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( lowercase ,lowercase ): """simple docstring""" _UpperCAmelCase = get_failure_array(lowercase ) # 2) Step through text searching for pattern _UpperCAmelCase , _UpperCAmelCase ...
289
0
"""simple docstring""" import random from .binary_exp_mod import bin_exp_mod def _A ( _a : str , _a : str=1_0_0_0 ): """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 ...
77
"""simple docstring""" import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py UpperCAmelCase ="\\n@INPROCEEDINGS{Papineni02bleu:a,\n author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu},\n title = {...
77
1
from __future__ import annotations import math import random from typing import Any class lowercase : def __init__( self): lowercase = [] lowercase = 0 lowercase = 0 def A__ ( self): return s...
101
'''simple docstring''' from manim import * class SCREAMING_SNAKE_CASE( A__ ): """simple docstring""" def A ( self : Union[str, Any] ) -> List[str]: UpperCAmelCase : Optional[Any] = Rectangle(height=0.5 , widt...
23
0
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 AcceleratorState from accelerate.test_utils...
210
def UpperCAmelCase_ ( ) -> int: return 1 def UpperCAmelCase_ ( __UpperCAmelCase : int ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def UpperCAmelCase_ ( __UpperCAmelCase : int ) -> int: return 0 if x < 0...
210
1
"""simple docstring""" import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device...
191
"""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 ...
191
1
from math import pow, sqrt def _A (*__a ) -> bool: """simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[int] = len(__a ) > 0 and all(value > 0.0 for value in values ) return result def _A (__a , __a ) -> float | ValueError: ...
370
"""simple docstring""" from __future__ import annotations import queue class lowerCAmelCase__ : '''simple docstring''' def __init__( self : Tuple , lowercase_ : Optional[int]): '''simple docstring''' SCREAMING_SNAKE_CASE_ ...
318
0
'''simple docstring''' import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK_REC...
1
"""simple docstring""" import unittest from transformers import 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 ModelTes...
264
0
def __snake_case ( _UpperCAmelCase ): __a = 0 # if input_string is "aba" than new_input_string become "a|b|a" __a = '''''' __a = '''''' # append each character + "|" in new_string for range(0, length-1) for i in input_string[: len(A__ ) - 1]: ...
358
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperC...
131
0
"""simple docstring""" from collections.abc import Sequence def a__ ( __SCREAMING_SNAKE_CASE = None ) -> int: if nums is None or not nums: raise ValueError("Input sequence should not be empty" ) __lowerCAmelCase: Optional[Any] = nums[0] for i in range(1 ...
217
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar __UpperCAmelCase : str = TypeVar("T") def A__ ( SCREAMING_SNAKE_CASE__) -> int: return (position - 1) // 2 def A__ ( SCREAMING_SNAKE_CASE__) -> ...
111
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 requir...
364
lowercase : Optional[int] = 9.8_0_6_6_5 def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : float = g) -> float: '''simple docstring''' if fluid_density <= 0: ...
151
0
# 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 ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet imp...
227
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def a( A : dict ) -> tuple: """simple doc...
227
1
"""simple docstring""" from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar __A = TypeVar('T') def _lowerCamelCase(__UpperCamelCase ) -> int: return (position - 1) // 2 def _lowerCamelCase(__UpperCamelCase ) -> int: return (...
365
"""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 __A = logging.get_l...
341
0
"""simple docstring""" from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMSchedu...
202
"""simple docstring""" from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common imp...
202
1
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTester...
368
'''simple docstring''' from decimal import Decimal, getcontext from math import ceil, factorial def __a ( _UpperCamelCase: int ) -> str: """simple docstring""" if not isinstance(_UpperCamelCase , _UpperCamelCase ): raise TypeError("Undefined for n...
142
0
"""simple docstring""" import requests _UpperCamelCase : List[Any] = "https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=" def a_ ( _lowerCAmelCase : str ): '''simple docstring''' lowercase__ : str = requests.get(_NEWS_API + bbc_new...
77
"""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 impor...
77
1
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer __snake_case : Union[str, Any] = lo...
371
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __snake_case : Union[str, Any] = { """configuration_convbert""": ["""CONVBERT_PRETRAINED_CONF...
122
0
# Copyright 2022 The HuggingFace Team and The OpenBMB 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 ...
210
import warnings from functools import wraps from typing import Callable def UpperCAmelCase ( lowercase ): """simple docstring""" @wraps(lowercase ) def _inner_fn(*lowercase , **lowercase ): warnings.warn( (F"'{fn.__name__}' is experime...
210
1
"""simple docstring""" lowerCAmelCase_ : Optional[int] = { '''a''': '''AAAAA''', '''b''': '''AAAAB''', '''c''': '''AAABA''', '''d''': '''AAABB''', '''e''': '''AABAA''', '''f''': '''AABAB''', '''g''': '''AABBA''', '''h''': '''AABBB''', '''i''': '''ABAAA''...
248
"""simple docstring""" import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline lowerCAmelCase_ : Tuple ...
248
1
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask A : Tuple = logging.getLogger(__name__) class A (SCREAMING_SNAKE_CASE ): '''simple docstring''' ...
274
import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def __lowerCamelCase ( __a :Dict ) -> Any: """simple docstring""" A__ = [ """decoder.version"...
274
1
import random def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> List[Any]: """simple docstring""" a = num - 1 a = 0 while s % 2 == 0: a = s // 2 t += 1 for _ in range(5 ): a = random.randrange(2, num - 1 ) ...
369
from typing import List, Union import numpy as np from ..utils import add_end_docstrings, 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 ..image_utils import loa...
330
0
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 __snake_case :Optional[int] ...
49
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 SequenceFeatu...
131
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPi...
39
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): def UpperCamelCase ( self ): A__ = [ '''safety_checker/pytorch_model.bin''', ...
39
1
"""simple docstring""" def lowercase ( __snake_case : int , __snake_case : list[int] , __snake_case : int ): def count_of_possible_combinations(__snake_case : int ) -> int: if target < 0: return 0 if target == 0: return 1 return su...
33
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require...
151
0
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging...
335
from dataclasses import dataclass, field from typing import Optional @dataclass class lowercase : '''simple docstring''' __SCREAMING_SNAKE_CASE = field( default="""codeparrot/codeparrot""" , metadata={"""help""": """Model name or path of model to be trained."""} )...
335
1
"""simple docstring""" import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from .....
266
def SCREAMING_SNAKE_CASE__ ( __a , __a ): if density <= 0: raise ValueError('Impossible fluid density' ) if bulk_modulus <= 0: raise ValueError('Impossible bulk modulus' ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": import...
327
0
"""simple docstring""" import comet # From: unbabel-comet import torch import datasets lowerCamelCase__ = datasets.logging.get_logger(__name__) lowerCamelCase__ = "\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, A...
310
"""simple docstring""" import torch from transformers import AutoModel class __SCREAMING_SNAKE_CASE ( torch.nn.Module ): '''simple docstring''' def __init__( self : Dict , __a : Tuple="sayef/fsner-bert-base-uncased" ) -> Dict: super(__a , ...
310
1
"""simple docstring""" import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_a...
81
from collections import namedtuple import requests from lxml import html # type: ignore _A : Any = namedtuple('covid_data', 'cases deaths recovered') def _a ( UpperCAmelCase = "https://www.worldometers.info/coronavirus/" ) -> covid_data: """simple docstring""" ...
142
0
def __UpperCAmelCase ( __a : float ,__a : float ) -> float: """simple docstring""" if mass < 0: raise ValueError('''The mass of a body cannot be negative''' ) return 0.5 * mass * abs(__a ) * abs(__a ) if __name__ == "__main...
15
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 UpperCAmelCase_ ( __lowercase ...
15
1
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example __lowercase = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], ...
40
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxMode...
122
0
'''simple docstring''' import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from dif...
365
'''simple docstring''' import argparse import os import re lowerCAmelCase : Tuple = """src/transformers""" # Pattern that looks at the indentation in a line. lowerCAmelCase : str = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key`...
25
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case : List[str] = { """configuration_trajectory_transformer""": [ """TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TrajectoryTransf...
248
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_utils...
248
1
def UpperCamelCase (lowercase_: Dict , lowercase_: int ) -> Tuple: return price * (1 + tax_rate) if __name__ == "__main__": print(f'''{price_plus_tax(100, 0.25) = }''') print(f'''{price_plus_tax(125.50, 0.05) = }''')
367
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_hub_...
141
0
'''simple docstring''' 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: ...
31
from __future__ import annotations def a__ ( UpperCAmelCase : list[list[int]] ) -> bool: UpperCAmelCase : Union[str, Any] = len(UpperCAmelCase ) # We need to create solution object to save path. UpperCAmelCase : int = [[0 for _ in range(UpperCAmelCase )] fo...
336
0
"""simple docstring""" from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, ...
255
"""simple docstring""" import fire from utils import calculate_rouge, save_json def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_=None , **UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = [x.strip() for x in open(UpperCamelCase_ ).readlines()] __SCRE...
255
1
def __A ( __lowerCAmelCase )-> bool: """simple docstring""" if not all(x.isalpha() for x in string ): raise ValueError('String must only contain alphabetic characters.' ) _UpperCAmelCase = sorted(string.lower() ) return len(__lo...
39
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { '''distilbert-base-uncased''': '''https://huggingface.co/...
39
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ = { '''configuration_longformer''': [ '''LONGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''...
353
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() snake_case_ = logging.get_logger(__name__) snake_case_ = { '''post_extract_proj''': '''feature_projection.projection'...
216
0
"""simple docstring""" import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncod...
263
"""simple docstring""" import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_tensor...
263
1
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_available, is_vision_avai...
193
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_d...
193
1
import comet # From: unbabel-comet import torch import datasets __snake_case = datasets.logging.get_logger(__name__) __snake_case = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon}, title = {Unbab...
310
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_en...
310
1
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table impo...
364
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __UpperCamelCase ( lowerCamelCase__ ): lowercase : List[str] =['image_processor', 'tokenizer'] lowercase : Optional[int] ...
6
0
def UpperCAmelCase ( a_ , a_ ) -> float: """simple docstring""" if mass < 0: raise ValueError("The mass of a body cannot be negative" ) return 0.5 * mass * abs(a_ ) * abs(a_ ) if __name__ == "__main__": import doctest doctest.testmod(verbose=Tr...
15
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 SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE ...
15
1
"""simple docstring""" from math import factorial, pi def _lowerCAmelCase ( lowercase_ , lowercase_ = 30 ): if not isinstance(lowercase_ , (int, float) ): raise ValueError('maclaurin_sin() requires either an int or float for theta' ) if...
181
"""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/licens...
181
1
"""simple docstring""" def A__ ( UpperCamelCase = 100 ): A = set() A = 0 A = n + 1 # maximum limit for a in range(2 , _snake_case ): for b in range(2 , _snake_case ): A = a**b # calculates the current...
292
"""simple docstring""" import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib ...
25
0
'''simple docstring''' 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,...
355
'''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 import...
104
0
"""simple docstring""" from __future__ import annotations import time import numpy as np SCREAMING_SNAKE_CASE : str = [8, 5, 9, 7] SCREAMING_SNAKE_CASE : Tuple = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] SCREAMING_SNAKE_CASE : Any ...
102
'''simple docstring''' import heapq def __UpperCamelCase ( lowercase__ : dict ): '''simple docstring''' __lowercase =[] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Prio...
141
0
"""simple docstring""" import random def lowercase__( __SCREAMING_SNAKE_CASE : list , __SCREAMING_SNAKE_CASE : List[Any] ): lowercase_ : List[Any] = [], [], [] for element in data: if element < pivot: less.append(_...
358
"""simple docstring""" class UpperCamelCase : def __init__( self ,__UpperCamelCase ) -> None: '''simple docstring''' lowercase_ : int = set_counts lowercase_ : List[Any] = max(__UpperCamelCase ) lower...
321
0
from math import ceil def A ( _lowerCamelCase = 1_001 ): '''simple docstring''' _lowerCAmelCase : int = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): _lowerCAmelCase : List[Any] = 2 * i + 1 _lowerCAmelC...
36
'''simple docstring''' 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 lowerCAm...
346
0
import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> List[Any]: '''simple docstring''' return x + 2 class __A ( unittest.TestCase ): ...
323
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __A : Any = logging.get_logger(__name__) __A : Union[str, Any] = { '''shi-labs/dinat-mini-...
323
1