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
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block ...
306
"""simple docstring""" import re import string import numpy as np import datasets a__ : Dict = """ Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. """ a__ : List[str] ...
589
0
"""simple docstring""" def __snake_case ( UpperCamelCase ) -> list: """simple docstring""" if len(UpperCamelCase ) <= 1: return [tuple(UpperCamelCase )] a__ = [] def generate(UpperCamelCase , UpperCamelCase ): if k == 1: res.append(tuple(...
158
"""simple docstring""" import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_ten...
158
1
import flax.linen as nn import jax import jax.numpy as jnp class _A ( nn.Module ): """simple docstring""" lowerCamelCase : int lowerCamelCase : jnp.dtype = jnp.floataa def _a ( self : Union[str, Any] ) -> List[Any]: _...
68
'''simple docstring''' def lowerCamelCase ( _snake_case : Optional[Any] ,_snake_case : Union[str, Any] ,_snake_case : Dict ,_snake_case : List[str] ,_snake_case : List[str] ,_snake_case : List[str] ): '''simple docstring''' if index == r...
267
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCAmelCase_ : str = { "configuration_mobilevit": ["MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_...
716
'''simple docstring''' from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar UpperCAmelCase_ : str = TypeVar("T") class a ( Generic[T] ): '''simple docstring''' __lowerCAmelCase : deque[T] # Cache store of keys ...
424
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 : Any = ...
63
from __future__ import annotations from fractions import Fraction def lowercase ( _a ,_a ) -> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def lowercase ( _a ) -> list[str]: UpperCAmelCase_: int...
137
0
'''simple docstring''' 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 DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils ...
714
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
403
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_availab...
86
import inspect import unittest class UpperCamelCase( unittest.TestCase ): def SCREAMING_SNAKE_CASE_ ( self : Dict ) -> List[Any]: '''simple docstring''' try: import diffusers # noqa: F401 except...
371
0
'''simple docstring''' import string from math import logaa def UpperCAmelCase ( a_ , a_ ) -> int: """simple docstring""" A_ : int = document.translate( str.maketrans("""""" , """""" , string.punctuation ) ).replace(...
385
'''simple docstring''' from __future__ import annotations class _lowerCAmelCase : """simple docstring""" def __init__( self , _lowerCamelCase ) -> Dict: A_ : List[Any] = TypeError( """Matrices must be formed from a list of zero or m...
385
1
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTesterMixin ...
323
def lowerCamelCase_(lowerCamelCase_ ) -> None: UpperCAmelCase = generate_pascal_triangle(lowerCamelCase_ ) for row_idx in range(lowerCamelCase_ ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=" " ) ...
323
1
"""simple docstring""" from __future__ import annotations UpperCAmelCase__ =10 def lowerCAmelCase_ ( UpperCamelCase__ : list[int] ): """simple docstring""" __lowercase = 1 __lowercase = max(UpperCamelCase__ ) while placement <= max_digit...
703
"""simple docstring""" import os import numpy import onnx def lowerCAmelCase_ ( UpperCamelCase__ : Optional[int] , UpperCamelCase__ : List[str] ): """simple docstring""" __lowercase = a.name __lowercase = b.name __lowercase = """...
442
0
'''simple docstring''' import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def UpperCamelCase_ ( snake_case_ : Optional[Any] , snake_case_ : List[Any] , snake_case_ : str , snake_case_ : Dict=5 ) -> Optional[int]: '''s...
427
import os from math import logaa def _lowerCAmelCase ( __magic_name__ :str = "base_exp.txt" ): UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(__magic_name__ ) , __magic_name__ ) )...
121
0
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transf...
715
def A(__a: int ): lowerCAmelCase_ = abs(__a ) lowerCAmelCase_ = 0 while n > 0: res += n % 10 n //= 10 return res def A(__a: int ): lowerCAmelCase_ = abs(__a ) return n if n < 10 else n % 10 + sum_of_digits(n // 10 ) def A(__a: int ...
226
0
'''simple docstring''' import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import...
98
"""simple docstring""" def __UpperCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> str: """simple docstring""" if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) __snake_case = str(bin(SCREAMIN...
163
0
'''simple docstring''' from dataclasses import dataclass, field from typing import Optional @dataclass class a_ : lowerCamelCase__ : Optional[str] = field( default='codeparrot/codeparrot' , metadata={'help': 'Model name or path of model to be trained.'} ) lowerCamelCase__ ...
511
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ =logging.get_logger(__name__) lowercase__ ={ 'xlm-mlm-en-2048': 'https://hu...
511
1
import argparse from ...utils.dataclasses import ( ComputeEnvironment, DistributedType, DynamoBackend, PrecisionType, SageMakerDistributedType, ) from ..menu import BulletMenu snake_case_ : Optional[Any] = [ 'EAGER', 'AOT_EAGER', 'INDUCTOR', 'NVFUSER', 'AOT_NVFUSE...
488
"""simple docstring""" from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def UpperCamelCase ( SCREAMING_SNAKE_CASE_ ) ->Union[str, Any]: return ConvertCommand( args.model_type , args.tf_checkpoint ,...
434
0
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class a__ ( snake_case__ ): _a : List[Any] ...
712
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py UpperCamelCase__ = """.""" if __name__ == "__main__": UpperCamelCase__ = os.path.join(REPO_PATH, """utils/documentation_tests.txt""...
552
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf UpperCAmelCase = logging.get_logger(__name__) @dat...
84
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Optio...
262
0
'''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 A = datasets.logging.get_logger(__name__) A = '\\n@InProceedings{moosavi2019minimum,\n author...
703
import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig A = { 'facebook/maskformer-swin-base-ade': ( 'https://huggingface.c...
234
0
'''simple docstring''' import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class lowercase_ (lowerCamelCase__ ): """simple docstring""" SCREAMING_SNAKE_CASE : Tuple = (PNDMScheduler,) SCREAMING...
41
'''simple docstring''' import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_v...
92
0
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _UpperCAmelCase ( A__ ,unittest.TestCase ): """simple docstring""" lowercase__ ...
671
class _UpperCAmelCase : """simple docstring""" def __init__( self : Optional[int], lowerCamelCase : str = "", lowerCamelCase : bool = False ): '''simple docstring''' # Mapping from the first character of the prefix of the node lowercase...
671
1
"""simple docstring""" from __future__ import annotations import bisect def A__ ( A__ , A__ , A__ = 0 , A__ = -1 ) -> int: '''simple docstring''' if hi < 0: _UpperCAmelCase = len(UpperCAmelCase__ ) while lo < hi: _UpperCAmelC...
426
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def __lowerCAmelCase ( UpperCAmelCase__ : str , UpperCAmelCase__ : str , **UpperCAmelCase__ : List[str] ) -> Tuple: lowerCamelCase_ = AutoConfig.from_...
272
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : Any = { "configuration_funnel": ["FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP", "FunnelConfig"], ...
3
import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ..utils import assert_arrow_memor...
3
1
def _a ( lowercase__ : int ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Any = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def _a ( lowercase__ : int = 50_00 ): '''simple docstring''' SCREAMING_SNAKE_CASE__...
85
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCAmelCase = { '''configuration_gpt_neo''': ['''GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoConfig''', '''GPTNeoOnnxConfig'''], } try: if not is_torch_a...
84
0
import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging __lowerCamelCase = { ...
707
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase = { 'configuration_informer': [ 'INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InformerConfig', ], } try...
328
0
import math import unittest from transformers import BioGptConfig, 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 ModelTeste...
64
'''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, to_chan...
314
0
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a_ ( unittest.TestCase ): @property...
707
def a_ ( __magic_name__ ) -> int: """simple docstring""" if not isinstance(__magic_name__ , __magic_name__ ): raise TypeError('''only integers accepted as input''' ) else: snake_case : str = str(ab...
84
0
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch...
433
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json',...
433
1
"""simple docstring""" 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, AutoModelForPre...
194
"""simple docstring""" def lowerCAmelCase ( __UpperCamelCase = 1000 ): '''simple docstring''' return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
194
1
import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin, SchedulerOutput @dataclass c...
234
'''simple docstring''' from __future__ import annotations def _lowerCAmelCase ( lowerCamelCase_ : list[int | str] ): create_state_space_tree(lowerCamelCase_ , [] , 0 , [0 for i in range(len(lowerCamelCase_ ) )] ) def _lowerCAmel...
502
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { """BAAI/AltCLIP""": """https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json""", # S...
481
def _lowerCAmelCase ( _lowerCAmelCase ): '''simple docstring''' A_ : Union[str, Any] = [0] * len(_lowerCAmelCase ) A_ : Optional[int] = [] A_ : str = [] A_ : Dict = 0 for values in graph.values(): for i in values:...
481
1
'''simple docstring''' import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @requir...
186
'''simple docstring''' from __future__ import annotations import math UpperCAmelCase__ = '''2020.9.26''' UpperCAmelCase__ = '''xcodz-dot, cclaus, dhruvmanila''' def UpperCAmelCase__( _SCREAMING_SNAKE_CASE : float,_SCREAMING_SNAKE_CASE : float,_SCREAMING_SNAKE_CASE : fl...
186
1
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) fr...
504
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path UpperCAmelCase : List[str] =Path(__file__).resolve().parents[3] / """src""" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import...
504
1
def SCREAMING_SNAKE_CASE ( lowercase_ ) -> int: """simple docstring""" if not isinstance(lowercase_ , lowercase_ ): raise TypeError('''Input value must be an \'int\' type''' ) A__ = 0 while number: position += 1 ...
87
from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): from ..models.auto.mo...
105
0
import fire from utils import calculate_rouge, save_json def lowerCamelCase( a__ ,a__ ,a__=None ,**a__): _SCREAMING_SNAKE_CASE =[x.strip() for x in open(a__).readlines()] _SCREAMING_SNAKE_CASE =[x.strip() for x in open(a__).readlines()][: len(a__)] _SCREAMING_SNAKE_CASE =calcu...
705
from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig snake_case_ : List[Any] = logging.get_logger(__name__) snake_case_ : Optional[Any] = '''T5Config''' cla...
191
0
import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyazr, require_zstandard ...
20
from PIL import Image def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ) -> Image: def brightness(__lowerCAmelCase ) -> float: return 128 + level + (c - 128) if not -2_5_5.0 <= level <= 2_5_5.0: raise Va...
228
0
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_ima...
448
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCamelCase : Dict = logging.get_logger(__name__) __lowerCamelCase : Union[str, Any] = { """xlm-mlm-e...
448
1
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging __a = logging.get_logger(__name__) __a = { '''google/umt5-small''': '''https://huggingface.co/google/umt5-small/resolve/main/config.json''', ...
319
import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTesterMixin __a = get...
319
1
"""simple docstring""" import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a : """simple docstring""" def __init__( self: int ): """simple docstring""" A__ ...
705
"""simple docstring""" from collections.abc import Callable def _snake_case ( UpperCAmelCase_ : Callable[[float], float] , UpperCAmelCase_ : float , UpperCAmelCase_ : float ): A__ = a A__ = b if function(UpperCAmelCase_ )...
500
0
class _lowercase : """simple docstring""" def __init__( self , UpperCAmelCase ): '''simple docstring''' _lowercase = arr.split(""",""" ) def _UpperCAmelCase ( self ): '''simple docstring''' ...
398
from string import ascii_uppercase A_: int = {char: i for i, char in enumerate(ascii_uppercase)} A_: Optional[Any] = dict(enumerate(ascii_uppercase)) def __lowerCAmelCase ( _A ,_A ): """simple docstring""" _lowercase = len(_A ) _lowercase...
398
1
"""simple docstring""" import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerat...
258
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __magic_name__ = { """configuration_ctrl""": ["""CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CTRLConfig"""], """tokenization_ctrl""": ...
258
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a : List[Any] = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: i...
273
"""simple docstring""" from collections import deque class lowercase: def __init__( self , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> None: """simple docstring""" a__ = process_name # process nam...
273
1
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable a = { 'configuration_gpt_neox_japanese': ['GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTNeoXJapaneseCo...
347
'''simple docstring''' import numpy as np def a_ ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ) -> Tuple: """simple docstring""" snake_case: ...
347
1
"""simple docstring""" import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging _lowerCAmelCase :Union[str, Any] = logging.get_logger(__name__) class _UpperCAmelCase ( a ): ...
506
"""simple docstring""" import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from acc...
506
1
"""simple docstring""" from __future__ import annotations from math import gcd def lowercase ( UpperCamelCase : int , UpperCamelCase : int = 2 , UpperCamelCase : int = 1 , UpperCamelCase : int = 3 , ): """simple docstring""" # A val...
704
"""simple docstring""" import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL __A : Optional[Any] = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") def lo...
595
0
def UpperCAmelCase_ ( __UpperCAmelCase : int = 10 , __UpperCAmelCase : int = 10_00 , __UpperCAmelCase : bool = True ) -> int: assert ( isinstance(__UpperCAmelCase , __UpperCAmelCase ) and isinstance(__UpperCAmelCase , __U...
31
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase = 600851475143 ): """simple docstring""" try: lowerCAmelCase__ : Union[str, Any] = int(UpperCamelCase ) except (TypeError, ValueError): raise TypeError("""Parameter n must be int or...
565
0
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def lowerCAmelCase__ ( ) -> str: import os as original_os from os import path as original_path from os import rename as original_rename ...
718
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCamelCase_ = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available(): ra...
599
0
"""simple docstring""" import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class A__ ( unittest.TestCase): """simple docstring""" ...
222
"""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 __lowerCamelCase :Union[str, Any] = logging.get_logger(__name__) __lo...
222
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _a : List[Any] = logging.get_logger(__name__) _a : List[Any] = { 'google/vivit-b-16x2-kinetics400': ( 'https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json' ...
717
import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBertForMaskedLM, Dist...
571
0
import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline 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_GUI...
36
'''simple docstring''' import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_commo...
11
0
"""simple docstring""" def _snake_case ( _snake_case : list , _snake_case : list , _snake_case : int , _snake_case : int , _snake_case : int ) -> int: '''simple docstring''' ...
505
"""simple docstring""" import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import...
505
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 SequenceFea...
31
from __future__ import annotations import requests def SCREAMING_SNAKE_CASE ( lowercase_ ) -> dict: """simple docstring""" A__ = f"""https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty""" return requests.get(lowercase_ ).json() def...
87
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor lowercase__ = logging.get_logger(__name__) class A_ ( __UpperCAmelCase ): '''simple docstring''' def __init__( self : Union...
717
'''simple docstring''' from datetime import datetime import requests def UpperCamelCase( UpperCAmelCase_ ): UpperCAmelCase : Tuple = 'https://downloadgram.net/wp-json/wppress/video-downloader/video?url=' UpperCAmelCase : List[str] = requests.get(base_url + url ).js...
695
0
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path ...
571
"""simple docstring""" def UpperCAmelCase ( A : int , A : int ): '''simple docstring''' return int((input_a, input_a).count(1 ) != 0 ) def UpperCAmelCase ( ): '''simple docstring''' assert or_gate(0 , 0 ...
573
0
'''simple docstring''' import inspect import unittest from transformers import MobileNetVaConfig 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_commo...
187
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : Optional[int] = logging.get_logger(__name__) __A...
187
1
from __future__ import annotations from collections.abc import Sequence from typing import Literal def UpperCamelCase__ ( lowerCAmelCase__ ,lowerCAmelCase__ ): lowercase = list(lowerCAmelCase__ ) lowercase = list(lowerCAmelCase__ ) lowercase = 0 for...
428
from __future__ import annotations import math def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" if depth < 0: raise ValueError('''Depth cannot be less ...
43
0
'''simple docstring''' import math def _A ( A ,A ) -> int: lowercase : Tuple = len(A ) lowercase : Union[str, Any] = int(math.floor(math.sqrt(A ) ) ) lowercase : Tuple = 0 while arr[min(A ,A ) - 1] < x: low...
425
'''simple docstring''' import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# lowerCAmelCase : Optional[int] = [ # (stable-diffusion, HF Diffusers) ("""time_embed.0.w...
425
1
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging UpperCAmelCase__ = logging.get_logger(__name__) def _a ( a :str ) -> Tuple: a = r'''\w+[.]\d...
117
class snake_case_ : '''simple docstring''' def __init__( self : Dict , __lowerCamelCase : int , __lowerCamelCase : Optional[Any]=None , __lowerCamelCase : Optional[Any]=None ) -> Dict: '''simple docstring''' ...
375
0
import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass # Copied from diffusers.schedul...
679
from __future__ import annotations __magic_name__ = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def UpperCAmelCase__( __UpperCAmelCase : list[list[int]] , __UpperCAmelCase : list[int] , __UpperCAmelCase : list[int] ...
679
1
import unittest from transformers import DebertaVaConfig, 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 ModelTesterMixin, ids_ten...
86
import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class _a ( snake_case_ ): """simple docstring""" _lowerCamelCase : Optional[Any] = (DDPMParallelScheduler,) def __A ( self ...
86
1
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor __SCREAMING_SNAKE_CASE : Optional[Any] =logging.get_logger(__name__) class A_ ( _A ): def __init__( self : Tuple , *snake_case__ : ...
709
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken ...
72
0
"""simple docstring""" import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": __A = argparse.ArgumentParser() parser.add_argument("--dump_p...
134
'''simple docstring''' import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow lowercase__ =False class a_ ( unittest.TestCase ): def lowerCAmelC...
263
0
"""simple docstring""" from __future__ import annotations from typing import Any def lowerCamelCase__ ( _lowerCamelCase : list ) -> int: if not postfix_notation: return 0 lowerCamelCase_ = {'+', '-', '*', '/'} lowerCamelCase_ = ...
711
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase : List[Any] ) -> str: # noqa: E741 lowerCamelCase_ = len(_lowerCamelCase ) lowerCamelCase_ = 0 lowerCamelCase_ = [0] * n lowerCamelCase_ = [False] * n lowerCamelCase_ ...
137
0
"""simple docstring""" import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def ...
677
"""simple docstring""" import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch Upp...
677
1
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance UpperCAmelCase_ = 6_37_81_37.0 UpperCAmelCase_ = 6_35_67_52.31_42_45 UpperCAmelCase_ = 6_37_81_37 def SCREAMING_SNAKE_CASE ( a_ : ...
490
'''simple docstring''' def SCREAMING_SNAKE_CASE ( a_ : int , a_ : int ): return int((input_a, input_a).count(0 ) != 0 ) def SCREAMING_SNAKE_CASE ( ): assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 a...
490
1
"""simple docstring""" from __future__ import annotations from typing import Any class UpperCAmelCase_ : def __init__( self : Any , A : int = 6 ): _UpperCAmelCase : Node | None = None _UpperCAmelCase : Node | Non...
289
"""simple docstring""" import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel _lowerCAmelCase : Any = HfApi() _lowerCAmelCase : int = {} # fmt: off _lowerCAmelCase : List[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_...
289
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase_ : int = { '''configuration_transfo_xl''': ['''TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TransfoXLConfig'''], ...
703
"""simple docstring""" from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax ...
295
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __A = { 'configuration_mobilebert': [ 'MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MobileBertConf...
484
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType __A = logging.get_logge...
484
1
"""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_mvp import Mv...
704
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE : Optional[int] = {"""configuration_van""": ["""VAN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """VanConfig"""]} ...
229
0
from ..utils import DummyObject, requires_backends class UpperCAmelCase ( metaclass=__snake_case ): a: Optional[int] = ["onnx"] def __init__( self: int , *__UpperCamelCase: Tuple , **__UpperCamelCase: str ): requires_backends(sel...
487
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.huggingfac...
487
1
import baseaa def UpperCamelCase_ ( lowerCAmelCase__ ): """simple docstring""" return baseaa.aaaencode(string.encode("utf-8" ) ) def UpperCamelCase_ ( lowerCAmelCase__ ): """simple docstring""" return baseaa.aaadecode(A_ ).decode("utf-8" ...
710
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_diffusion_safe imp...
587
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCAmelCase : Dict = logging.get...
567
"""simple docstring""" from math import factorial UpperCAmelCase : Tuple = {str(d): factorial(d) for d in range(10)} def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> int: '''simple docstring''' return sum(DIGIT_FACTORIAL[d] for d in str(__lowerCAmelCa...
567
1
'''simple docstring''' import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model...
715
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _UpperCamelCase ( _a : NDArray[floataa] , _a : NDArray[floataa] , _a : list[int] , _a : int , ): """simple docstring""" __Up...
287
0
import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # noqa: F401 # Here to have ...
85
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class snake_case ( UpperCamelCase_ ): lowercase_ = ['image_processor', 'tokenizer'] lowercase_ = 'AutoImageProcessor' lowercase_ = 'AutoTokenizer' def __init__( self ...
85
1
"""simple docstring""" def UpperCAmelCase ( A__: list[list] ) -> list[list]: __lowerCamelCase : List[Any] = current_set.copy() for row_index, row in enumerate(A__ ): __lowerCamelCase : Dict = row[0] for column_index, column in enumerate(A__ ...
263
"""simple docstring""" def UpperCAmelCase ( A__: Dict ) -> Optional[int]: stooge(A__ , 0 , len(A__ ) - 1 ) return arr def UpperCAmelCase ( A__: Dict , A__: List[str] , A__: Optional[int] ) -> Any: if i >= ...
263
1
'''simple docstring''' import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness __lowerCAmelCase ="\\n@misc{chen2021evaluating,\n title={Evaluating...
697
'''simple docstring''' from argparse import ArgumentParser from . import BaseTransformersCLICommand def a ( _UpperCAmelCase ) -> int: """simple docstring""" return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) ...
697
1
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common...
692
'''simple docstring''' def lowerCAmelCase_ ( __A : int = 1_00 ): '''simple docstring''' snake_case: List[str] = n * (n + 1) * (2 * n + 1) / 6 snake_case: List[Any] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) ...
692
1
'''simple docstring''' import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_v...
18
'''simple docstring''' import numpy as np class __a : def __init__( self : Optional[int] ): '''simple docstring''' __SCREAMING_SNAKE_CASE = (0, 0) __SCREAMING_SNAKE_CASE = None __SCREAMING_SNAKE_CASE = 0 __SCR...
109
0
'''simple docstring''' import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm mus...
27
'''simple docstring''' from __future__ import annotations def lowerCamelCase ( lowerCamelCase : dict , lowerCamelCase : str): A_ , A_ : List[Any] = set(lowerCamelCase), [start] while stack: A_ : Optional[Any] =...
27
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
70
from maths.prime_check import is_prime def _SCREAMING_SNAKE_CASE ( lowercase : int ): '''simple docstring''' if not isinstance(lowercase , lowercase ): lowerCamelCase_ = f"""Input value of [number={number}] must be an integer""" ...
70
1
import numpy class UpperCAmelCase__ : def __init__( self , A__ , A__ ): """simple docstring""" UpperCAmelCase_: Optional[Any] = input_array # Random initial weights are assigned where first argument is the # number of nodes in previous layer an...
704
from __future__ import annotations _lowerCAmelCase = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _lowerCAmelCase = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def lowercase ( _a ) -> list[float]: UpperCAmelCase_: Dict = [] U...
306
0
def a__ ( A__, A__ ): SCREAMING_SNAKE_CASE_ : Dict = len(A__ ) + 1 SCREAMING_SNAKE_CASE_ : List[str] = len(A__ ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # length i of input_string matches with prefix string of len...
101
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 _UpperCamelCase ( unittest.TestCase ): '''simpl...
25
0
import random from .binary_exp_mod import bin_exp_mod def lowerCamelCase_ ( _lowercase , _lowercase=1_000 ) -> Tuple: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __A : int = n - 1 __A : int ...
705
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers.model...
387
0
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaXLForSequenceClassi...
74
"""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 __lowerCamelCase ...
96
0
'''simple docstring''' def UpperCAmelCase_ ( A , A , A=False ): '''simple docstring''' if isinstance(A , A ) and isinstance(A , A ): _a : str = len(set_a.intersection(A ) ) if alternative_union: _a : str = len(...
716
'''simple docstring''' from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar UpperCAmelCase_ : str = TypeVar("T") class a ( Generic[T] ): '''simple docstring''' __lowerCAmelCase : deque[T] # Cache store of keys ...
424
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCamelCase = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available(): raise OptionalDep...
45
'''simple docstring''' import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def A ( UpperCamelCase_ : Optional[int] , UpperCamelCase_ ...
48
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase_ = { "configuration_biogpt": ["BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "BioGptConfig"], "tokenizatio...
704
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { "distil...
490
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _SCREAMING_SNAKE_CASE : str = {'''configuration_van''': ['''VAN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''VanConfig''']} try: if not is_torch_available(): ...
493
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor _SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(__name__) class UpperCAmelCase__ ( A__ ): """simple docstring""" def __init__( self : List[Any] , *__lowe...
493
1
'''simple docstring''' import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK_RECO...
718
'''simple docstring''' import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import tensorflow as tf f...
454
0
'''simple docstring''' import copy import re class SCREAMING_SNAKE_CASE : """simple docstring""" _SCREAMING_SNAKE_CASE = """hp""" _SCREAMING_SNAKE_CASE = {} _SCREAMING_SNAKE_CASE = None @classmethod ...
430
'''simple docstring''' from math import factorial def __lowerCamelCase ( A__ , A__ , A__ ) -> float: """simple docstring""" if successes > trials: raise ValueError('successes must be lower or equal to trials' ) if ...
430
1
from __future__ import annotations __lowerCAmelCase : int = '#' class snake_case__ : """simple docstring""" def __init__( self : Optional[Any] ) -> None: a = {} def __UpperCAmelCase ( self : Tuple , __lowe...
710
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _in...
662
0
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_avai...
23
import random from .binary_exp_mod import bin_exp_mod def _A ( __snake_case :List[Any] , __snake_case :Union[str, Any]=1000 ) -> int: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __...
693
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tenso...
706
import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import floats_tensor, is_xformers_available...
604
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase :Optional[Any] = logging.get_logger(__name__) lowerCamelCase :List[Any] = { '''RWKV/rwkv-4-169m-pile''': '''https://huggingface.co/RWKV/rwkv-4-169m-pi...
667
'''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 cla...
667
1
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 ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _A = ...
712
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, AutoTokenizer, ...
279
0
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_to...
558
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class UpperCAmelCase ( __A ...
558
1
import numpy as np from PIL import Image def __UpperCAmelCase ( snake_case_ : np.ndarray , snake_case_ : int , snake_case_ : int ): '''simple docstring''' UpperCAmelCase: List[str] = np.array(snake_case_ ) if arr.shape[...
166
def __UpperCAmelCase ( snake_case_ : int = 6_0_0_8_5_1_4_7_5_1_4_3 ): '''simple docstring''' try: UpperCAmelCase: Optional[int] = int(snake_case_ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) i...
166
1
"""simple docstring""" import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def A_ ( snake_case__ , snake_case__=1 ) -> Optional[int]: if n_shave_prefix_segments >= 0: return ".".join(path.split('''.''' )[n_sh...
355
"""simple docstring""" from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class A( lowerCamelCase__ ): """simple docstring""" def _UpperCamelCase( self , SCREAMING_SNAKE_CASE__ ) -> float...
355
1
"""simple docstring""" import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _A = object() # For specifying empty leaf dict `{}` _A = object() def...
720
"""simple docstring""" import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( Pro...
538
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = { 'configuration_roberta': ['ROBERTA_PRETRAINED_CON...
625
"""simple docstring""" def snake_case_ ( A_ : list, A_ : list, A_ : int, A_ : int, A_ : int ): '''simple docstring''' if index == number_of_items: return 0 _lowerCamelCase : int = ...
83
0
"""simple docstring""" from collections.abc import Callable import numpy as np def a__ ( __lowercase , __lowercase , __lowercase , __lowercase , __lowercase ) -> np.array: _A = int(np.ceil((x_end - xa) / step_size ) ) _A = np.zer...
621
"""simple docstring""" import random def a__ ( __lowercase , __lowercase , __lowercase ) -> Optional[Any]: _A = a[left_index] _A = left_index + 1 for j in range(left_index + 1 , __lowercase ): if a[j] < pivot: _A ...
621
1