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 warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __A ( lowerCAmelCase ): '''simple docstring''' lowerCAmelCase_ = """Speech2TextFeatureExtractor""" lowerCAmelCase_ = """Speech2TextTokenizer...
209
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __A ( lowerCAmelCase ): '''simple docstring''' lowerCAmelCase_ = """Speech2TextFeatureExtractor""" lowerCAmelCase_ = """Speech2TextTokenizer...
209
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { """uw-madison/mra-base-512-4""": """https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.j...
67
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ) -> int: """simple docstring""" return int((input_a, input_a).count(0 ) != 0 ) def a__ ( ) -> None: """simple docstring""" ...
67
1
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def _a ( UpperCamelCase_ : int ) -> str: """simple docstring""" def wrapper(*UpperCamelCase_ : Dict , **Uppe...
340
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 a_ = get_tests_dir('''fixtures/test_sentencepiece_bpe.model''') ...
340
1
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch import nn from t...
20
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = { "configuration_blenderbot_small": [ "BLENDERBOT_SMALL_PRETRAINED_CONFIG_...
20
1
"""simple docstring""" import fire from utils import calculate_rouge, save_json def _snake_case ( lowercase__ , lowercase__ , lowercase__=None , **lowercase__ ): _lowerCamelCase : Dict = [x.strip() for x in open(lowercase__ ...
96
'''simple docstring''' def a ( __a , __a ) -> int: '''simple docstring''' if len(__a ) != len(__a ): raise ValueError('''String lengths must match!''' ) UpperCamelCase__ :Union[str, Any] = 0 for chara, chara in zip(__a , __a ): ...
97
0
def lowerCamelCase__ ( snake_case_ : list[int] , snake_case_ : list[int] ) -> tuple[float, float]: # Check if the input is valid if not len(snake_case_ ) == len(snake_case_ ) == 3: raise ValueError('''Please enter a valid equation.''' ) if equationa[0] == equati...
371
import math def lowerCamelCase__ ( snake_case_ : int ) -> list[int]: __snake_case = [] __snake_case = 2 __snake_case = int(math.sqrt(snake_case_ ) ) # Size of every segment __snake_case = [True] * (end + 1) ...
238
0
import math import unittest def A ( _lowerCamelCase ): '''simple docstring''' assert isinstance(_lowerCamelCase , _lowerCamelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are prim...
36
import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as np from .import_utils im...
36
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _snake_case : Dict = logging.get_logger(__name__) _snake_case : int = { 'shi-labs/nat-mi...
361
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 DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging ...
207
0
"""simple docstring""" from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def Uppe...
64
"""simple docstring""" import argparse import hashlib # hashlib is only used inside the Test class import struct class lowercase: '''simple docstring''' def __init__( self: List[Any], a_: List[str] ): '''simple docstring''' ...
64
1
'''simple docstring''' lowercase__ : Optional[Any] = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)] def a__ ( lowercase : int ) -> List[str]: """simple docstring""" _UpperCamelCase = 0 while number: # Increased Speed S...
367
'''simple docstring''' import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def a__ ( lowercase : Tuple ) -> Dict: """simple docstring""" _U...
287
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ : List[str] = { """configuration_ctrl""": ["""CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CTRLConfig"""], """tokeniza...
91
"""simple docstring""" from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging UpperCAmelCase_ : Optional[int] = logging.get_logger(__name__) def ...
91
1
"""simple docstring""" import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging i...
356
"""simple docstring""" import math def _lowerCamelCase( a ): __a = [] __a = 2 __a = int(math.sqrt(a ) ) # Size of every segment __a = [True] * (end + 1) __a = [] while start <= end: if...
268
0
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor UpperCamelCase__ = logging.get_logger(__name__) class A ( UpperCAmelCase_ ): def __init__(self : List[str] , *__UpperCAmelCase : List[...
65
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch import pya...
65
1
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva __lowerCamelCase : List[Any] = "" __lowerCamelCase : str = "" __lowerCamelCase : Optional[int] = "" __lowerCamelCase : List[Any] = 1 # (0 is vertic...
371
"""simple docstring""" import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizer...
313
0
"""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
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def __magic_name__ ( __snake_case : Dict , __snake_case : Optional[Any]=False ) -> Tuple: lowercase : Union[str, A...
202
1
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_availa...
356
"""simple docstring""" def _lowerCamelCase(__UpperCamelCase ) -> Optional[Any]: _lowerCAmelCase =0 _lowerCAmelCase =len(__UpperCamelCase ) for i in range(n - 1 ): for j in range(i + 1 , __UpperCamelCase ): if arr[i] > arr[j]: num_inversions += 1 return num_invers...
341
0
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_determi...
82
def _UpperCAmelCase ( snake_case = 10_00 ): """simple docstring""" _lowerCAmelCase = -1 _lowerCAmelCase = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c _lowerCAmelCase = (n ...
82
1
from __future__ import annotations def __magic_name__ ( __lowerCAmelCase : list ) -> float: if not nums: raise ValueError('''List is empty''' ) return sum(__lowerCAmelCase ) / len(__lowerCAmelCase ) if __name__ == "__main__": import doct...
339
def __magic_name__ ( __lowerCAmelCase : int , __lowerCAmelCase : int ) -> int: return abs(__lowerCAmelCase ) if a == 0 else greatest_common_divisor(b % a , __lowerCAmelCase ) def __magic_name__ ( __lowerCAmelCase : int , __lowe...
339
1
"""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...
150
"""simple docstring""" from ...configuration_utils import PretrainedConfig class lowerCAmelCase_ ( lowerCAmelCase ): """simple docstring""" _lowerCAmelCase : Tuple = """bert-generation""" def __init__( self , lowerCAmelCase=5_03_58 , lowerCAmelCase=10_24 ...
150
1
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore __A : Tuple = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" __A : int = [file for file in filepaths if file != file.lower()...
352
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_KEYS loggin...
49
0
import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _snake_case ( lowerCAmelCase : ...
18
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _UpperCamelCase ( lowerCAmelCase ): UpperCAmelCa...
169
0
def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ) -> str: if number < 0 or shift_amount < 0: raise ValueError("both inputs must be positive integers" ) UpperCamelCase__ : Optional[Any] = str(bin(__lowerCAmelCase ) ...
370
from __future__ import annotations def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ) -> list[int]: UpperCamelCase__ : Optional[Any] = 0 UpperCamelCase__ : Any = len(__lowerCAmelCase ) - 1 while i < ...
196
0
'''simple docstring''' 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 __lowercase : Dict = '.' if __name__ == "__main__": __lowercase : Union[str, Any] = os.path.join(REPO_PATH, 'ut...
27
'''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....
27
1
'''simple docstring''' def __lowerCamelCase ( _lowercase ) -> list: if any(not isinstance(_lowercase , _lowercase ) or x < 0 for x in sequence ): raise TypeError("""Sequence must be list of non-negative integers""" ) for _ in range(len(_lowercase ) ): ...
367
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : ...
338
0
lowercase__ : Dict = '''\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n''' lowercase__ : Optional[Any]...
338
"""simple docstring""" import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class _lowerCAmelCase ( pl.LightningModule ): """simple docstring""" def __init__( self : Option...
17
0
from __future__ import annotations import math def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negativ...
358
from ...processing_utils import ProcessorMixin class __magic_name__ ( snake_case ): UpperCamelCase_ :str = """SpeechT5FeatureExtractor""" UpperCamelCase_ :Optional[int] = """SpeechT5Tokenizer""" def __init__( self , ...
60
0
'''simple docstring''' def lowercase_ ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ): """simple docstring""" return int((input_a, input_a).count(1 ) != 0 ) def lowercase_ ( ): """simple docstring""" assert...
254
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowercase_ ( lowerCAmelCase__ : Union[str, Any] ): """simple docstring""" __UpperCAmelCase : Optional[int] = FileLock(str(tmpdi...
254
1
"""simple docstring""" import unittest from transformers import DonutProcessor A = '''naver-clova-ix/donut-base''' class __lowercase ( unittest.TestCase ): '''simple docstring''' def _lowerCamelCase ( self ...
188
"""simple docstring""" import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser ...
188
1
"""simple docstring""" import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table...
260
import math import unittest def __lowercase ( _SCREAMING_SNAKE_CASE ) -> bool: '''simple docstring''' assert isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) and ( number >= 0 ), "'number' must been an int and positive" if 1...
296
0
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
49
from __future__ import annotations class _SCREAMING_SNAKE_CASE : def __init__( self , _SCREAMING_SNAKE_CASE )-> None: lowerCamelCase_ =data lowerCamelCase_ =None lowerCamelCase_ =None def __UpperCamelCase ( ...
49
1
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransforme...
83
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np a__ : Optional[int] = re.compile(R'\b(a|an|the)\b', re.UNICODE) a__ : int = None def _UpperCamelCase ( ) -> Dict...
80
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = {'''configuration_mmbt''': ['''MMBTConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNo...
361
"""simple docstring""" from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('''3.8'''): import importlib_metadata else: import importlib.metadata as importlib_metadata...
133
0
import cva import numpy as np class UpperCAmelCase__ : """simple docstring""" def __init__( self , A_ , A_ ) -> Optional[Any]: if k in (0.04, 0.06): __UpperCamelCase =k __UpperCamelCase =window_size ...
62
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_dim...
62
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE : Union[str, Any] = { """configuration_llama""": ["""L...
157
"""simple docstring""" from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention...
157
1
'''simple docstring''' import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin ...
267
from collections import namedtuple import requests from lxml import html # type: ignore SCREAMING_SNAKE_CASE :Union[str, Any] = namedtuple('''covid_data''', '''cases deaths recovered''') def _lowerCAmelCase ( lowerCAmelCase_ :str = "https://www.worldometers.info/coronavir...
159
0
"""simple docstring""" import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _a = logging.get_logger(__name__) _a = { 'vocab_file': 'vocab.json', 'merges_file...
358
"""simple docstring""" _a = [ 'DownloadConfig', 'DownloadManager', 'DownloadMode', 'StreamingDownloadManager', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager ...
144
0
def _a ( UpperCamelCase_ : Optional[int] ) -> List[str]: """simple docstring""" assert ( isinstance(A__ , A__ ) and number_of_steps > 0 ), F"number_of_steps needs to be positive integer, your input {number_of_steps}" if number_of_s...
340
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowercase_ (lowerCamelCase__ ): """simple docstring""" SCREAMING_SNAKE_CASE : Optional[Any] = ['image_processor', 'tokenizer'] ...
104
0
import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available lowerCamelCase_ : List[Any] = logging.getLogger(__name__) @datacl...
368
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def A__ ( ) -> Union[str, Any]: import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dirname as original_dirname ...
223
0
from __future__ import annotations def snake_case( __magic_name__ = 4 ) -> list[list[int]]: '''simple docstring''' lowercase : Tuple = abs(__magic_name__ ) or 4 return [[1 + x + y * row_size for x in range(__magic_name__ )] for y...
308
import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeling_tf_auto...
308
1
"""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...
366
"""simple docstring""" from math import factorial, radians def a__ ( lowerCAmelCase , lowerCAmelCase = 18 , lowerCAmelCase = 10 ) -> float: UpperCAmelCase__ : List[Any] = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) # Converting from degrees to radians ...
166
0
'''simple docstring''' import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def snake_case__ ( _A: List[Any] ) -> List[str]: '''simple docstring''' if "model" in orig_key: lowerCAmelCase = orig_key.replace("""model.""" , """""" ) if...
272
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_prop...
272
1
def __lowercase ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> str: '''simple docstring''' if not (isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) and isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE )): ...
193
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE_ = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], """...
193
1
'''simple docstring''' import os def SCREAMING_SNAKE_CASE_ (UpperCamelCase = "input.txt" ) -> int: with open(os.path.join(os.path.dirname(UpperCamelCase ) , UpperCamelCase ) ) as input_file: lowerCamelCase__ ...
41
'''simple docstring''' from __future__ import annotations _A : Any ={ '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''...
41
1
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def __UpperCamelCase ( ) ->Dict: """simple docstring""" import os as original_os from os import path as original_path from os import rename as original_rename ...
354
from __future__ import annotations class _SCREAMING_SNAKE_CASE : def __init__( self , _SCREAMING_SNAKE_CASE )-> None: lowerCamelCase_ =data lowerCamelCase_ =None lowerCamelCase_ =None def __UpperCamelCase ( ...
49
0
def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAKE_CASE : int ): """simple docstring""" __a = (boundary[1] - boundary[0]) / steps __a = boundary[0] __a = boundary[1] __a = make_points(_SCREAMING_SNAKE...
302
class SCREAMING_SNAKE_CASE : def __init__( self : List[Any] , __lowercase : Union[str, Any] ): '''simple docstring''' __a = val __a = None __a = None def UpperCamelCase_ ...
302
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase = { 'configuration_roc_bert': ['ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoCBertConfig'], 'tokenization_roc_bert': ['RoCBertTokeniz...
361
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" return base * power(SCREAMING_SNAKE_CASE , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of exponent using recursion...') ...
93
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 AddedToken, PreTrainedTokenizer from ...utils import logging __A = logging.get_logger(__name__) __A = {"vocab_file": "...
164
'''simple docstring''' import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class A ( __UpperCAmelCase ): lowerCamelCase : Union[str, Any] = """MCTCTFeatureExtractor""" lowerCamelCase : Dict = ""...
164
1
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, loggi...
355
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class __snake_case ( unittest.TestCase ): def lowerCamelCase ( self : Dict): """simple...
7
0
from collections.abc import Sequence def UpperCAmelCase_( a__ , a__ = False ): """simple docstring""" if not arr: return 0 SCREAMING_SNAKE_CASE : Optional[Any] = 0 if allow_empty_subarrays else float('''-inf''' ) SCREAMING_SNAKE_CASE ...
313
import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import DEFAULTS, task_specific_params ...
313
1
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...
355
# 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 # # Unl...
247
0
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("""dataset_size""" , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize("""input_in_memory_max_size""" , ["""default""", 0, 100 * 2**20, 900 * 2**20] ) def __low...
245
import os import pytest from attr import dataclass UpperCAmelCase__ : Optional[int] = """us-east-1""" # defaults region @dataclass class a__ : """simple docstring""" UpperCAmelCase__ : str UpperCAmelCase__ : Union[str, ...
245
1
"""simple docstring""" 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. UpperCAmelCase = 10 def lowercase ( a__ : int , a__ : int , a__ : list[i...
54
"""simple docstring""" import numpy as np def lowercase ( a__ : Optional[Any] , a__ : str , a__ : Union[str, Any] , a__ : Any , a__ : List[str] ) -> Dict: _UpperCamelCase = int(np.ceil((x_end - xa) / h ) ) _UpperCamelCa...
54
1
"""simple docstring""" from __future__ import annotations def lowercase ( _snake_case : int = 4 ) ->list[list[int]]: """simple docstring""" __snake_case : str = abs(_snake_case ) or 4 return [[1 + x + y * row_size for x in range(_snake_case )] for y in...
102
import math def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ) -> float: if ( not isinstance(_SCREAMING_SNAKE_CASE ,(int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("power_factor must be a...
48
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_con...
349
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A_ : List[Any] = logging.get_logger(__name__) A_ : Union[str, Any] = ...
349
1
'''simple docstring''' def _A ( A__ = 3 , A__ = 7 , A__ = 1000000 ): """simple docstring""" __lowercase = 0 __lowercase = 1 for current_denominator in range(1 , limit + 1 ): __lowercase = current_denominator * numerator // denominat...
104
import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def _snake_case ( lowerCAmelCase : str , lowerCAmelCase : Union[str, ...
18
0
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import Conf...
34
def UpperCamelCase( lowercase_ , lowercase_ ) -> str: '''simple docstring''' return "\n".join( f'''{number} * {i} = {number * i}''' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_t...
34
1
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class lowercase__ ...
201
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy,...
7
0
'''simple docstring''' lowerCamelCase = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], """G""": ["""C"""], } def _A ( _...
354
'''simple docstring''' import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging lowerCamelCase ...
48
0
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase : List[str] = logging.get_logger(__name__) UpperCAmelCase : Tuple = { "vocab_file": "vocab.json", "merges_...
252
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : List[str] = { "configuration_x_clip": [ "XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "XCLIPConfig", "XCLIPTextConfig", "XCLIPVisionConfig...
252
1
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 accelerate import ...
358
import unittest import numpy as np from transformers import BertConfig, 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(): from transformers.mod...
225
0
'''simple docstring''' from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def __lowerCamelCase ( lowerCAmelCase_ = True , *lowerCAmelCase_ , **lowerCAmelCase_ ) -> Dict: if not is_tqd...
89
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 ModelTesterMixin, UNetTesterMixin __sn...
129
0
import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput lowerCAmelCase__ = logging.getLogger(__name__) if is_torch_tpu_available(check_device=False...
119
import argparse from collections import defaultdict import yaml lowerCAmelCase__ = 'docs/source/en/_toctree.yml' def __lowerCamelCase ( lowerCAmelCase__ ): lowerCAmelCase__ = defaultdict(lowerCAmelCase__ ) for doc in model_doc: counts[doc["loca...
119
1
'''simple docstring''' from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split __UpperCAmelCase =datasets.load_iris() __UpperCAmelCase =np.array(data["data"]) __UpperCAmelCase =np.array(data["target"]) _...
67
import logging from transformers import PretrainedConfig _UpperCAmelCase = logging.getLogger(__name__) _UpperCAmelCase = { """bertabs-finetuned-cnndm""": """https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json""", } c...
140
0
"""simple docstring""" import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ): lowercase__ = "M-CLIP" def __init__( self : List[Any] , lowerCAmelCase_ : Dict=1_0_2_4 , ...
359
"""simple docstring""" import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators ...
313
0
import math from numpy import inf from scipy.integrate import quad def _a ( SCREAMING_SNAKE_CASE : float ) -> float: """simple docstring""" if num <= 0: raise ValueError('math domain error' ) return quad(SCREAMING_SNAKE_CASE , 0 , SCREAMING_...
322
from __future__ import annotations def _a ( SCREAMING_SNAKE_CASE : list[int] , SCREAMING_SNAKE_CASE : int ) -> list[int]: """simple docstring""" __lowerCAmelCase: int = 0 __lowerCAmelCase: Tuple = len(SCREAMING_SNAKE_CASE ) - 1 wh...
322
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { "configuration_megatron_bert": ["MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MegatronBertConfig"], } try: if not is_torch_available(): raise OptionalDepend...
273
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger __A = get_logger(__name__) class _SCREAMING_SNAKE_CASE ( enum.Enum ): '''simple docstring''' lowercase_ = "all_checks" lowercase_ = ...
273
1
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller UpperCamelCase__ = 3 def a__ ( lowerCAmelCase__ ) -> int: print('''Generating primitive root of p''' ) while Tr...
181
'''simple docstring''' import pprint import requests UpperCamelCase__ = '''https://zenquotes.io/api''' def a__ ( ) -> list: return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def a__ ( ) -> list: return requests...
181
1
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 if is_torch_availa...
201
from __future__ import annotations from collections import deque class lowerCAmelCase : def __init__( self :List[Any] , _lowercase :list[str] ): '''simple docstring''' lowercase__ = [] self.adlist.append( {"value": "", "next_states"...
201
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase : Any = { """configuration_electra""": ["""ELECTRA_PRETRAINED_CONF...
52
"""simple docstring""" from scipy.stats import pearsonr import datasets _UpperCamelCase: str = '\nPearson correlation coefficient and p-value for testing non-correlation.\nThe Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of ...
255
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_image, load_numpy,...
352
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): ...
60
0
from __future__ import annotations def _lowerCAmelCase (_lowerCAmelCase , _lowerCAmelCase): UpperCamelCase_ = [] UpperCamelCase_ = [] UpperCamelCase_ = 0 UpperCamelCase_ = sum(SCREAMING_SNAKE_CASE_) create_state_sp...
128
'''simple docstring''' import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import...
158
0
'''simple docstring''' import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline lowerCamelCase__ ...
354
'''simple docstring''' from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline lowerCamelCase__ = logging.get_logger(__n...
322
0
"""simple docstring""" 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...
61
"""simple docstring""" import numpy as np def a__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase = 1E-12 , lowerCAmelCase = 1_00 , ) -> tuple[float, np.ndarray]: assert np.shape(lowerCAmelCase )[0] == np.shape(lowerCAmelCase )[1] # Ensure prope...
171
0
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap snake_case : Dict = "Usage of script: script_name <size_of_canvas:int>" snake_case : List[Any] = [0] * 100 + [1] * 10 random.shuffle(choice) def lowerCAme...
41
from __future__ import annotations snake_case : Optional[int] = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } class _snake_case : def __init__( self , _a , ...
41
1
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> List[Any]: _snake_case = [0] * len(__A ) _snake_case = [] _snake_case = [1] * len(__A ) for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(__A ) ): if indegree[i] == ...
42
'''simple docstring''' import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers...
162
0
import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accel...
26
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIte...
26
1
'''simple docstring''' from typing import Dict from .base import GenericTensor, Pipeline class _snake_case ( _a ): def __UpperCamelCase ( self : Dict ,SCREAMING_SNAKE_CASE__ : List[Any]=None ,SCREAMING_SNAKE_CASE__ : int=None ,SCREAMING_SNAKE_CASE__ ...
139
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "t5-small": "https://huggingface.co/t5-small/resolve/ma...
139
1
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelForQuestionAnswering...
262
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, ...
262
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __UpperCamelCase : List[Any] = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_vision_avai...
228
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 diffu...
228
1
"""simple docstring""" import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets __UpperCamelCase = datasets.logging.get_logger(__name__) __UpperCamelCase = '''\ @inproceedings{bleurt, title={BLEURT: Learning Robust Metrics for...
368
"""simple docstring""" import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __UpperCamelCase = get_tests_di...
312
0
'''simple docstring''' import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() _lowerCamelCase : Any = logging.get_logger(__name__) _lowerCamelCase : int ...
28
'''simple docstring''' import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six...
28
1
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enable_full_dete...
17
'''simple docstring''' def __UpperCAmelCase ( a_: int, a_: int ): if not isinstance(a_, a_ ): raise ValueError("iterations must be defined as integers" ) if not isinstance(a_, a_ ) or not number >= 1: raise ValueError( "starting number must be\n ...
17
1
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class _UpperCamelCase : '''simple docstring''' def __init__( self : Optional[Any...
76
'''simple docstring''' from PIL import Image def _a( UpperCamelCase__ : Image, UpperCamelCase__ : float ): '''simple docstring''' def brightness(UpperCamelCase__ : int ) -> float: return 1_2_8 + level + (c - 1_2_8) ...
152
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging.set...
223
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigT...
223
1
import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class lowercase__( UpperCAmelCase , unittest.TestCase ): """simple docstring""" a :Optional[Any] ...
30
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoMod...
59
0
"""simple docstring""" from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup lowercase__ : List[str] = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def __lowercase ( _a = "mumbai" ): snake_ca...
155
"""simple docstring""" 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, ) lowercase__ : List[Any] = { '''confi...
155
1
import math def lowerCAmelCase__(__snake_case ,__snake_case ) -> float: '''simple docstring''' if ( not isinstance(__snake_case ,(int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError('''power_factor must be a valid float ...
209
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def lowerCAmelCase__(__snake_case ) -> int: # picklable for multiprocessing ...
209
1
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class __lowerCAmelCase ( unittest.TestCase , A ): def _lowerCamelCase ( self : Tuple) -> Union[str, Any]: """simple docstring""" _Upp...
290
from typing import TYPE_CHECKING from ...utils import _LazyModule UpperCAmelCase__ = {"tokenization_bertweet": ["BertweetTokenizer"]} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys UpperCAmelCase__ = _LazyModule(__name__, globals()["__...
290
1
"""simple docstring""" import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXL...
25
"""simple docstring""" import math import unittest def lowercase_ ( _snake_case ): assert isinstance(_snake_case ,_snake_case ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes ...
25
1
'''simple docstring''' from __future__ import annotations def _lowerCamelCase ( lowerCamelCase_ : list , lowerCamelCase_ : int | None = None , lowerCamelCase_ : int | None = None ): """simple docstring""" if start is None: UpperCAmelCase_ ...
274
'''simple docstring''' snake_case__ : str = '''Tobias Carryer''' from time import time class __SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self , snake_case_ , snake_case_ , snake_case_ , snake_case_=int(time() ) ): # no...
274
1
'''simple docstring''' from ...processing_utils import ProcessorMixin class a__( lowerCAmelCase__ ): '''simple docstring''' UpperCAmelCase_ : Tuple = '''SpeechT5FeatureExtractor''' UpperCAmelCase_ : Union[str, Any] = '''SpeechT5Tokenizer''' def ...
272
'''simple docstring''' 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 a__( enum.En...
272
1
"""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, PoolFormerImageProcessor...
370
from __future__ import annotations from typing import Any class _SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__(self : Any , UpperCAmelCase_ : int) ->None: '''simple docstring''' lowerCamelCase__: int =num_of_nodes lowerCamelCase__...
273
0
"""simple docstring""" import qiskit def UpperCamelCase__ ( lowercase__ : int , lowercase__ : int ): snake_case : Tuple = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register snake_case : List[s...
148
"""simple docstring""" import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_availa...
148
1
def lowercase_ ( _lowerCamelCase : int , _lowerCamelCase : int): while second != 0: lowercase__ : List[Any] = first & second first ^= second lowercase__ : Optional[int] = c << 1 return first if __name__ == "__main__": ...
333
import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from transformers import...
333
1
import math def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : int ) -> bool: assert isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are prime...
325
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : list[list[int]] ) -> int: # preprocessing the first row for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column ...
325
1
def lowerCamelCase__ ( a__ : Optional[int] ) -> List[str]: if not head: return True # split the list to two parts UpperCamelCase_ , UpperCamelCase_ = head.next, head while fast and fast.next: UpperCamelCase_ =...
261
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowercase_ ( __SCREAMING_SNAKE_CASE ): A__ : List[Any] = """EncodecFeatureExtractor""" A__ : Tuple = ("""T5Tokenizer""", """T5TokenizerFast"...
261
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : int = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_available(): raise Opt...
274
from __future__ import annotations from collections.abc import Callable __lowerCAmelCase = list[list[float | int]] def snake_case_ ( snake_case , snake_case ) -> Matrix: lowercase__: int = len(snake_case ) lowercase__: Matrix =...
196
0
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logg...
53
"""simple docstring""" import datasets from .evaluate import evaluate _UpperCamelCase: 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 ...
53
1
"""simple docstring""" import math from datetime import datetime, timedelta def a__ ( __SCREAMING_SNAKE_CASE ) -> Tuple: __lowerCAmelCase: str = year % 1_9 __lowerCAmelCase: List[Any] = year % 4 __lowerCAmelCase: Tuple = year %...
217
def __lowerCamelCase ( UpperCAmelCase_ : int = 1000 ): """simple docstring""" a , a :int = 1, 1 a :Any = 2 while True: a :Optional[int] = 0 a :str = fa + fa ...
94
0
import numpy as np from PIL import Image def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> np.ndarray: lowerCAmelCase__ : Optional[Any] = np.array(SCREAMING_SNAKE_CASE_ ) if arr.shape[0] != arr.shape[1]: ...
351
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate lowerCamelCase__ = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow("""""", """|""", """|"""...
307
0