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
"""simple docstring""" def _lowerCamelCase( ): __a = 0 for i in range(1 , 1_0_0_1 ): total += i**i return str(a )[-1_0:] if __name__ == "__main__": print(solution())
261
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_com...
261
1
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # al...
349
'''simple docstring''' from __future__ import annotations import math def snake_case_ ( lowerCAmelCase_ )-> list[int]: '''simple docstring''' if num <= 0: _UpperCAmelCase : List[Any] = F'''{num}: Invalid input, please enter a positive integer....
349
1
"""simple docstring""" def A_ ( _lowercase ): '''simple docstring''' if not isinstance(_lowercase, _lowercase ): raise TypeError("""Input value must be an 'int' type""" ) snake_case_ :Any = 0 while number: position += 1 number >>...
66
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_d...
66
1
from __future__ import annotations lowerCAmelCase__ : List[Any] =[-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] lowerCAmelCase__ : Dict =[-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def a__ ( A__ ): SCREAMING_SNAKE_CASE_ : ...
162
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, Ope...
162
1
'''simple docstring''' import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib im...
250
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class UpperCAmelCase_ ( a): def snake_case__ ( self, __a): '''simple docstring''' return 0.0 def A ...
36
0
"""simple docstring""" import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelin...
168
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class __magic_name__ ( UpperCAmelCase__ ): '''simple docstring''' __UpperCamelCase = (KDPMaDis...
168
1
'''simple docstring''' import argparse from collections import defaultdict import yaml _lowerCamelCase : Optional[Any] = 'docs/source/en/_toctree.yml' def __a ( UpperCAmelCase ) ->List[Any]: """simple docstring""" A = defaultdict(UpperCAmelCase ) A...
258
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tok...
124
0
'''simple docstring''' import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as tran...
16
'''simple docstring''' import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, ...
16
1
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTe...
349
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer a__ : Optional[Any] =...
349
1
'''simple docstring''' import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.me...
228
'''simple docstring''' import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging __UpperCAmelCase = logging.get_logger(__name__) class a__ ( ...
228
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase = { '''configuration_funnel''': ['''FUNNEL_PRETRAINED_CONFIG_ARCHIVE...
162
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { '''weiweishi/roc-bert-base-zh''': '''https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.js...
162
1
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __snake_case ( _SCREAMING_SNAKE_CASE): """simple docstring""" lowercase = ['image_proce...
371
'''simple docstring''' from __future__ import annotations def UpperCamelCase_ ( A__ : int | float | str , A__ : int | float | str ): '''simple docstring''' if nth_term == "": return [""] lowerCAmelCase_ : str = i...
89
0
'''simple docstring''' import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class a ( _SCREAMING_SNAKE_CASE ): _lowerCAmelCase = (DDIMParallelScheduler,) _lowerCAmelCase = (("""eta""", 0.0), ("...
168
'''simple docstring''' import math class a : def __UpperCAmelCase ( self , __magic_name__ , __magic_name__ ) -> int: _a = 0.0 _a = 0.0 for i in range(len(__magic_name__ ) ): da += math.pow...
168
1
from math import loga def lowerCamelCase_ ( _UpperCamelCase ) -> Tuple: """simple docstring""" if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(__lowerCamelCase , __lowerCamelCase ): raise TypeError(''...
351
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 lowerCamelCase_ ( _UpperCamelCase ) -> tuple: ...
279
0
"""simple docstring""" import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import l...
16
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is...
16
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_available, is_tf_availa...
351
"""simple docstring""" import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) _a = logging.getLogger() def ...
23
0
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : int...
228
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logg...
228
1
import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append(""".""") def snake_case_ (__A : int ) -> str: __lowerCAmelCase : Union[str, Any] = ...
139
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
139
1
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 : str = logging.getLogger(__name__) ...
219
'''simple docstring''' import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixi...
89
0
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline UpperCamelCase__ = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) parser.add_argument("--dpm", action="store_true",...
352
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/config.json", "xlnet-large-cased": "https://huggingfac...
87
0
"""simple docstring""" import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_fu...
16
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_ = logging.getLogger(__name__) @dataclass class ...
279
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase_ : Union[str, Any] = logging.get_logger(__name__) UpperC...
142
'''simple docstring''' from __future__ import annotations from collections.abc import Callable def __a ( _UpperCamelCase: Callable[[int | float], int | float] , _UpperCamelCase: int | float , _UpperCamelCase: int | float , _UpperCamelCase: int = 100 , ) ->...
142
1
'''simple docstring''' __SCREAMING_SNAKE_CASE :int = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} __SCREAMING_SNAKE_CASE :Any = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def UpperCAmelCase_ ( __lowercase : dict[int, list[int]] , __lowercase ...
22
'''simple docstring''' 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 SCREAMING_S...
23
0
'''simple docstring''' from functools import lru_cache @lru_cache def __lowerCamelCase ( __lowerCAmelCase : Union[str, Any] ) -> int: if num < 0: raise ValueError("""Number should not be negative.""" ) return 1 if num in (0, 1) else nu...
362
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transfo...
3
0
'''simple docstring''' from __future__ import annotations from math import ceil, floor, sqrt def A_ ( snake_case = 2000000 ): SCREAMING_SNAKE_CASE:list[int] = [0] SCREAMING_SNAKE_CASE:int for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ...
139
'''simple docstring''' from __future__ import annotations def A_ ( snake_case , snake_case , snake_case , ): if (stress, tangential_force, area).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 values" ) elif stress < 0...
139
1
"""simple docstring""" import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow __snake_case = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ """tex...
112
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requ...
112
1
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( A_ , A_ = False ): if n == 2: return True if not n % 2 or n < 2: return False if n > 5 and n % 10 not in (1, 3, 7, 9): # can quickly check last digit return False if n > 3_31_70_44_06_46_79_88_73_85_96_19_81 and not allow_probable: ...
106
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big...
87
0
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowercase__ ( _UpperCAmelCase ): A__ : List[str] =(DP...
359
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP __snake_case = False try: __snake_case = _is_packa...
169
0
from pathlib import Path import numpy as np from PIL import Image def _a ( UpperCAmelCase ) -> np.ndarray: """simple docstring""" lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ : List[Any] = rgb[:, :, 0], rgb[:, :, 1], rgb[:, :,...
142
def _a ( UpperCAmelCase , UpperCAmelCase ) -> float: """simple docstring""" return price * (1 + tax_rate) if __name__ == "__main__": print(F'''{price_plus_tax(1_00, 0.25) = }''') print(F'''{price_plus_tax(125.50, 0.05) = }''')
142
1
'''simple docstring''' def lowercase (_A , _A ): """simple docstring""" _lowerCAmelCase : Tuple = len(_A ) _lowerCAmelCase : List[Any] = [[False] * (required_sum + 1) for _ in range(arr_le...
362
'''simple docstring''' lowerCAmelCase : Union[str, Any] = 0 # The first color of the flag. lowerCAmelCase : Optional[int] = 1 # The second color of the flag. lowerCAmelCase : int = 2 # The third color of the flag. lowerCAmelCase : Any...
25
0
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPAIN...
101
'''simple docstring''' import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers...
3
0
from collections import defaultdict from math import ceil, sqrt def UpperCamelCase ( _A = 1000000, _A = 10 ): """simple docstring""" __magic_name__ : defaultdict = defaultdict(_A ) for outer_width in range(3, (t_limit // 4) + 2 ): ...
138
from decimal import Decimal, getcontext from math import ceil, factorial def UpperCamelCase ( _A ): """simple docstring""" if not isinstance(_A, _A ): raise TypeError("""Undefined for non-integers""" ) elif precision < 1: raise ValueError(""...
138
1
'''simple docstring''' import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_v...
112
'''simple docstring''' import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import Paddin...
112
1
def _UpperCAmelCase (UpperCamelCase_ : dict ): '''simple docstring''' _lowerCAmelCase : Tuple = set() # edges = list of graph's edges _lowerCAmelCase : int = get_edges(__A ) # While there are still elements in edges list, take an arbitrary edge ...
357
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def _UpperCAmelCase (UpperCamelCase_ : Tuple , UpperCamelCase_ : Dict ): '''simple docstring''' _lowerCAmelCase : ...
159
0
def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ = 0 , lowercase_ = 0 ) -> Optional[int]: """simple docstring""" A__ = right or len(_lowerCAmelCase ) - 1 if left > right: return -1 elif list_data[left] == key:...
14
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class _UpperCamelCase ( lowerCAmelCase ): UpperCAmelCase_ = ...
169
0
from collections.abc import Callable def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_ ): _A : float = a _A : float = b if function(snake_case_ ) == 0: # one of the a or b is a root for the function return a ...
343
from __future__ import annotations from collections.abc import Callable _snake_case = list[list[float | int]] def lowerCAmelCase_ ( snake_case_,snake_case_ ): _A : int = len(snake_case_ ) _A : Matrix = [[0 for _ in range(size + 1 ...
343
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { 'microsoft/wavlm-base': 'https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json', # Se...
26
"""simple docstring""" import mpmath # for roots of unity import numpy as np class lowerCAmelCase_ : """simple docstring""" def __init__(self , SCREAMING_SNAKE_CASE__=None , SCREAMING_SNAKE_CASE__=None ) -> Dict: """simple docstring...
25
0
'''simple docstring''' import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def ...
371
'''simple docstring''' import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common i...
55
0
import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, require_multi_gpu from a...
138
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> str: '''simple docstring''' return " ".join( ''.join(word[::-1] ) if len(_UpperCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_w...
138
1
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def _lowerCAmelCase ( ): '''simple docstring''' UpperCAmelCase , UpperCAmelCase = 9, 14 # noqa: F841 UpperCAmelCase = [ ...
152
def _lowerCAmelCase ( A__: int = 1000 ): '''simple docstring''' UpperCAmelCase = 2**power UpperCAmelCase = str(A__ ) UpperCAmelCase = list(A__ ) UpperCAmelCase = 0 for i in list_num: sum_of_num += int(A__ ...
152
1
'''simple docstring''' from __future__ import annotations from collections.abc import MutableSequence class UpperCAmelCase_ : def __init__( self : Dict , UpperCAmelCase__ : int , UpperCAmelCase__ : MutableSequence[float] ) ...
4
from __future__ import annotations def _lowerCAmelCase ( lowerCAmelCase_ :float , lowerCAmelCase_ :float , lowerCAmelCase_ :float )->float: '''simple docstring''' if days_between_payments <= 0: raise ValueError("days_between_payments mu...
159
0
"""simple docstring""" import argparse import os import re snake_case_ = """src/transformers/models/auto""" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict snake_case_ = re.compile(R"""[A-Z_]+_M...
181
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ = { """configuration_rember...
181
1
from collections.abc import Callable def lowercase( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ) -> float: '''simple docstring''' UpperCamelCase = a UpperCamelCase = b if function(UpperCamelCase_ ) == 0: # one of the a or b is a root for the fu...
343
def lowercase( UpperCamelCase_ , UpperCamelCase_ ) -> float: '''simple docstring''' if mass < 0: raise ValueError("""The mass of a body cannot be negative""" ) return 0.5 * mass * abs(UpperCamelCase_ ) * abs(UpperCamelCase_ ) if __name__ == "__main__": import doctes...
343
1
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class lowerCAmelCase__ ( lowerCamelCase_ ): lowerCAmelCase_ = ['''image_processor''', '''tokenizer'''] lowerCA...
367
'''simple docstring''' def snake_case_ ( __SCREAMING_SNAKE_CASE : str ): """simple docstring""" return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__SCREAMING_SNAKE_CASE ) ) if txt[a].isalpha() ...
264
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_sec...
41
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils impo...
55
0
"""simple docstring""" def lowercase ( A_ = 10 , A_ = 22 )-> int: '''simple docstring''' a : str = range(1 , A_ ) a : List[Any] = range(1 , A_ ) return sum( 1 for power in powers for base...
226
"""simple docstring""" import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # p...
226
1
'''simple docstring''' def _a( UpperCamelCase__ : int = 1_0_0_0 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Any =2**power SCREAMING_SNAKE_CASE__ : Union[str, Any] =str(UpperCamelCase__ ) SCREAMING_S...
152
'''simple docstring''' import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import ded...
152
1
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformer...
112
"""simple docstring""" import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow __snake_case = logging.getLogger() @unittest.skip('''Temporarily...
112
1
'''simple docstring''' from __future__ import annotations import math import random from typing import Any class lowerCamelCase_ : def __init__( self : List[Any] ): '''simple docstring''' UpperCAmelCase__ : list[Any] = ...
181
'''simple docstring''' # Algorithm for the pigeonhole sorting def a__ ( lowerCAmelCase__ ) -> Optional[Any]: UpperCAmelCase__ : Any = min(lowerCAmelCase__ ) # min() finds the minimum value UpperCAmelCase__ : Optional[int] = ...
181
1
import string def snake_case_ ( lowerCAmelCase_ : str ): for key in range(len(string.ascii_uppercase ) ): __lowercase : Any = """""" for symbol in message: if symbol in string.ascii_uppercase: __...
306
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Union[str, Any] = logging.get_logger(__name__) lowerCamelCase : str = { '''facebook/nllb-moe-54B''': '''https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json''', } class ...
306
1
def lowerCAmelCase_ ( __a , __a , __a ) -> bool: """simple docstring""" return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(__a ) ) def lowerCAmelCase_ ( __a , __a , __a , __a ) -> bool: ...
10
"""simple docstring""" import sys lowercase__ : Dict = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557'''...
264
0
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def UpperCamelCase (lowercase_: int = 3 ) -> qiskit.result.counts.Counts: if isinstance(_snake_case , _snake_case ): raise TypeError("""number of qubits must b...
352
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...test...
141
0
def a ( _UpperCAmelCase : int ): '''simple docstring''' if number < 0: raise ValueError('''number must not be negative''' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod() ...
226
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_...
226
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __magic_name__: Optional[Any] = { "configuration_graphormer": ["GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "GraphormerConfig"], } try: if not is_t...
355
import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation __magic_na...
138
0
'''simple docstring''' from decimal import Decimal, getcontext from math import ceil, factorial def lowerCAmelCase_ ( _lowerCamelCase: int ): if not isinstance(_lowerCamelCase , _lowerCamelCase ): raise TypeError("""Undefined for non-integers""" ) elif precision < 1: ...
112
'''simple docstring''' 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_fast import BertTokenizerFast from .tokenization_dpr import DP...
112
1
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_determinism, load_numpy...
352
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { "xlnet-base-cased": "https://huggingface.co/xlnet-base-cased/resolve/main/config.json", "xlnet-large-cased": "https://huggingfac...
87
0
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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils impo...
306
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils im...
306
1
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py __UpperCAmelCase = '''.''' if __name__ == "__main__": __UpperCAmelCase = os.path.join(REPO_PATH, '''utils/documentation_tests.txt''') __U...
362
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_p...
103
0
import random from typing import Any def UpperCamelCase_( lowerCamelCase_ ) -> list[Any]: for _ in range(len(lowerCamelCase_ ) ): _lowercase : Optional[int] = random.randint(0 , len(lowerCamelCase_ ) - 1 ) _lowercase : str = random...
21
'''simple docstring''' def __UpperCamelCase ( lowercase__ : str, lowercase__ : bool = False ): '''simple docstring''' if not isinstance(lowercase__, lowercase__ ): __lowercase =F'''Expected string as input, found {type(lowercase__ )}''' ...
141
0
"""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_available, logg...
57
"""simple docstring""" import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from...
57
1
from __future__ import annotations class __lowerCAmelCase : """simple docstring""" def __init__( self : Any , _snake_case : Optional[int]=None ): __lowercase : Dict = data __lowercase : List[Any] = None ...
156
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokeni...
138
0
"""simple docstring""" import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowercase : List[Any] = lo...
272
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) _lowercase : Any = { "configuration_trocr": ["TROCR_PRETRAINED_CONFIG_...
272
1
"""simple docstring""" __UpperCamelCase : Optional[int] = [0, 2, 4, 6, 8] __UpperCamelCase : Optional[int] = [1, 3, 5, 7, 9] def __SCREAMING_SNAKE_CASE ( A_ , A_ , A_ , A_ ): if remaining_length == 0: if digits[0] == 0 or digits[-1] == ...
106
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big...
87
0
'''simple docstring''' UpperCamelCase_ : Optional[int] = {'''a''': ['''c''', '''b'''], '''b''': ['''d''', '''e'''], '''c''': [], '''d''': [], '''e''': []} UpperCamelCase_ : Any = ['''a''', '''b''', '''c''', '''d''', '''e'''] def __a ( _UpperCamelCa...
362
'''simple docstring''' def __a ( _UpperCamelCase: int ) -> None: """simple docstring""" _snake_case = generate_pascal_triangle(_UpperCamelCase ) for row_idx in range(_UpperCamelCase ): # Print left spaces for _ in range(num_rows - ...
142
0
'''simple docstring''' import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def UpperCamelCase_ ( _UpperCAmelCase : int ) -> Dict: """simple docstring""" _UpperCAmelCase : Optional[int] ...
31
import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipeline_mixi...
103
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 SCREAMING_SNAKE_CASE_ = logging.getLogger(__name__) if is_torch_tp...
354
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
0
"""simple docstring""" import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from da...
57
"""simple docstring""" from __future__ import annotations def _lowerCamelCase ( _UpperCamelCase = 4 ): '''simple docstring''' __lowerCAmelCase = abs(_UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(_UpperCamelCase )] for y in range(_UpperCamelCase )]...
57
1
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_proce...
173
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def __lowercase ( _Up...
173
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) __lowercase = { '''configuration_trocr''': ['''TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP''...
272
'''simple docstring''' from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig __lowercase = { '''susnato/ernie-m-base_pytorch''': '''https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json''', '''susnato/ernie-m-large_py...
272
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCamelCase : Union[str, Any] = logging.get_logger(__name__) __lowerCamelCase : Tuple = { """roberta-b...
140
import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __lowerCamelCase : Dict = get_tests_dir("""fixtures/spiec...
140
1
def __lowercase ( __lowerCAmelCase : str ): 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) ...
240
import argparse import os import re import packaging.version _A : Optional[int] = 'examples/' _A : str = { 'examples': (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compile(r'^__version__\s+=\s+"([^"]+)"\s*$', re.MULT...
142
0
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__ ( A__ : Optional[Any] ): # picklable for multiprocessing ...
371
import qiskit def lowerCamelCase__ ( A__ : int , A__ : int ): '''simple docstring''' __lowerCamelCase = qiskit.Aer.get_backend("""aer_simulator""" ) __lowerCamelCase = qiskit.QuantumCircuit(4 , 2 ) # encode inputs in qubit...
29
0
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 _SCREAMING_SNAKE_CASE : str = datasets.utils.logging...
314
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) a__: List[Any] = logging.getLogger()...
193
0
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 _snake_case = datasets.utils.logging.get_logger(__name__) ...
352
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
300
0
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetectio...
173
"""simple docstring""" from sklearn.metrics import recall_score import datasets _UpperCAmelCase = """ Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true positives and ...
173
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torc...
371
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def lowerCamelCase__ ( a__ : Dict , a__ : Dict=None ) -> Union[str, Any]: UpperCamelCase_ = None if token is n...
261
0
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""", # ...
140
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """huggingface/time-series-transformer-tourism-monthly""": ( """https://huggingface.co/huggin...
140
1
# Lint as: python3 import itertools import os import re UpperCamelCase = re.compile(R'''([A-Z]+)([A-Z][a-z])''') UpperCamelCase = re.compile(R'''([a-z\d])([A-Z])''') UpperCamelCase = re.compile(R'''(?<!_)_(?!_)''') UpperCamelCase = re.compile(R'''(_{2,}...
125
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase = {'''configuration_mmbt''': ['''MMBTConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDepen...
125
1
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : int = 600851475143 ) -> Tuple: try: _a : Tuple =int(__snake_case ) except (TypeError, ValueError): raise TypeError("""Parameter n must be int or castable to ...
276
import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem __UpperCAmelCase = importlib.util.find_spec('s3fs') is not None if _has_safs: from .s...
29
0
import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyazr, require_zstandard @...
119
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class a_ : '''simple docstring''' UpperCAmelCase_ = None UpperCAmelCase_ = False UpperCAmelCase_ = False UpperCAmelCase_ = False UpperCAmelCase_ ...
119
1
import unittest import numpy as np from transformers import RobertaConfig, 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 tra...
110
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor _lowerCAmelCase : Tuple = logging.get_logger(__name__) class __magic_name__ ( lowerCamelCase__ ): """simple docstring""" def __init__( self :Unio...
300
0
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available ...
354
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tens...
125
0
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, ...
14
"""simple docstring""" import copy import re class snake_case__ : _snake_case : Dict = """hp""" _snake_case : List[str] = {} _snake_case : int = None @classmethod def a__ ( cls , lowerCamelCase , lowerCamelCase ): __a = prefix ...
261
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless...
355
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __magic_name__ ( pl.LightningModule ): def __init__( self , __snake_case ) -> List[Any]: ...
308
0
'''simple docstring''' import math def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : float, SCREAMING_SNAKE_CASE__ : float ) -> float: if initial_intensity < 0: raise ValueError('''The value of intensity cannot be negative''' ) # handlin...
125
'''simple docstring''' import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, rand...
125
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "google/fnet-large": "https://huggingface.co/google/fnet-large/resolve/mai...
357
def lowerCAmelCase_ ( snake_case_ = 1000 ): _A : List[Any] = 3 _A : Tuple = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a a += 1 ...
343
0
from math import log from scipy.constants import Boltzmann, physical_constants __UpperCAmelCase = 300 # TEMPERATURE (unit = K) def UpperCamelCase ( snake_case__ : float , snake_case__ : float , snake_case__ : float , ) -> float: ...
119
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu __UpperCAmelCase = get_tests_...
119
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A__ : List[Any] ={'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig...
220
'''simple docstring''' def UpperCamelCase__ ( lowerCAmelCase , lowerCAmelCase ): """simple docstring""" if len(lowerCAmelCase ) != len(lowerCAmelCase ): raise ValueError("""String lengths must match!""" ) _lowerCAmelCase...
220
1
"""simple docstring""" import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class __lowerCAmelCase ( unittest.TestCase ): '''simple docstring''' def __UpperCAmelCase ( self ...
45
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case_ : Union[str, Any] = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "M...
125
0
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(_a ) , "Tatoeba directory does not...
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''' import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weight...
85
def snake_case( __magic_name__ = 50 ) -> int: '''simple docstring''' lowercase : Union[str, Any] = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in rang...
308
0
"""simple docstring""" import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class a ( unittest.TestCase ): def UpperCamelCase__ ( self ): """simple docstring""" debug_laun...
309
"""simple docstring""" __UpperCamelCase : Dict = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} __UpperCamelCase : str = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : dict[int, list[int]] , _UpperCAmelCase : ...
309
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_av...
7
def lowercase( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ) -> bool: '''simple docstring''' return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(UpperCamelCase_ ) ) def lowercase( UpperCamelCase_ ,...
343
0
"""simple docstring""" class snake_case : def __init__( self : Optional[int] ): '''simple docstring''' a : dict[str, TrieNode] = {} # Mapping from char to TrieNode a : str = False def lowerCamelCase__ ( ...
186
"""simple docstring""" import argparse import os import re import packaging.version _UpperCamelCase : Optional[Any] = 'examples/' _UpperCamelCase : Any = { 'examples': (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'i...
186
1
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class a ( a_ ): UpperCAmelCase_ : List[Any] =["image_processor", "tokenizer"] UpperCAmelCase_ : str ="AutoImageProcessor" UpperCAme...
220
"""simple docstring""" # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class a ( a_ ): def __init__( self , _lowerCamelCase , _lowerCamelCase ): super()...
220
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor,...
358
'''simple docstring''' from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 _lowerCamelCase : Any = { # 1536-bit 5: { ...
337
0
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( lowerCAmelCase_ :List[str] , lowerCAmelCase_ :Union[str, Any] , lowerCAmelC...
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 argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def lowerCAmelCase_ ( __a ) -> Optional[int]: """simple docstring""" lowerCamelCase__: Union[str, Any] =[ "decoder.version", ...
273
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/distilbert-base-uncased...
273
1
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 : int = version.parse(version.parse...
300
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers import AutoTokenizer, TFAutoModelForS...
308
0
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 YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_verbosity_info() _snake_case ...
350
from __future__ import annotations from functools import lru_cache from math import ceil _snake_case : Tuple = 100 _snake_case : int = set(range(3, NUM_PRIMES, 2)) primes.add(2) _snake_case : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: cont...
134
0