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
def A_ ( A__ , A__ , A__ ) -> int: def update_area_of_max_square(A__ , A__ ) -> int: # BASE CASE if row >= rows or col >= cols: return 0 a__ : Optional[int] = update_area_of_max_square(A__ , col + 1 ...
99
def A_ ( A__ ) -> int: stooge(A__ , 0 , len(A__ ) - 1 ) return arr def A_ ( A__ , A__ , A__ ) -> List[Any]: if i >= h: return # If first element is smaller than the last then swap them if arr[i] > arr[h]: ...
99
1
"""simple docstring""" import unittest from transformers import MraConfig, 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, floats_tensor, ids_tensor, random...
296
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING A_ = logging.get_logger(__name__)...
296
1
'''simple docstring''' from queue import PriorityQueue from typing import Any import numpy as np def __snake_case ( UpperCAmelCase_ : dict , UpperCAmelCase_ : str , UpperCAmelCase_ : set , UpperCAmelCase_ : set , UpperC...
55
'''simple docstring''' from __future__ import annotations def __snake_case ( UpperCAmelCase_ : int ): lowerCamelCase_ = 2 lowerCamelCase_ = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(UpperCAmelCase_ ) if n > 1: fac...
55
1
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor lowerCamelCase__ = logging.get_logger(__name__) class A__ ( __magic_name__ ): def __init__( self : Any , *a : Any , **a : List...
307
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class A__ ( __magic_name__ ): lowercase ...
307
1
"""simple docstring""" from argparse import ArgumentParser from . import BaseTransformersCLICommand def snake_case ( A__ ): return DownloadCommand(args.model ,args.cache_dir ,args.force ,args.trust_remote_code ) class UpperCamelCase_ (UpperCamelCase__ ): @stati...
268
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 UpperCAmelCase : in...
95
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : str = { "configuration_xlm_roberta_xl": [ "XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMRobertaXLConfig", "XLMRo...
354
from __future__ import annotations A : Dict = "#" class lowerCamelCase : """simple docstring""" def __init__( self : Dict ) -> None: SCREAMING_SNAKE_CASE_ = {} def __A ( self : List[Any] , __magic_...
305
0
from scipy.stats import spearmanr import datasets __lowercase = ''' The Spearman rank-order correlation coefficient is a measure of the relationship between two datasets. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Positive correlations imply that...
43
'''simple docstring''' import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets SCREAMING_SNAKE_CASE_: Optional[Any] ='\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burns\n ...
1
0
from __future__ import annotations def lowercase_ ( A__ = 4 ) -> list[list[int]]: """simple docstring""" snake_case = abs(A__ ) or 4 return [[1 + x + y * row_size for x in range(A__ )] for y in range(A__ )] def lowercase_ ( A__ )...
137
from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { "google/realm-cc-news-pretrained-embedder": ( "https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/config.json" ), "google/realm-c...
137
1
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration lowercase : Union[str, Any] = 5_0_0_0_0_0 lowercase : Optional[Any] = os.path.split(__file__) lowercase : List[Any] = ...
99
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() snake_case__ : Dict = logging.get_logger(__name__) snake_case__ : Optional[Any] ...
117
0
'''simple docstring''' from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record __lowerCAmelCase = '''\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Syst...
361
'''simple docstring''' from math import sqrt def __lowerCamelCase ( lowerCAmelCase_ ) -> int: _a : Dict = 0 for i in range(1 , int(sqrt(lowerCAmelCase_ ) + 1 ) ): if n % i == 0 and i != sqrt(lowerCAmelCase_ ): total += i + n // i elif i == sqr...
107
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _A : Optional[int] = logging.get_logger(__name__) _A : int = { ...
229
'''simple docstring''' import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _A : Optional[int] = logging.get_logger(__name__) class _lowercase ( UpperCAmelCase__ ): '''simple docstring''' ...
229
1
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, BertT...
366
import warnings 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 : List[str] = logging.get_logger(__name__) A : List[Any] = ...
146
0
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_pipe...
287
from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize("""repo_id""" , ["""canonical_dataset_name""", """org-name/dataset-name"""] ) @pytest.mark.parametrize("""path""" , ["""filename.csv""", """filename with blanks.csv...
147
0
import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor...
257
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def A__ ( __lowerCamelCase, __lowerCamelCase, __lowerCamelCase, __lowerCamelCase )...
257
1
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> bool: UpperCAmelCase__ : Optional[int] = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def a__ ( lowerCAmelCase__ = 50_00 ) -> int: UpperCAmelCase__ : Tuple ...
181
'''simple docstring''' import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets UpperCamelCase__ = datasets.logging.get_logger(__name__) UpperCamelCase__ = '''\ @In...
181
1
"""simple docstring""" import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorState fr...
271
"""simple docstring""" def _snake_case ( _snake_case : str ) -> str: '''simple docstring''' _A = '' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups d...
271
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = { '''configuration_bigbird_pegasus''': [ '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BigBirdPegasusConfig''', ...
89
"""simple docstring""" # Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar _UpperCamelCase : Optional[Any] = TypeVar('T') class a ( Generic[T] )...
220
0
import copy import re class __a : __lowercase : Optional[Any] = 'hp' __lowercase : Tuple = {} __lowercase : Optional[Any] = None @classmethod def SCREAMING_SNAKE_CASE__ ( cls , lowerCAmelCase__ , ...
367
import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class __a ( tf.keras.layers.Layer ): def __init__( self , ...
288
0
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( lowercase ,lowercase ,lowercase ,lowercase ): # noqa: E741 """simple docstring""" while r - l > 1: _UpperCAmelCase = (l + r) // 2 if v[m] >= key: _UpperCAmelCase ...
289
"""simple docstring""" from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ...
289
1
"""simple docstring""" import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils i...
364
"""simple docstring""" import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py __A : Union[str, Any] = "src/transformers" # This is ...
326
0
from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCAmelCase_ = {'''tokenization_bertweet''': ['''BertweetTokenizer''']} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys lowerCAmelCase_ = _LazyModule(__name__, globals()['''__file__''...
279
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAvailable() excep...
279
1
"""simple docstring""" import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transforme...
233
"""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 __SCREAMING_SNAKE_CASE : Dict = logging.get_logger(__name__) __...
233
1
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __lowerCAmelCase ( ...
90
def a ( lowerCamelCase_ ): '''simple docstring''' lowercase__ = [1] lowercase__ , lowercase__ , lowercase__ = 0, 0, 0 lowercase__ = ugly_nums[ia] * 2 lowercase__ = ugly_nums[ia] * 3 lowercase__ = ugly_nums[ia] * 5 for _ in range(1...
207
0
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node UpperCamelCase_ = 4 UpperCamelCase_ = 3 class a_ ( _snake_case ): pass...
364
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 UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "facebook/lev...
344
0
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py _lowercase: int = "src/di...
227
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def a( A : dict ) -> tuple: """simple doc...
227
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : List[str] = logging.get_logger(__name__) UpperCAmelCase__ : str = { 'microsoft/wavlm-base': 'https://huggingface.co/microsoft/wavlm-base/resol...
301
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase__ : Union[str, Any] = { 'configuration_roc_bert': ['ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoCBertConfig'], 'tokenization_roc_ber...
301
1
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ...
71
from torch import nn class __A ( nn.Module ): """simple docstring""" def __init__( self , lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" super().__init__() __UpperCamelCase : ...
71
1
'''simple docstring''' from functools import lru_cache def __a ( UpperCAmelCase ) ->set: """simple docstring""" A = 2 A = set() while i * i <= n: if n % i: i += 1 else: n //= i factors.add(UpperCAmelCase ) if n > 1: factors.add(Uppe...
360
'''simple docstring''' from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import f...
337
0
"""simple docstring""" import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def __a ( __lowerCamelCase ): return (data["dat...
61
'''simple docstring''' import re from filelock import FileLock try: import nltk UpperCamelCase__ = True except (ImportError, ModuleNotFoundError): UpperCamelCase__ = False if NLTK_AVAILABLE: with FileLock('''.lock''') as lock: nltk.download('''punkt''', qu...
181
0
from math import factorial def a__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): """simple docstring""" if n < k or k < 0: raise ValueError("Please enter positive integers for n and k where n >= k" ) return factorial(_SCREAMING_SNAKE_CASE ) // (factorial(_SCREAMING_...
363
"""simple docstring""" from __future__ import annotations from random import choice def a__ ( _SCREAMING_SNAKE_CASE ): """simple docstring""" return choice(_SCREAMING_SNAKE_CASE ) def a__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): """simple docstring...
244
0
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class ...
287
def lowerCamelCase__ ( a , a ) -> str: if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) _A: Union[str, Any] = str(bin(a ) )[2:] # remove the leading "0b" _A: Union[str, Any] = str(bin(a ) )[2:...
121
0
'''simple docstring''' def lowercase__( __UpperCamelCase: int ): """simple docstring""" if divisor % 5 == 0 or divisor % 2 == 0: return 0 SCREAMING_SNAKE_CASE : str = 1 SCREAMING_SNAKE_CASE : Optional[int] = 1 while repu...
363
'''simple docstring''' 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 j...
246
0
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def __snake_case ( UpperCAmelCase_ : Iterable[str] , UpperCAmelCase_ : int ): lowerCamelCase_ = iter(UpperCAmelCase_ ) while True: lowerCamelCase...
55
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda ...
259
0
"""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 ...
351
"""simple docstring""" from math import pi def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase ) -> float: return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 10))
312
0
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class...
215
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class a ( unittest.TestCase ): """simple docstring""" lowerCamelCase :Tuple = JukeboxTokenizer lowerCamelCase :str = { '''artist...
180
0
"""simple docstring""" import requests _a = """YOUR API KEY""" def __a ( __lowerCamelCase, __lowerCamelCase = giphy_api_key ): UpperCAmelCase_ : Optional[Any] = '+'.join(query.split() ) UpperCAmelCase_ : Any = f"""https://api.giphy.com/v1/gifs/search?q={fo...
352
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _a = {'configuration_unispeech': ['UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP', 'UniSpeechConfig']} try...
23
0
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_c...
197
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : List[str] =logging.get_logger(__name__) __lowerCAmelCase : str ={ """facebook/dpr-ctx_encoder-single-nq-base""": ( """https:/...
197
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __SCREAMING_SNAKE_CASE : Optional[Any] = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMO...
73
"""simple docstring""" import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is...
73
1
'''simple docstring''' from __future__ import annotations from cmath import sqrt def lowerCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ ): '''simple docstring''' if a == 0: raise ValueError('''Coefficient \'a\' must not be zero....
3
'''simple docstring''' from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def UpperCAmelCase ( a_ ) -> Dict[str, torch.Tensor]: """simple docstring""" ...
344
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase_ = {'''configuration_ibert''': ['''IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''IBertConfig''', '''IBertOnnxConfig''']} try: if not is_torch_available(): raise Op...
34
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning thing...
34
1
"""simple docstring""" import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_ava...
84
'''simple docstring''' from scipy.stats import spearmanr import datasets __lowerCAmelCase = '\nThe Spearman rank-order correlation coefficient is a measure of the\nrelationship between two datasets. Like other correlation coefficients,\nthis one varies between -1 and +1 with 0 implying no correlati...
341
0
from sklearn.metrics import mean_squared_error import datasets lowerCAmelCase_ = '\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n and Thirion, B. and Grisel, O. and Blondel, M. an...
116
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_MA...
116
1
import numpy as np import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel from ...utils import logging lowercase_ = logging.get_logger(__name__) class A ( _UpperCAmelCase ): """simple docstring"""...
7
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils imp...
50
0
import qiskit def __UpperCamelCase ( _A = 2 ): lowerCAmelCase_ = qubits # Using Aer's simulator lowerCAmelCase_ = qiskit.Aer.get_backend('''aer_simulator''' ) # Creating a Quantum Circuit acting on the q register lowerCAmelCase_ = qiskit.Q...
356
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_image...
167
0
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class __magic_name__ ( lowerCamel...
188
import os import string import sys lowerCamelCase = 1 << 8 lowerCamelCase = { '''tab''': ord('''\t'''), '''newline''': ord('''\r'''), '''esc''': 27, '''up''': 65 + ARROW_KEY_FLAG, '''down''': 66 + ARROW_KEY_FLAG, '''right''': 67 + ARROW_KEY_FLAG, '''left''': ...
188
1
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def lowerCamelCase_ ( lowerCamelCase__ ): if "cls_token" in name: lowerCamelCase_ = name.replace("cls_token" , "vit.embedd...
370
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__=False ): lowerCamelCase_ = OmegaConf.load(lowerCamelCase__ ) if display: print(yaml.dump(Omega...
47
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import lo...
310
from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, 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, ...
310
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 ( SegformerConfig, SegformerForImageClassif...
12
"""simple docstring""" import re def _snake_case ( lowercase__ ): _lowerCamelCase : Optional[int] = re.compile(r'^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$' ) if match := re.search(lowercase__ , lowercase__ ): return match.string == ...
12
1
"""simple docstring""" def lowercase ( lowerCAmelCase__ : str ) -> list: if n_term == "": return [] __a = [] for temp in range(int(lowerCAmelCase__ ) ): series.append(f'''1/{temp + 1}''' if series else '''1''' ) return series if __name...
45
from __future__ import annotations def __snake_case ( __UpperCamelCase : list[list[int]] ): """simple docstring""" for i in range(1 ,len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in range(1 ...
312
0
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_t...
306
def snake_case_ ( lowerCAmelCase_ : str , lowerCAmelCase_ : str ): __lowercase : Optional[Any] = len(lowerCAmelCase_ ) __lowercase : str = len(lowerCAmelCase_ ) __lowercase : Optional[int] = [[False for _ in rang...
306
1
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avai...
24
'''simple docstring''' import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE( A__ ): """simple docstring""" lowerCamelCase__ = """MCTCTFeatureExtractor""" lowerCame...
23
0
'''simple docstring''' lowerCAmelCase__ = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def _A ( ): """simple docstring""" __lowercase = input('''Enter message: ''' ) __lowercase = input('''Enter key [alphanumeric]: ''' ) __lowercase = input('''Encrypt/Dec...
52
'''simple docstring''' def _A ( A__ = 1000 ): """simple docstring""" __lowercase , __lowercase = 1, 1 __lowercase = 2 while True: __lowercase = 0 __lowercase = fa + fa __lowercase , __lowercase = fa, f index += 1 for _...
52
1
'''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 d...
27
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
342
0
"""simple docstring""" # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's e...
314
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _snake_case ( _snake_case : Dict ): # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wikipedia.org...
314
1
'''simple docstring''' def snake_case_ (_a : float , _a : float , _a : float , _a : float , _a : float , ): UpperCAmelCase = [redshift, radiation_density, matter_density, dark_energy] if any(p < 0 for p in parameters ):...
34
'''simple docstring''' from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _conc...
34
1
from __future__ import annotations class lowerCamelCase : """simple docstring""" def __init__( self : Tuple, _UpperCAmelCase : int = 0 ) -> Union[str, Any]: """simple docstring""" SCREA...
191
import qiskit def _a ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ) -> qiskit.result.counts.Counts: '''simple docstring''' SCREAMING_SNAKE_CASE__ : Union[str, Any] = qiskit.Aer.get_backend("aer_simulator" ...
191
1
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf,...
116
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge SCREAMING_SNAKE_CASE_:Any = [ """Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw a cell pho...
116
1
import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqaSeqL...
250
def _a ( lowerCamelCase: str ) -> bool: '''simple docstring''' __A = [int(lowerCamelCase ) for i in ip_va_address.split('''.''' ) if i.isdigit()] return len(lowerCamelCase ) == 4 and all(0 <= int(lowerCamelCase ) <= 2_5...
250
1
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 snake_case_ ( lowerCAmelCase_ : List[Any] ): # picklable for multiproces...
233
import math class lowerCAmelCase : '''simple docstring''' def __init__( self : Tuple , __a : int=0 ) -> Optional[Any]: # a graph with Node 0,1,...,N-1 """simple docstring""" __lowercase : Any = n __lowercase : ...
233
1
"""simple docstring""" from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake _lowerCAmelCase : int = numpy.array([0, 0]) _lowerCAmelCase : Dict = numpy.array([0.5, 0.8_660_254]) _lowerCAmelCase : str =...
340
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase : Optional[Any] = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extractio...
340
1
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
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase : int = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_vision_available()...
47
0
_UpperCAmelCase = """ABCDEFGHIJKLMNOPQRSTUVWXYZ""" def UpperCamelCase ( ): '''simple docstring''' A_ : Tuple = input('Enter message: ' ) A_ : int = input('Enter key [alphanumeric]: ' ) A_ : Optional[Any] = input('Encr...
357
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) ...
192
0
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SegformerConfig, SegformerForImageClassification, SegformerForSemanticSegmentation, Se...
12
from __future__ import annotations from PIL import Image # Define glider example UpperCAmelCase_ = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0...
12
1
"""simple docstring""" from __future__ import annotations class a : """simple docstring""" def __init__( self: Tuple , UpperCamelCase: str , UpperCamelCase: str ): """simple docstring""" A__ , A__ = ...
367
"""simple docstring""" import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin SCREAMING_SNAKE_CASE_ : Union[str...
69
0
import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() UpperCamelCase = [ '''word_embeddings_...
306
from __future__ import annotations import unittest from transformers import DebertaVaConfig, 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, rando...
306
1
"""simple docstring""" import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.num...
365
"""simple docstring""" import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() _UpperCamelCase ...
234
0
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetYaagf, RegNetYaagf, RegNetY...
52
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py __lowerCamelCase : str = """src/transformers""" # This is to m...
52
1
from __future__ import annotations def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' lowercase = 2 lowercase = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append...
97
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ :Optional[int] = logging.get_logger(__name__) lowercase__ :List[Any] = { "camembert-base": "https://huggingfac...
97
1
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning thing...
314
import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def UpperCAmelCase_ ( ): '''simple docstring''' raise RuntimeError('''CUDA out of memory.''' ) class ...
314
1
import random def UpperCamelCase_( snake_case__: int ) -> bool: UpperCAmelCase__ = num - 1 UpperCAmelCase__ = 0 while s % 2 == 0: UpperCAmelCase__ = s // 2 t += 1 for _ in range(5 ): UpperCAmelCase__ = random.randrange(2...
335
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_spe...
335
1
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMixi...
284
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _snake_case : List[Any] = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tokenization_biogpt': ['BioGptToken...
284
1
'''simple docstring''' def __UpperCamelCase ( ): lowercase__ : Any = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] lowercase__ : Any = 6 lowercase__ : Optional[Any] = 1 lowercase__ : int = 1901 lowercase__ : List[str] = 0 while year < 2001: da...
214
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase ): lowercase__ : Dict = len(UpperCAmelCase ) print('''The following activities are selected:''' ) # The first activity is always selected lowercase__ : str = 0 print(UpperCAmelCase , ...
214
1
'''simple docstring''' from __future__ import annotations def _A ( snake_case , snake_case , snake_case , snake_case ) -> int: # noqa: E741 while r - l > 1: _lowercase : Dict = (l + r) // 2 if v[m] >= key: _lowercase : List[Any] ...
250
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resi...
250
1
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def UpperCAmelCase ( ): """simple docstring""" A__ = {} A__ = 2 while True: A__ = ...
154
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_...
154
1
def __UpperCamelCase ( _A ): lowerCAmelCase_ = set() # To detect a back edge, keep track of vertices currently in the recursion stack lowerCAmelCase_ = set() return any( node not in visited and depth_first_search(_A , _A , _A , _A ) for nod...
278
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAG...
278
1
import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) def __SCREAM...
189
from typing import Any class a : def __init__( self , A_ ): '''simple docstring''' _UpperCAmelCase : List[Any] = data _UpperCAmelCase : Any = None class a : def __init__( self ): ...
189
1
"""simple docstring""" from math import factorial def a__ ( snake_case__ = 20 ) -> int: lowerCamelCase = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... lowerCamelCase = n // 2 return int(factorial(lowercase_ ...
291
def UpperCamelCase (lowercase_: int = 10 ) -> str: if not isinstance(lowercase_ , lowercase_ ) or n < 0: raise ValueError("""Invalid input""" ) A__ : List[str] = 10**n A__ : Any = 28433 * (pow(2 , 7830457 , lowercase_ ))...
192
0
'''simple docstring''' def __lowerCamelCase ( lowerCAmelCase_ ) -> Any: if len(lowerCAmelCase_ ) <= 1: return [tuple(lowerCAmelCase_ )] _a : Any = [] def generate(lowerCAmelCase_ , lowerCAmelCase_ ): if k == 1: res.append(tuple(arr[:] ) ...
355
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller __lowerCAmelCase = 3 def __lowerCamelCase ( lowerCAmelCase_ ) -> int: print('Generating primitive root of p' ) while True: _a : ...
107
0
'''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 transform...
70
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokeniz...
70
1
"""simple docstring""" 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_ten...
11
"""simple docstring""" import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def lowercase ( lowerCAmelCase__ : ...
11
1
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester from .....
68
'''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 lowerCamelCase__ = logging.get_logger(__name__) lo...
234
0
class lowercase_ : def __init__( self , __UpperCamelCase = "" , __UpperCamelCase = False ): """simple docstring""" UpperCamelCase_ = {} # A node will be a leaf if the tree contains its word UpperCamelCase_ = is_leaf ...
352
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def lowerCamelCase__ ( a__ : Dict ) -> List[Any]: UpperCamelCase_ = {} UpperCamelCase_ ...
261
0
"""simple docstring""" def a__ ( snake_case__ , snake_case__ ) -> Tuple: assert x is not None assert y is not None lowerCamelCase = len(snake_case__ ) lowerCamelCase = len(snake_case__ ) # declaring the array for storing the dp values l...
291
"""simple docstring""" import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): impor...
291
1
'''simple docstring''' import argparse import os # New Code # import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed...
37
'''simple docstring''' # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnod...
37
1
def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ) -> bool: # 1. Validate that path exists between current and next vertices if graph[path[curr_ind - 1]][next_ver] == 0: return False # 2. Validate that nex...
50
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, logging if is_sentencepie...
50
1
'''simple docstring''' import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE ...
3
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) fr...
3
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass a :List[str] = (3, 9, -11, 0, 7, 5, 1, -1) a :List[str] = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class __a : '''simple docstring''' ...
132
"""simple docstring""" import unittest from typing import Dict, List, Optional, Union 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 ImageProcessingSavingTes...
132
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase = { '''configuration_rembert''': ['''REMBERT_PRETRAI...
335
# flake8: noqa # Lint as: python3 _UpperCamelCase = [ '''VerificationMode''', '''Version''', '''disable_progress_bar''', '''enable_progress_bar''', '''is_progress_bar_enabled''', '''experimental''', ] from .info_utils import VerificationMode from .logging import disab...
335
1
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
81
from math import isclose, sqrt def a_ ( _A , _A , _A ) -> tuple[float, float, float]: """simple docstring""" snake_case__ = point_y / 4 / point_x snake_case__ = 2 * normal_gradient / (1 + normal_gradient * normal_...
307
0
import flax.linen as nn import jax import jax.numpy as jnp class lowerCAmelCase__ ( nn.Module ): __a = 42 __a = jnp.floataa def lowercase ( self : Union[str, Any] ): _snake_case = nn.Conv( self.out_ch...
361
"""simple docstring""" import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": UpperCAmelCase__ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned' ...
40
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Tuple =logging.get_logger(__name__) _UpperCAmelCase : str ={ """microsoft/git-base""": """https://huggingface.co/microsoft/git-base/resolve/main/config...
262
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig _UpperCAmelCase : Dict ={ """susnato/ernie-m-base_pytorch""": """https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json""", """susnato/ernie-m-large_pytorch""": """https...
262
1
import string def a__ ( lowerCAmelCase__ ) -> str: UpperCAmelCase__ : Any = '''''' for i in sequence: UpperCAmelCase__ : List[Any] = ord(lowerCAmelCase__ ) if 65 <= extract <= 90: output += chr(1_55 - ex...
352
'''simple docstring''' class lowerCamelCase_ : def __init__( self : Union[str, Any] , _A : int ): '''simple docstring''' UpperCAmelCase__ : str = n UpperCAmelCase__ : Union[str, Any] ...
299
0
import math def UpperCAmelCase_( a__ , a__ = 0 , a__ = 0 ): """simple docstring""" SCREAMING_SNAKE_CASE : Optional[int] = end or len(a__ ) for i in range(a__ , a__ ): SCREAMING_SNAKE_CASE : int = i ...
313
from abc import ABC, abstractmethod from typing import List, Optional class a_ ( a__ ): """simple docstring""" def __init__( self ) ->List[str]: # test for the above condition self.test() def __lowerCAmelCase ( self ...
313
1
"""simple docstring""" def _lowerCamelCase(__UpperCamelCase ) -> str: if not all(char in """01""" for char in bin_string ): raise ValueError("""Non-binary value was passed to the function""" ) if not bin_string: raise ValueError("""Empty string was passed to the function""" ) _lowerCAmelCase ...
341
"""simple docstring""" import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common...
341
1
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(): import ...
11
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available lowerCAmelCase__ = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvai...
11
1
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset SCREAMING_SNAKE_CASE_:str = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), 6: (3, 2),...
353
from random import randint, random def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase = False , _lowerCAmelCase = False , _lowerCAmelCase = 5 , ) -> list: """simple docstring""" A : Any = ...
115
0
"""simple docstring""" __SCREAMING_SNAKE_CASE ={} def lowercase__( __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int ): # if we are absent twice, or late 3 consecutive days, # no further prize strin...
213
"""simple docstring""" from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class UpperCamelCase ( yaml.SafeLoader ): def _UpperCAmelCase ( self ,__UpperCamelCase ) -> Optional[int]: '''simple docstring''' ...
213
1
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ....
220
'''simple docstring''' 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.skipUnles...
220
1
'''simple docstring''' import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import To...
37
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" lowerCAmelCase__ , lowerCAmelCase__ : List[str] = an...
37
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def lowerCamelCase__ ( _lowercase ): '''simple docstrin...
235
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaProcessor, BlipImagePro...
235
1