code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup SCREAMING_SNAKE_CASE_ = 'https://www.indeed.co.in/jobs?q=mobile+app+development&l=' def __snake_case ( _lowercase = "mumbai" ): ""...
34
import re def _lowerCamelCase ( snake_case ): if len(re.findall('[ATCG]' , snake_case ) ) != len(snake_case ): raise ValueError('Invalid Strand' ) return dna.translate(dna.maketrans('ATCG' , 'TAGC' ) ) if __name__ == "__main__": import doctest doctest.test...
192
0
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def lowercase_ ( SCREAMING_SNAKE_CASE : Sequence[float] , SCREAMING_SNAKE_CASE : int , SCREAMING_SNAKE_CASE : int ): """simple docstring""" ...
711
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets lowerCamelCase__ = '''\ @inproceedings{wang2019glue, title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding}, author={Wang, Alex and S...
408
0
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 _lowerCAmelCase = logging.get_logger(__name__) class UpperCAmelCase__ ( snake_case__ ): snake_case...
137
def lowercase ( ) -> int: return [ a * b * (1000 - a - b) for a in range(1 ,999 ) for b in range(_a ,999 ) if (a * a + b * b == (1000 - a - b) ** 2) ][0] if __name__ == "__main__": print(F"""{solution() = }""")
137
1
'''simple docstring''' from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import data...
704
'''simple docstring''' import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline lowerCAmelCase_ : int = { 'n_samples': 64, 'horizon': 32, 'num_inference_steps': 20, 'n_guide_steps': 2, # can set to 0 for faster ...
464
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless...
63
'''simple docstring''' from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : str = logging.get_logger(__name__) lowerCAmelCase_ : Optional[int] = { """snap-research/efficientformer-l1-300""": ( ...
435
0
'''simple docstring''' 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 UpperCAmelCase_ : Dict = logging.getLogger(__name__) if i...
715
'''simple docstring''' import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPIN...
11
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : str = logging.get_logger(__name__) UpperCAmelCase_ : List[Any] = { '''SCUT-DLVCLab/lilt-roberta-en-base''': ( '''https...
255
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : Any = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_e...
255
1
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def lowerCAmelCase__ ( a__ , a__=7 ) ->int: '''simple docstring''' _UpperCamelCase = None if token is not None: _UpperCamelCase = {"Accept...
712
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowerCAmelCase__ ( a__ ) ->str: '''simple docstring''' return getitem, k def lowerCAmelCase__ ( a__ , a__ ) ->Tuple: '''simple docstring''' ...
82
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "facebook/vit-mae-base": "https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json", # See all ViT MAE models at https...
346
"""simple docstring""" from timeit import timeit def a__ ( __SCREAMING_SNAKE_CASE ) -> int: if number < 0: raise ValueError("the value of input must not be negative" ) __lowerCAmelCase: str = 0 while number: number &= number - 1 ...
346
1
import string def __lowerCAmelCase ( snake_case : str ) -> None: for key in range(len(string.ascii_uppercase ) ): __lowerCamelCase: Dict = """""" for symbol in message: if symbol in string.ascii_uppercase: __lowerCamelCase: Optional[Any] ...
189
_A : Tuple = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def __lowerCAmelCase ( ) -> None: __lowerCamelCase: Optional[int] = input("""Enter message: """ ) __lowerCamelCase: Dict = input("""Enter key [alphanumeric]: """ ) __lowerCamelCase: List[Any] =...
189
1
"""simple docstring""" from math import pi, sqrt, tan def __UpperCAmelCase ( __UpperCamelCase ): if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def __UpperCAmelCase ...
76
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration _SCREAMING_SNAKE_CASE = HfArgumentParser(InitializationArguments) _SCREAMING_SNAKE_CASE = parser.parse_args() # Load codeparrot tokenize...
401
0
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor __snake_case :Union[str, Any] =logging.get_logger(__name__) class lowerCAmelCase__ ( _lowerCamelCase ): def __init__( self : str , *__UpperCamelCase : Union[str,...
224
from __future__ import annotations class lowerCAmelCase__ : def __init__( self : Dict , __UpperCamelCase : list[list[int]] ) -> List[Any]: A = TypeError( 'Matrices must be formed from a list of zero or more lists containing at ' ...
224
1
"""simple docstring""" _A = [0, 2, 4, 6, 8] _A = [1, 3, 5, 7, 9] def SCREAMING_SNAKE_CASE ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ) -> int: if remaining_length == 0: if digits[0] == 0 or d...
159
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _A = {'configuration_fnet': ['FNET_PRETRAINED_CONFIG_ARCHIVE_MA...
159
1
'''simple docstring''' import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import...
700
import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, requi...
613
0
def __snake_case ( __UpperCamelCase : list[list[int]] ,__UpperCamelCase : int ,__UpperCamelCase : int ,__UpperCamelCase : set ): """simple docstring""" A_ , A_ = len(__UpperCamelCase ), len(grid[0] ) if ( min(__UpperCamelCase ,__...
86
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class _a ( unittest.TestCase ): """simple docstring""" def __A ( self : ...
86
1
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_c...
12
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging a :Optional[Any] = logging.get_logger(__name__) a :Union[str, Any] = { "t5-small": "https://huggingface.co/t5-small/r...
12
1
"""simple docstring""" from collections import defaultdict def _lowerCAmelCase ( lowerCamelCase__ : int ) -> int: _SCREAMING_SNAKE_CASE : Optional[int] = 1 _SCREAMING_SNAKE_CASE : List[Any] = True for v in tree[start]: if v not in visited: ...
572
"""simple docstring""" def _lowerCAmelCase ( ) -> int: return [ a * b * (1_0_0_0 - a - b) for a in range(1, 9_9_9 ) for b in range(lowerCamelCase__, 9_9_9 ) if (a * a + b * b == (1_0_0_0 - a - b) ** 2) ][0] if __name__ == "__main__": print(F'{solu...
572
1
'''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, BatchEncoding, PreTrainedTokenizer from ...utils import logging snake_case__ : Tuple = logging.get_logger(__name...
389
'''simple docstring''' import qiskit def _lowerCamelCase ( lowerCamelCase_ : int = 2 ): """simple docstring""" UpperCAmelCase_ : List[Any] = qubits # Using Aer's simulator UpperCAmelCase_ : str = qiskit.Aer.get_backend('aer_simu...
389
1
"""simple docstring""" import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class lowerCAmelCase ( lowerCamelCase_ , unittest.TestCase ): ...
247
"""simple docstring""" from __future__ import annotations __UpperCamelCase = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] __UpperCamelCase = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def lowercase (SCREAMING_SNAKE_CASE_ : list[float] ) ...
247
1
"""simple docstring""" def __lowerCamelCase ( lowerCAmelCase__ ): A__ = int(lowercase_ ) if n_element < 1: A__ = ValueError('a should be a positive number' ) raise my_error A__ = [1] A__ = (0, 0,...
720
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def __lowerCamelCase ( lowerCAmelCase__ ,lowerCAmelCase__ = "cpu" ,lowerCAmelCase__ = None ): A__ = torch.load(lowerCAmelCase__ ,map_locat...
554
0
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup lowerCAmelCase_ = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def lowerCamelCase_ ( _UpperCamelCase = "mumbai" ) -> Generator[tuple[str...
60
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mode...
205
0
from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class UpperCamelCase: snake_case_ : str = field( metadata={"""h...
473
import os from typing import Dict, List, Tuple, TypeVar, Union A : List[Any] = TypeVar('T') A : Dict = Union[List[T], Tuple[T, ...]] A : Any = Union[T, List[T], Dict[str, T]] A : Optional[int] = Union[str, b...
473
1
"""simple docstring""" from collections.abc import Iterable from typing import Any class UpperCamelCase : def __init__( self : str , UpperCAmelCase__ : int | None = None ) -> Tuple: _a : List[str] = value _a : Node | None...
389
"""simple docstring""" from collections.abc import Sequence def lowerCAmelCase__ ( UpperCamelCase__ = None ): '''simple docstring''' if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) _a : List[Any] = num...
389
1
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class __A ( SCREAMING_SNAKE_CASE_ ): ...
663
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> bool: return sum(i for i in range(1 ,number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') _a : int ...
663
1
'''simple docstring''' import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class lowerCAmelCase_ : def __init__( s...
292
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() ...
292
1
'''simple docstring''' _a : Tuple = """Alexander Joslin""" import operator as op from .stack import Stack def snake_case__ ( UpperCAmelCase : Optional[int] ): lowerCAmelCase__ :str = {"*": op.mul, "/": op.truediv, "+": op.add, "-": op.sub} ...
716
from __future__ import annotations import math from collections.abc import Callable def snake_case__ ( UpperCAmelCase : Callable[[int | float], int | float] , UpperCAmelCase : int | float , UpperCAmelCase : int | float , UpperCAmelCase : int = 1_0_0 ...
111
0
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_...
79
'''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_availabl...
347
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase : Union[str, Any] ={ """configuration_lla...
720
"""simple docstring""" import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCAmelCase__ ( lowerCAmelCase__ :str ) -> Optional[in...
197
0
"""simple docstring""" def snake_case ( A__ ,A__ ): # Check if the input is valid if not len(A__ ) == len(A__ ) == 3: raise ValueError("Please enter a valid equation." ) if equationa[0] == equationa[1] == equationa[0] == equationa[1] == 0: raise ValueError("Both a & b of tw...
95
'''simple docstring''' import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers...
329
0
'''simple docstring''' import argparse import importlib from pathlib import Path # Test all the extensions added in the setup _lowerCAmelCase = [ '''kernels/rwkv/wkv_cuda.cu''', '''kernels/rwkv/wkv_op.cpp''', '''kernels/deformable_detr/ms_deform_attn.h''', '''kernels/deformable_detr/cud...
160
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase = { '''configuration_time_series_transformer''': [ '''TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimeSeries...
160
1
def _SCREAMING_SNAKE_CASE ( lowerCAmelCase__ = 1_00 ): lowerCamelCase_ : Tuple = set() lowerCamelCase_ : Tuple = 0 lowerCamelCase_ : List[str] = n + 1 # maximum limit for a in range(2 ,snake_case__ ): for b in range(2...
364
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, ...
455
0
'''simple docstring''' import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTr...
719
'''simple docstring''' from __future__ import annotations def __magic_name__( lowerCamelCase, lowerCamelCase): __lowerCAmelCase = sorted(numsa + numsa) __lowerCAmelCase , __lowerCAmelCase = divmod(len(lowerCamelCase), 2) if mod...
474
0
'''simple docstring''' from __future__ import annotations class _A : def __init__( self : Optional[int] , __magic_name__ : list[list[int]] ) -> str: """simple docstring""" __snake_case : str = TypeError( ...
26
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> str: """simple docstring""" if isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(SCREAMING_SNAKE_CASE_ , ...
628
0
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if versi...
676
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import t...
676
1
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE ( snake_case_ : Optional[Any] , snake_...
297
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() __lowerCamelCase : int = logging.get_logger(__name__) __lowerCamelCase : Tuple = { """post_extract_proj""": """fea...
297
1
from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging __magic_name__ = logging.get_logger(__name_...
721
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowercase : '''simple docstring''' __SCREAMING_SNAKE_CASE = 42 __SCREAMING_SNAKE_CAS...
391
0
'''simple docstring''' _snake_case = """Alexander Joslin""" import operator as op from .stack import Stack def _A ( snake_case ) -> Union[str, Any]: _lowercase : List[str] = {"*": op.mul, "/": op.truediv, "+": op.add, "-": op.sub} _lowercase : List[str] ...
245
from __future__ import annotations def a__ ( lowercase__ , lowercase__ ): '''simple docstring''' if b == 0: return (1, 0) ((UpperCAmelCase_) , (UpperCAmelCase_)) =extended_euclid(lowercase__ , a % b ) UpperCAmelC...
54
0
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class a_ : """simple docstring""" __SCREAMING_SNAKE_CASE : List[str]...
714
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a__ : Tuple = { '''configuration_roberta''': ['''ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP...
333
0
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging UpperCAmelCase_ ...
24
'''simple docstring''' import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def _lowerCAmelCase ( lowercase :...
161
0
'''simple docstring''' import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_m...
721
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( A : int ) -> int: """simple docstring""" __snake_case : str = 1 for i in range(1 , num + 1 ): fact *= i return fact def _SCREAMING_SNAKE_CASE ( ...
61
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta i...
209
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCamelCase_ = { '''configuration_blip''': [ '''BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP'''...
209
1
def __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_): '''simple docstring''' lowerCamelCase_ : int = len(lowerCAmelCase_) lowerCamelCase_ : List[str] = [] for i in range(len(lowerCAmelCase_) - pat_len + 1): lowerCamelCase_ : ...
714
def __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_): '''simple docstring''' if digit_amount > 0: return round(number - int(lowerCAmelCase_) , lowerCAmelCase_) return number - int(lowerCAmelCase_) if __name__ == "__main__": print(decimal_isolate(1.53, 0)) ...
73
0
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar __snake_case :Union[str, Any] =TypeVar('T') def lowerCamelCase_ ( lowerCAmelCase__ : int ) -> int: '''simple docstring''' return (position - 1) // 2 def...
106
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Optional[Any] =logging.get_logger(__name__) __snake_case :Tuple ={ 'transfo-xl-wt103': 'https://huggingface.co/transfo-xl-wt103/resolve/main/config.json', } class lowerCAmelCase_...
106
1
'''simple docstring''' import os import jsonlines import numpy as np from tqdm import tqdm a__ = 2_048 a__ = 4_096 a__ = 42 a__ = os.environ.pop('''PROCESS_TRAIN''', '''false''') a__ = {'''null''': 0, '''short''': 1, '''long''': 2, '''yes''': 3, '''no...
700
'''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_vision_avai...
566
0
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class _snake_case ( A__ ): def __init__( self , a , a , a) -> Dict: SCREAMING_SNAKE_CASE = dataset SCREAMING_SNAK...
73
import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): import jax...
488
0
'''simple docstring''' from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import t...
713
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCamelCase : Optional[int] = { """configuration_longt5""": ["""LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LongT5Config""", """Lo...
610
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE__ : Any = { """configuration_mobilenet_v2""": [ """MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """...
79
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import j...
79
1
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import HuggingFace...
714
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", } class __lowerCAmelCase ( lowerCAmelCase__ ): ...
622
0
import colorsys from PIL import Image # type: ignore def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): lowercase = x lowercase = y for step in range(__SCREAMING_SNAKE_CASE ): # noqa: B007 lowercase = ...
84
'''simple docstring''' def _A ( ): '''simple docstring''' A__ = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] A__ = 6 A__ = 1 A__ = 1901 A__ = 0 while year < 2001: day += 7 if (year % 4 == 0 and...
531
0
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_availa...
83
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class a ( __lowerCAmelCase ): """simple docstring""" def UpperCAmelCase ( self ) -> List[str]: return [ ...
83
1
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def _SCREAMING_SNAKE_CASE ( __snake_case ) -> str: _UpperCAmelCase = {} _UpperCAmelCase ...
108
"""simple docstring""" lowercase__ = """ # Transformers 설치 방법 ! pip install transformers datasets # 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요. # ! pip install git+https://github.com/huggingface/transformers.git """ lowercase__ = [{"""type""": """code""", """content""": INSTALL_CONTENT}...
610
0
'''simple docstring''' from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_availa...
624
'''simple docstring''' import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) lower...
624
1
class _A ( __lowercase ): pass class _A ( __lowercase ): pass class _A : def __init__( self ): _UpperCAmelCase = [ [], [], [], ] def UpperCAmelCase ...
518
a = 8.314_462 # Unit - J mol-1 K-1 def _SCREAMING_SNAKE_CASE ( snake_case , snake_case , snake_case ) -> float: if moles < 0 or kelvin < 0 or volume < 0: raise ValueError("""Invalid inputs. Enter positive value.""" ) ret...
518
1
'''simple docstring''' import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class __A...
318
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __A ( a ): """simple docstring""" A_ = '' A_ ...
318
1
"""simple docstring""" 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_subproce...
621
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'huggingface/time-series-transformer-tourism-monthly': ( 'htt...
621
1
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": lowerCAmelCase__ = pd.read_csv("""sample_data.csv""", header=None) lowerCAmelCase__ ...
648
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTes...
648
1
from ... import PretrainedConfig lowerCAmelCase_ = { '''sijunhe/nezha-cn-base''': '''https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json''', } class snake_case_ ( __A ): '''simple docstring''' SCREAMING_SNAKE_CASE : int ...
39
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { '''Intel/dpt-large''': '''https://huggingface.co/Intel/dpt-large/resolve/main/config...
39
1
'''simple docstring''' import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def lowerCamelCase__ ( ) -> Any: raise RuntimeError('''...
717
import collections import inspect import unittest from transformers import SwinvaConfig 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_configuration_common...
388
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _lowerCAmelCase ...
93
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version __A = { """<""": operator.lt, """<=""": operator.le, """==""": operator.eq, """!=""": operator.ne, """>=""": operator.ge, "...
93
1
'''simple docstring''' def __lowerCamelCase ( A__ , A__ ) -> bool: """simple docstring""" UpperCamelCase = len(_lowerCAmelCase ) UpperCamelCase = len(_lowerCAmelCase ) UpperCamelCase = [[False for _ in range(m + 1 ...
716
'''simple docstring''' import argparse import json from tqdm import tqdm def __lowerCamelCase ( ) -> List[str]: """simple docstring""" UpperCamelCase = argparse.ArgumentParser() # Required parameters parser.add_argument( ...
324
0
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): A_ : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack A_ : set[int] = set() return any( node not in visited and depth_first_search(SCREAMING_SNAKE_CASE , ...
590
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class _lowerCamelCase ( UpperCamelCase , UpperCamelCase ): """simple docstring""" @re...
590
1
"""simple docstring""" # Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def lowercase_ ( _lowerCamelCase: Any ) -> Optional[Any]: '''simple docstring'''...
366
"""simple docstring""" import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class _snake_case : snake_case__ = None snake_case__ = False snake_case__ = False snake_case__ = False snake_c...
366
1
from __future__ import annotations UpperCamelCase = list[list[int]] # assigning initial values to the grid UpperCamelCase = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], ...
66
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 deduplicate_dataset from transformers import AutoTok...
686
0
from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusionScheduler from ...utils ...
373
import sys from collections import defaultdict class lowerCAmelCase_ : def __init__( self : Optional[int] ) ->Any: """simple docstring""" a__ :Optional[Any] = [] def _snake_case ( self : Optional[Any] , __A : ...
373
1
from __future__ import annotations def __lowerCamelCase ( lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" lowercase__ : list[list[int]] = [] create_all_state(1 , lowerCamelCase__ , lowerCamelCase__ , [] , lowerCamelCase__ ) return result de...
496
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def __lowerCamelCase ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" if not arr: return None, N...
496
1
"""simple docstring""" import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH...
721
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
497
0
class _UpperCamelCase : '''simple docstring''' def __init__( self : Optional[Any] , _lowerCamelCase : Union[str, Any] ): '''simple docstring''' __lowerCamelCase : Union[str, Any] = size __lowerCamelCase : ...
519
import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor lowerCamelCase_ = logging.get_logger(__name__) class __A( __lowerCamelCase ): """simple docstring""" def __init__(self , *SCREAMING_SNAKE_CASE_ , **SCREAMING_SNAKE_...
513
0
"""simple docstring""" from __future__ import annotations from collections import deque class snake_case : def __init__(self , SCREAMING_SNAKE_CASE_ ): """simple docstring""" SCREAMING_SNAKE_CASE_ = [] self.adlist.append( {'''v...
717
"""simple docstring""" import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .tr...
628
0
from __future__ import annotations from collections.abc import Callable def __UpperCAmelCase( lowercase_ , lowercase_ , lowercase_ , lowercase_ = 1_00 , ): _lowerCamelCase : int = x_start _lowerCamelCase : List[str] = fnc(lowercase_ ) _low...
114
"""simple docstring""" 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 _UpperCAmelCase = logging.get_logger(__name__)...
409
0
lowercase__ ='\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' lowercase__ =[{'type': 'code', 'c...
702
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase__ ={ 'configuration_ctrl': ['CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CTRLConfig'], 'tokenization_ctrl': ['CTRLTokenizer'], } try: if not is_torch_ava...
326
0
'''simple docstring''' def lowerCAmelCase (__A): """simple docstring""" assert column_title.isupper() _a = 0 _a = len(__A) - 1 _a = 0 while index >= 0: _a = (ord(column_title[index]) - 64) * pow(26 , _...
11
from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand a__ = logging.get_logger(__name__) # pylint: disable=invalid-name def lowercase ( SCREA...
477
0
'''simple docstring''' import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_...
719
'''simple docstring''' import torch def snake_case ( ) -> List[str]: """simple docstring""" if torch.cuda.is_available(): lowerCAmelCase = torch.cuda.device_count() else: lowerCAmelCase = 0 print(F'Successfully ran on {num_gpus} GPUs' ) if __...
514
0
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class a__ ( A__ ): A = 'char' A ...
216
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def _snake_case ( lowerCAmelCase : str , lowerCAmelCase : complex , lowerCAmelCase : str = "x" , lowerCAmelCase : float = 1_0**-1_0 , lowerCAmelCase : int = 1 , ): """simple do...
216
1
"""simple docstring""" import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets SCREAMING_SNAKE_CASE__:str = """\ @article{hendrycksmath2021, title={Measuring Mathematical Problem Solving With the MATH Dataset}, author={Dan Hendrycks and Collin Burns and Saurav Kadav...
67
"""simple docstring""" 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 if TYPE_CHECKING: from transformers....
67
1
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a__ = logging.get_logger(__name__) a__ = { """vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", } a__ = { "...
654
import re def __UpperCamelCase ( _lowerCAmelCase ) -> str: """simple docstring""" if len(re.findall("""[ATCG]""" , _lowerCAmelCase ) ) != len(_lowerCAmelCase ): raise ValueError("""Invalid Strand""" ) return dna.translate(dna.maketrans(""...
662
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { 'caidas/swin2sr-classicalsr-x2-64': ( 'https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config....
369
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 ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, Vilt...
369
1
'''simple docstring''' def lowerCAmelCase_ ( __A : int ): '''simple docstring''' assert ( isinstance(__A , __A ) and number_of_steps > 0 ), f"""number_of_steps needs to be positive integer, your input {number_of_steps}""" if number_of_steps == 1: retur...
329
'''simple docstring''' from collections.abc import Callable import numpy as np def lowerCAmelCase_ ( __A : Callable , __A : float , __A : float , __A : float , __A : float ): '''simple docstring''' snake_case: ...
329
1
def _UpperCamelCase ( lowercase__ , lowercase__ , lowercase__ , lowercase__ ): global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: __SCREAMING_SNAKE_CASE : int = mf_knapsack(i - 1 , lowercase__ , lowercase__ ,...
260
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as compute...
260
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ : Union[str, Any] = { '''configuration_pegasus_x''': ['''PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusXConfig'''], } try: ...
588
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowerCAmelCase__ : '''simple docstring''' lowerCAmelCase_ = 42 lowerCAmelCase_ = 42 class ...
544
0
def lowerCAmelCase( __lowerCamelCase = 6008_5147_5143 ): try: __a = int(__lowerCamelCase ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError('Parameter n must be greater t...
246
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline lowerCamelCase_ : Any = datasets.utils.loggi...
246
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ : Optional[Any] = logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake_case__ ...
280
'''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 : Union[str, Any] = datasets.logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] = '''\ @InP...
72
0
'''simple docstring''' from __future__ import annotations from typing import Generic, TypeVar __UpperCAmelCase = TypeVar("""T""") class UpperCamelCase__ ( Generic[T] ): """simple docstring""" def __init__( self : Any , lowerCamelCase_ : T ): ''...
79
'''simple docstring''' import math def __A ( lowerCamelCase_ ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return ...
79
1
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('''ignore''', category=UserWarning, module='''torch.optim.lr_scheduler''') class lowerCamelCase_ : ...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : int , __A : Tuple , __A : List[Any] ): __A : Optional[int] = None __A : Any = None __A : int = graph self._normalize_graph(__A , ...
17
1
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def a (_lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase = None , _lowerCAmelCase = None...
89
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import to...
89
1
'''simple docstring''' import os import pytest from attr import dataclass lowerCAmelCase : Dict = 'us-east-1' # defaults region @dataclass class SCREAMING_SNAKE_CASE__ : lowerCAmelCase_ = 42 lowerCAmelCase_ = """arn:aws:iam::558105141721:ro...
3
"""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,...
690
0
"""simple docstring""" import os import string import sys __A = 1 << 8 __A = { 'tab': ord("""\t"""), 'newline': ord("""\r"""), 'esc': 27, 'up': 65 + ARROW_KEY_FLAG, 'down': 66 + ARROW_KEY_FLAG, 'right': 67 + ARROW_KEY_FLAG, 'left': 68 + ARROW_KEY_FLAG, ...
702
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast 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 ...
560
0
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def A ( _SCREAMING_SNAKE_CASE ) -> str: l...
311
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE__ : List[str] = { 'configuration_bridgetower': [ 'BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BridgeTowerConfig'...
311
1
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py A = 'src/transformers' A = 'docs/source/en/tasks' def _low...
97
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A = logging.get_logger(__name__) A = {'vocab_file': 'spm_char.model'} A = { ...
97
1
import enum import shutil import sys __UpperCamelCase, __UpperCamelCase: Optional[int] = shutil.get_terminal_size() __UpperCamelCase: Optional[Any] = {"""UP""": """A""", """DOWN""": """B""", """RIGHT""": """C""", """LEFT""": """D"""} class __lowerCAmelCase ( enum.Enum ): ...
266
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class __lowerCAmelCase ( _UpperCamelC...
266
1
import math from collections.abc import Iterator from itertools import takewhile def lowerCAmelCase ( UpperCAmelCase ) ->List[str]: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif n...
720
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowercase_ = { '''configuration_clip''': [ ...
336
0
def lowerCamelCase__ (_UpperCAmelCase = 10 , _UpperCAmelCase = 1000 , _UpperCAmelCase = True): assert ( isinstance(_UpperCAmelCase , _UpperCAmelCase) and isinstance(_UpperCAmelCase , _UpperCAmelCase) and isinstance(_UpperCAmelCase , _U...
73
def __snake_case ( __magic_name__ ): '''simple docstring''' lowercase = set() # To detect a back edge, keep track of vertices currently in the recursion stack lowercase = set() return any( node not in visited and depth_first_sea...
441
0
"""simple docstring""" import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForCo...
709
"""simple docstring""" import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() a__ : List[str] = logging.get_logger(__name__) def A__ ( __lowerCamelCase ): ...
309
0
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 # python utils/check_config_docstrings.py UpperCam...
619
"""simple docstring""" import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class UpperCamelCase : """simple docstring...
571
0
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) a__ = { """iou_prediction_head.laye...
99
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_device=Fals...
99
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_comm...
22
'''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 _snake_case : Tuple = ...
22
1
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(__lowercase ) , 'Tatoeba direc...
710
from typing import List import numpy as np def __magic_name__( __UpperCAmelCase ) -> int: '''simple docstring''' _lowerCamelCase = {key: len(__UpperCAmelCase ) for key, value in gen_kwargs.items() if isinstance(__UpperCAmelCase , __UpperCAmelCase )} if le...
638
0
"""simple docstring""" import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) # pylint: disable=invalid-name class a__ ...
227
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def UpperCAmelCase ( snake_case : BertModel , snake_case : str , snake_case : str ): _lowerCAmelCa...
227
1
'''simple docstring''' from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet import StableDiffusionControlNetPipeline # noqa: F401 deprecate( 'stable diffusion controlnet', '0.22.0', 'Importing `StableDiffusio...
705
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { 'microsoft/markuplm-base': 'https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json', 'microsof...
347
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer __A : Optional[Any] = logging.get_logger(__name__) __A : ...
16
import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings __A : Optional[Any] = loggin...
16
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCAmelCase: Any = { 'configuration_rag': ['RagConfig'], 'retrieval_rag': ['RagRetriever'], 'tokenization_rag': ['RagTokenizer...
713
'''simple docstring''' import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_av...
195
0