code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __A =get_tests_dir("fixtures/spiece.model") @...
226
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class __SCREAMING_SNAKE_CASE ( A__ ): A : Union[List[np....
337
0
from math import pow, sqrt def A ( *_lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : Any = len(a__ ) > 0 and all(value > 0.0 for value in values ) return result def A ( _lowerCamelCase , _lowerCamelCase ): '...
361
class UpperCAmelCase_ : def __init__( self): '''simple docstring''' _lowerCAmelCase : Dict = 0 _lowerCAmelCase : Optional[int] = 0 _lowerCAmelCase : Tuple = {} ...
300
0
UpperCAmelCase_ : Optional[int] = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] UpperCAmelCase_ : str = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] UpperCAmelCase_ : str = { 0: 'Sunday', 1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursday', 5:...
32
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_t...
32
1
'''simple docstring''' # Imports import numpy as np class UpperCamelCase_ : def __init__( self , A=None , A=None , A=None , A=None , A=None ) -> Union[str, Any]: self.set_matricies(red=A , green=A , blue=A , red_edge=A , nir=A ) def _lowercase( s...
338
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extrac...
338
1
"""simple docstring""" from math import ceil, sqrt def lowercase ( a__ : int = 1000000 ) -> int: _UpperCamelCase = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: _UpperCamelCase = max(ceil(sqrt(ou...
256
import math import random from typing import Any from .hill_climbing import SearchProblem def lowerCAmelCase__( lowercase : Dict , lowercase : bool = True , lowercase : float = math.inf , lowercase : float = -math.inf , lowercase : float = math.in...
326
0
'''simple docstring''' def _a( UpperCamelCase__ : int, UpperCamelCase__ : int ): '''simple docstring''' return base * power(UpperCamelCase__, (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of...
367
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_instructblip': [ 'INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InstructBlipConfig', 'InstructBlip...
222
0
'''simple docstring''' from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Any = logging.get_logger(__name__) lowerCamelCase : Dict = { 'huggingface/time-series-transformer-tourism-monthly': ...
2
'''simple docstring''' from datetime import datetime import requests def _lowercase ( __A ): '''simple docstring''' __UpperCamelCase = """https://downloadgram.net/wp-json/wppress/video-downloader/video?url=""" __UpperCamelCase = requests.g...
349
0
'''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 Tokenizer...
368
'''simple docstring''' import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets _snake_case = '\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Languag...
199
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 required by appl...
26
import inspect import unittest from transformers import ViTMSNConfig 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 import ConfigTester from ...test...
300
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { '''facebook/xmod-base''': '''https://huggin...
211
import math class _a : def __init__( self : List[Any] , _SCREAMING_SNAKE_CASE : Any=0 )-> Optional[Any]: # a graph with Node 0,1,...,N-1 lowerCAmelCase__ : Optional[int] = n lowerCAmelCase__ : List[Any] = [ [math.inf fo...
211
1
# Imports import numpy as np class lowercase_ : """simple docstring""" def __init__( self , __SCREAMING_SNAKE_CASE=None , __SCREAMING_SNAKE_CASE=None , __SCREAMING_SNAKE_CASE=None , __SCREAMING_SNAKE_CASE=None , __SCREAMING_SNAKE_CASE=None ) ->int: ...
338
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowercase_ ( unittest.TestCase ): ...
338
1
"""simple docstring""" 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__ ( __magic_name__ , __magic_name__ ): ...
341
"""simple docstring""" import warnings from .generation import TFGenerationMixin class lowerCamelCase__ ( __magic_name__ ): '''simple docstring''' # warning at import time warnings.warn( '''Importing `TFGenerationMixin` from `src/transformers/generation_tf_uti...
341
1
'''simple docstring''' import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from j...
34
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPAIN...
222
0
def __UpperCamelCase (_SCREAMING_SNAKE_CASE ) -> List[str]: if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise TypeError('only integers accepted as input' ) else: lowercase__ = str(abs(_SCREAMING_SNAKE_CASE ) ) lowercase__ ...
356
from typing import TYPE_CHECKING from ..utils import _LazyModule lowercase_ = { """config""": [ """EXTERNAL_DATA_FORMAT_SIZE_LIMIT""", """OnnxConfig""", """OnnxConfigWithPast""", """OnnxSeq2SeqConfigWithPast""", """PatchingSpec""", ], ...
269
0
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class UpperCamelCase_ ( UpperC...
14
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class A ( UpperCamelCase_ ): UpperCamelCase__ : Any =(DPM...
199
0
def lowerCamelCase ( a_ ) -> int: assert column_title.isupper() lowerCAmelCase_ = 0 lowerCAmelCase_ = len(a_ ) - 1 lowerCAmelCase_ = 0 while index >= 0: lowerCAmelCase_ = ...
14
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
14
1
'''simple docstring''' from math import isqrt def lowerCAmelCase (__A): """simple docstring""" _a = [True] * max_number for i in range(2 , isqrt(max_number - 1) + 1): if is_prime[i]: for j in range(i**2 , __A , __A): _a = Fal...
211
'''simple docstring''' from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder lowercase_ = datasets.utils.logging.get_logger(__name__) class __A ( folder_based_builder.FolderBasedBuilderConfig ): ...
211
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class _snake_case ( metaclass=lowercase_ ): lowerCAmelCase_ : Dict = ["flax"] def __init__( self , *a__ , **a__ ) -> List[Any]: '''simple docstring''' ...
92
'''simple docstring''' import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention...
92
1
'''simple docstring''' 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 ( __snake_case , __snake_case ): '''simple docst...
341
'''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
1
'''simple docstring''' from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
16
'''simple docstring''' import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, ...
16
1
import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_utils import OnnxRuntimeModel ...
43
"""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_modeli...
269
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision f...
356
"""simple docstring""" import math def _lowerCamelCase( a ): __a = [] __a = 2 __a = int(math.sqrt(a ) ) # Size of every segment __a = [True] * (end + 1) __a = [] while start <= end: if...
268
0
def SCREAMING_SNAKE_CASE ( lowercase_ ) -> int: """simple docstring""" assert column_title.isupper() A__ = 0 A__ = len(lowercase_ ) - 1 A__ = 0 while index >= 0: A__ = (ord(column_title[index...
14
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np _lowerCamelCase : str = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 _lowerCamelCase : Tuple = typing.Union[np.floataa, int, float] # noqa: UP007 ...
14
1
import datasets _UpperCAmelCase = "\\n@InProceedings{conneau2018xnli,\n author = \"Conneau, Alexis\n and Rinott, Ruty\n and Lample, Guillaume\n and Williams, Adina\n and Bowman, Samuel R.\n and Schwenk, Holger\n ...
368
from datetime import datetime import requests def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :str ) -> bytes: __lowerCAmelCase : List[Any] = """https://downloadgram.net/wp-json/wppress/video-downloader/video?url=""" __lowerCAmelCase : Dict = requests.get(b...
232
0
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import ...
92
import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( """The `image_to_image.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionImg2ImgPipeline` instead.""" )
92
1
import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgumentParser, TrainingArguments ...
323
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __A : Any = logging.get_logger(__name__) __A : Union[str, Any] = { '''shi-labs/dinat-mini-...
323
1
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, ...
16
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is...
16
1
def lowerCamelCase_ ( _a , _a ): """simple docstring""" lowerCAmelCase__ : Optional[Any] = len(snake_case__ ) lowerCAmelCase__ : Dict = [] for i in range(len(snake_case__ ) - pat_len + 1 ): lowerCAmelCase__ : str ...
365
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowerCamelCase = logging.get_logger(__name__) lowerCamelCase ...
211
0
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 A ( UpperCAmelCase_ ): __UpperC...
65
"""simple docstring""" import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers...
268
0
"""simple docstring""" from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from ...
215
"""simple docstring""" from __future__ import annotations class __A : """simple docstring""" def __init__( self , __A = 0 ) -> Dict: a =key def SCREAMING_SNAKE_CASE ( self , __A , __A ) -> list[str...
215
1
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = {"""vocab_file""": """vocab.json"""} snake...
78
import math def _SCREAMING_SNAKE_CASE ( ) -> None: '''simple docstring''' __UpperCamelCase : List[Any] = input("Enter message: ") __UpperCamelCase : Optional[int] = int(input(F'Enter key [2-{len(_lowerCamelCase) - 1}]: ')) ...
232
0
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class __SCREAMING_SNAKE_CASE (lowerCamelCa...
346
'''simple docstring''' import requests lowerCAmelCase_ : List[Any] = 'YOUR API KEY' def _lowerCamelCase ( lowercase : str , lowercase : str = giphy_api_key ) -> list: _a = "+".join(query.split() ) _a = ...
346
1
'''simple docstring''' import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils impo...
323
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class UpperCamelCase__ ( unittest.TestCase ): """simple docs...
323
1
'''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, ...
351
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE_: int ={ 'configuration_maskformer': ['MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MaskFormerConfig'], 'configuratio...
106
0
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(): import jax.numpy as jnp from tran...
76
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, ...
211
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config.json""", # See all...
352
'''simple docstring''' from collections import Counter from timeit import timeit def a ( __a = "" , ) -> bool: '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def a ( _...
219
0
'''simple docstring''' from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def snake_case_ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ = False )-> list[float]: '''simple docstrin...
215
'''simple docstring''' from __future__ import annotations import queue class lowercase : """simple docstring""" def __init__( self ,a_ ) -> str: _UpperCAmelCase : Optional[Any] = data _UpperCAmelCase : Optional[int] = None ...
215
1
'''simple docstring''' import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import Token...
360
'''simple docstring''' from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ =...
111
0
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class lowerCAmelCase_ ( lowerCamelCas...
346
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _UpperCamelCase ( ): '''simple docstring''' import os as original_os from os import path as original_path from os import rename as original_rename from os.path im...
346
1
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> list[int]: '''simple docstring''' lowercase_ = 2 lowercase_ = [] while i * i <= n: if n % i: i += 1 else: n //= i ...
313
"""simple docstring""" import os from collections.abc import Iterator def _SCREAMING_SNAKE_CASE (__lowerCAmelCase = "." ) -> Iterator[str]: '''simple docstring''' for dir_path, dir_names, filenames in os.walk(__lowerCAmelCase ): lowercase_ = [d for d...
313
1
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class a_ ...
309
"""simple docstring""" from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar __UpperCamelCase : Tuple = TypeVar('''T''') class SCREAMING_SNAKE_CASE ( Generic[T] ): """simple docstring""" lowerc...
106
0
import copy import re class lowercase_ : A__ : Optional[Any] = """hp""" A__ : Union[str, Any] = {} A__ : Optional[int] = None @classmethod def lowerCamelCase_ ( cls , __UpperCamelCase , __UpperCamelCase ): """simple docstring""" ...
261
from __future__ import annotations def lowerCamelCase__ ( a__ : list[list[int]] ) -> int: # preprocessing the first row for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in...
261
1
def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__ ): return int((input_a, input_a).count(0 ) == 0 ) def lowerCamelCase_ ( ): assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_gate(1 , 0 ) == 0 assert and_gate(1 , 1 ) == 1 if __name_...
19
import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_NAMES, save_json f...
219
0
from collections.abc import Callable import numpy as np def UpperCamelCase (lowercase_: Callable , lowercase_: float , lowercase_: float , lowercase_: float , lowercase_: float ) -> np.array: A__ : List[str] = int(np.ceil((x_end - xa) / step_size ) ) ...
141
from argparse import ArgumentParser from . import BaseTransformersCLICommand def UpperCamelCase (lowercase_: int ) -> str: return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) class _a (__magic_name__ ): '''simple docstring'''...
141
1
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...
244
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_torch_available(): import torch...
111
0
'''simple docstring''' import argparse import datetime def _snake_case ( A ) -> str: lowerCAmelCase__ = { """0""": """Sunday""", """1""": """Monday""", """2""": """Tuesday""", """3""": """Wednesday""", ...
356
'''simple docstring''' 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 ...
228
0
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class a_ ( unittest.TestCase ): """simple docstring""" def __lowerCAmelCase ( self ) ->None: SCREAMING_SNAKE_CASE...
313
import csv import tweepy # Twitter API credentials a__ : Union[str, Any] = '''''' a__ : List[str] = '''''' a__ : Any = '''''' a__ : List[str] = '''''' def UpperCAmelCase_( a__ ): """simple docstring""" SCREAMING_SNAKE_CASE ...
313
1
from __future__ import annotations from typing import Any class __lowerCAmelCase : def __init__(self , __magic_name__ , __magic_name__ , __magic_name__ = 0 ) -> None: '''simple docstring''' snake_case_ : Tuple = row, column sn...
355
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase_ = {'''configuration_xglm''': ['''XGLM_PRETRAINED_...
279
0
"""simple docstring""" from __future__ import annotations from dataclasses import dataclass @dataclass class snake_case__ : _snake_case : float _snake_case : TreeNode | None = None _snake_case : TreeNode | None = None def _lowerCamelCase( a ): # Valida...
261
"""simple docstring""" 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 snake_case__ ( snake_case_, snake_case_ ): @register_to_config def __init__( ...
261
1
"""simple docstring""" import functools import logging import os import sys import threading from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import ...
350
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __magic_name__ ( __UpperCAme...
172
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_im...
141
'''simple docstring''' import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def __UpperCamelCase ( lowercase__ : Optional[int], lowercase__ : str, lowercase__ : int ): '''simple docstring''' __...
141
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta.tokenization_ta import TaToke...
364
from __future__ import annotations from PIL import Image # Define glider example lowerCAmelCase__ :str = [ [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...
185
0
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class SCREAMING_SNAKE_CASE( datasets.BeamBasedBuilder ): ...
23
from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...test_pi...
228
0
import os from collections import deque import torch from torch.utils.data import Dataset class __UpperCAmelCase ( lowercase__ ): def __init__( self : Tuple, __A : str="", __A : str="train" ): assert os.path.isdir(lowercase_ ) UpperCAmel...
351
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, Train...
99
0
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torch ...
348
lowerCAmelCase_ = { "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr": 4_1_8_6_8_0_...
279
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase :str = logging.get_logger(__name__) _lowerCAmelCase :Optional[int] = { 'google/big...
68
"""simple docstring""" from ...processing_utils import ProcessorMixin class _UpperCAmelCase ( a ): '''simple docstring''' a__ ='''WhisperFeatureExtractor''' a__ ='''WhisperTokenizer''' def __init__( self , A , A ) -> Any: super().__i...
68
1
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester ...
285
"""simple docstring""" import flax.linen as nn import jax import jax.numpy as jnp class UpperCamelCase ( nn.Module ): UpperCAmelCase : int UpperCAmelCase : jnp.dtype = jnp.floataa def _lowercase (self : Any) -> Optional[int]: ...
172
0
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, ...
39
import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( 'The `image_to_image.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionImg2ImgPipeline` instead.' )
39
1
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCAmelCase_ ( __a ) -> Union[str, Any]: """simple docstring""" def is_in_circle(__a , __a ) -> bool: lowerCamelCase__: Tuple =sqrt((x...
10
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) A__ : List[str] = {"""configuration_beit""": ["""BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
185
0
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelForQuestionAnswering, ...
131
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(...
131
1
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 from accelerate import Ac...
21
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments @requi...
99
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { "configuration_pegasus_x": ["PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP", "PegasusXConfig"], } try: if not is_torch_available(): ...
2
"""simple docstring""" import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": __A = argparse.ArgumentParser() parser.add_argument( "--checkpoint_path", defau...
2
1
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeatur...
68
def lowerCAmelCase__ ( ) -> Any: '''simple docstring''' for n in range(1 , 1_0_0_0_0_0_0 ): yield n * (n + 1) // 2 def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: Tuple ) -> Any: '''simple docstring''' A__ = 1 A__ ...
68
1
'''simple docstring''' lowerCamelCase_ = { 0: '''0''', 1: '''1''', 2: '''2''', 3: '''3''', 4: '''4''', 5: '''5''', 6: '''6''', 7: '''7''', 8: '''8''', 9: '''9''', 10: '''a''', 11: '''b''', 12: '''c''', 13: '''d''', 14: '''e''', 15: '''f''...
360
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = { '''camembert-base''': ...
174
0
import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistep...
39
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger _a = get_logger(__name__) class __lowerCamelCase ( enum.Enum): """simple docstring""" UpperCamelCase__ = ...
39
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_available f...
369
from ..utils import DummyObject, requires_backends class A__ ( metaclass=__magic_name__ ): lowercase = ['torch', 'transformers', 'onnx'] def __init__( self : Any , *a : Any , **a : Any ): '''simple doc...
307
0
from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstrings, add_start...
131
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer lowerCamelCase = logging.get_logger(__name__) lowerCa...
131
1
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> set: SCREAMING_SNAKE_CASE__ : Union[str, Any] = set() # edges = list of graph's edges SCREAMING_SNAKE_CASE__ : List[str] = get_edges(__lowerCAmelCase ) # While there are still elements...
56
"""simple docstring""" import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu a :List[Any] =...
56
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase : List[Any] = { 'configuration_pegasus_x': ['PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PegasusXConfig'], } try: if not is_torch_availab...
2
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase : str = { 'configuration_rag': ['RagConfig'], 'retrieval_rag': ['RagRetriever'], 'tokenization_rag': ['RagTokeniz...
2
1
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : List[str] = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctct''': ['''MCTCTFeatur...
363
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer _lowerCamelCase : Union[str, Any] = logging.get_logger(__nam...
206
0
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging lowerC...
302
'''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, get_resize_output_image_size, normalize, rescale, resize,...
174
0
from collections import deque class __snake_case : def __init__( self : Tuple , _snake_case : str , _snake_case : int , _snake_case : int): """simple docstring""" UpperCAmelCase_ = process_name # process name ...
364
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_...
7
0
from numpy import exp, pi, sqrt def lowerCamelCase_ ( _a : str , _a : int = 0.0 , _a : Dict = 1.0 ): '''simple docstring''' return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__": import doctest ...
345
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) __UpperCamelCase : int = 299792458 # Symbols __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase : Optional[int] = symbols...
307
0
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case__ : Any = { '''configuration_vivit''': ['''VIVIT_PRETRAINED_CONFIG_ARCHIVE...
359
"""simple docstring""" import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class snake_case_( a__ ): __UpperCamelCase = (DDPMScheduler,) def lowerCamelCase__ ( self : List[Any] , **UpperCamelCase_ :...
314
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging a : Optional[int] = logging.get_logger(__name__) def __magic_name__ ( __UpperCAmelCase ) -> List[int]: '''simple docstring''' if isinstance...
56
'''simple docstring''' import math from collections.abc import Callable def __magic_name__ ( __UpperCAmelCase, __UpperCAmelCase, __UpperCAmelCase ) -> float: '''simple docstring''' snake_case_ = xa snake_case_ = xa while True: if x_n == x...
56
1
"""simple docstring""" from __future__ import annotations from collections import Counter from random import random class lowerCamelCase : '''simple docstring''' def __init__(self ): """simple docstring""" UpperCAmelCase__ : List[str] = {} def _a ...
166
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class lowerCamelCase ( datasets.BeamBasedBuilder ): '''simple docstring''' def ...
166
1
"""simple docstring""" import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) ...
224
'''simple docstring''' import argparse import struct import unittest class _lowerCAmelCase : def __init__(self , lowercase ): A_ : List[str] = data # Initialize hash values A_ : Tuple = [ 0X6A09_E667, 0XBB67_AE85, 0X3C6E_F3...
206
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_i...
68
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=a ): '''simple docstring''' a__ =['''transformers''', '''torch''', '''note_seq'''] def __init__( self , *A , **A ) -> int: requires_ba...
68
1
"""simple docstring""" import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import A...
291
from timeit import timeit def _snake_case( SCREAMING_SNAKE_CASE__ : int ) -> int: '''simple docstring''' if number < 0: raise ValueError('the value of input must not be negative' ) A__ = 0 while number: number &=...
7
0
'''simple docstring''' import os def snake_case__ ( ) -> List[str]: A_ : Optional[Any] = os.path.join(os.path.dirname(lowerCamelCase__ ) , '''num.txt''' ) with open(lowerCamelCase__ ) as file_hand: return str(sum(int(lowerC...
4
'''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 snake_case__ = l...
4
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig lowerCAmelCase__ = { '''google/tapas-base-finetuned-sqa''': ( '''https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json''' ), '''google/tapas-base-finetuned-wtq''': ( '''ht...
104
from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCAmelCase__ ( A__ ): """simple docstring""" def __init__( ...
314
0
import math from datetime import datetime, timedelta def lowerCamelCase__ ( lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : Optional[int] = year % 19 SCREAMING_SNAKE_CASE : List[str] = year % 4 SCREAMING_SNAKE_CASE : str = year % 7 S...
369
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) snake_case = { """configuration_encodec""": [ """ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP""", """EncodecConfig""", ], """feature_extracti...
319
0
'''simple docstring''' def _A ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): """simple docstring""" __lowercase =[False] * len(_lowerCAmelCase ) __lowercase =[] queue.append(_lowerCAmelCase ) ...
166
'''simple docstring''' from __future__ import annotations def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase =[True] * limit __lowercase =False __lowercase =False __lowercase =True for i in range(3 , int(...
166
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowercase: str = { '''configuration_lxmert''': ['''LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LxmertConfig''']...
368
import math from numpy import inf from scipy.integrate import quad def a( A : float ) -> float: """simple docstring""" if num <= 0: raise ValueError("math domain error" ) return quad(A , 0 , A , args=(A) )[0] def a( A : float , A :...
71
0
from ...processing_utils import ProcessorMixin class a__ ( snake_case ): """simple docstring""" __lowerCamelCase = 'WhisperFeatureExtractor' __lowerCamelCase = 'WhisperTokenizer' def __init__( self , lowercase , lowercase ) -> Dict: ...
68
import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokenization_common import To...
68
1
"""simple docstring""" from __future__ import annotations from math import gcd def __A ( a_ :int , a_ :int = 2 , a_ :int = 1 , a_ :int = 3 , ) -> int | None: # A value less than 2 can cause an infinite loop in the algorithm. if num...
188
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apach...
188
1
'''simple docstring''' import os def a_ ( ): lowerCAmelCase = os.path.join(os.path.dirname(lowerCamelCase ) , 'num.txt' ) with open(lowerCamelCase ) as file_hand: return str(sum(int(lowerCamelCase ) for line in file_hand ) )[:10] if __name__ == ...
4
'''simple docstring''' def a_ ( lowerCamelCase : Optional[Any] ): return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8:...
4
1
"""simple docstring""" import string def __lowerCAmelCase ( lowercase : str ) -> str: """simple docstring""" snake_case : List[str] = "" for i in sequence: snake_case : Optional[Any] = ord(lowercase ) if 65 <= extract <= 90...
112
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _lowerCAmelCase ( unit...
112
1
import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def _UpperCAmelCase ( snake_case , snake_case , snake_case , snake_case ): """simple docstring""" _lowerCAmelCase = s.rsplit(__lowercase , __lowerc...
82
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasonin...
319
0
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class _snake_case ( unittest.TestCase ...
92
'''simple docstring''' _SCREAMING_SNAKE_CASE : Optional[int] = "Alexander Joslin" import operator as op from .stack import Stack def UpperCamelCase_( snake_case : str ): '''simple docstring''' snake_case_ = {"*": op.mul, "/": op.truediv, "...
92
1
"""simple docstring""" import itertools import string from collections.abc import Generator, Iterable def _snake_case ( _snake_case : Iterable[str] , _snake_case : int ): lowerCAmelCase : Optional[int] = iter(_snake_case ) while True: lowerCAmelCase : Tu...
60
import random def A ( a_ ,a_ ,a_ = False ) -> dict: __UpperCamelCase : dict ={i: [] for i in range(a_ )} # if probability is greater or equal than 1, then generate a complete graph if probability >= 1: ...
71
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowercase__ : Dict = { """configuration_falcon""": ["""FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FalconCon...
289
"""simple docstring""" import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mod...
289
1
import random from .binary_exp_mod import bin_exp_mod def UpperCAmelCase__ ( _A : Optional[int] , _A : Dict=10_00 ): '''simple docstring''' if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd a__ =n - 1 a__ =0 while d % 2 ==...
188
from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): import torch f...
188
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) snake_case_ = { """configuration_mega""": ["""MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MegaConfig""", """MegaOnnxConfig"""]...
181
"""simple docstring""" import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme import ...
181
1
'''simple docstring''' from __future__ import annotations def lowerCAmelCase_ ( _lowerCamelCase: list[int] ): return len(set(_lowerCamelCase ) ) == len(_lowerCamelCase ) if __name__ == "__main__": import doctest doctest.testmod()
112
'''simple docstring''' def lowerCAmelCase_ ( _lowerCamelCase: float , _lowerCamelCase: list[float] ): if discount_rate < 0: raise ValueError("""Discount rate cannot be negative""" ) if not cash_flows: raise ValueError("""Cash flows list cannot be empty""" ) __SCREA...
112
1
"""simple docstring""" from __future__ import annotations from typing import Any class lowercase__ : '''simple docstring''' def __init__( self : Union[str, Any] , _UpperCAmelCase : int = 6 ) -> None: '''s...
364
"""simple docstring""" def a__ ( lowerCAmelCase__ = 2000000 ): UpperCAmelCase_ = [0 for i in range(n + 1 )] UpperCAmelCase_ = 1 UpperCAmelCase_ = 1 for i in range(2 , int(n**0.5 ) + 1 ): ...
241
0
def _a ( SCREAMING_SNAKE_CASE_ : int ): # noqa: E741 __lowerCAmelCase = len(SCREAMING_SNAKE_CASE_ ) __lowerCAmelCase = 0 __lowerCAmelCase = [0] * n __lowerCAmelCase = [False] * n __lowerCAmelCase = [Fa...
92
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 torch_xla.core.x...
92
1
'''simple docstring''' from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.uti...
349
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) A_ : str = { """configuration_roberta_prelayernorm""": [ """ROBERTA_PRELA...
349
1
"""simple docstring""" from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def __UpperCAmelCase ( lowercase ,lowercase ,lowercase ,lowercase ,): """simple docstring""" _UpperCAmelCase , _UpperCAmelCase ...
289
"""simple docstring""" import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transforme...
289
1
'''simple docstring''' from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer lowerCAmelCase: List[str] = loggi...
96
'''simple docstring''' from math import factorial, pi def lowerCamelCase__ ( _A , _A = 30 ): if not isinstance(_A , (int, float) ): raise ValueError('maclaurin_sin() requires either an int or float for theta' ) if not isinstance(_A , _A ) or accuracy <= 0: ...
96
1