code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase : Any = logging.get_logger(__name__) UpperCAmelCase : List[Any] =...
115
"""simple docstring""" def lowerCamelCase ( _UpperCamelCase : float , _UpperCamelCase : float , _UpperCamelCase : int ) -> float: '''simple docstring''' if principal <= 0: raise Exception("""Principal borrowed must be...
115
1
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_...
350
from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import...
14
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _snake_case = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: _snake...
36
'''simple docstring''' import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging _lowerCamelCase : Union[str, Any] = "\\n\n" _lowerCamelCase : List[str] ...
28
0
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_...
358
'''simple docstring''' # DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.co...
227
0
import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configu...
103
'''simple docstring''' import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class lowercase ( A__ ): ""...
97
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch ...
20
import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPR_CONTEXT_ENCODER_...
20
1
import random class UpperCAmelCase : '''simple docstring''' @staticmethod def __magic_name__ ( lowerCAmelCase_ : str ): """simple docstring""" _A: Union[str, Any] = [ord(__lowercase ) for i in text] _A: str = [] _A: Optio...
121
def lowerCamelCase__ ( __lowerCamelCase : Tuple , __lowerCamelCase : Union[str, Any] ): __UpperCAmelCase : Tuple = [1] for i in range(2 , __lowerCamelCase ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k out of b...
114
0
"""simple docstring""" import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_avail...
241
"""simple docstring""" from collections.abc import Iterable from typing import Generic, TypeVar lowerCamelCase = TypeVar("""_T""") class lowercase__ ( Generic[_T] ): '''simple docstring''' def __init__( self : int , _Up...
241
1
"""simple docstring""" def A ( snake_case :int ) -> int: __UpperCamelCase = [1] __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 0, 0, 0 __UpperCamelCase = ugly_nums[ia] * 2 __UpperCamelCase = ugly_nums[ia] * 3 __UpperCamelCase ...
316
"""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 __lowerCAmelCase ( __SCREAMING_SNAKE_...
316
1
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _lowerCAmelCase : ...
298
"""simple docstring""" import inspect import unittest from transformers import DecisionTransformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTest...
298
1
import os import re import shutil import sys import tempfile import unittest import black UpperCAmelCase_ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_copies # noqa: E402 # This is the reference code...
12
import os from distutils.util import strtobool def __lowercase ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Tuple: '''simple docstring''' for e in env_keys: SCREAMING_SNAKE_CASE = int(os.environ.get(_SCREAMING_SNAKE_CASE , -1 ) )...
296
0
import unittest from knapsack import knapsack as k class UpperCamelCase ( unittest.TestCase ): def __A ( self ): A__ = 0 A__ = [0] A__ = [0] A__ = len(UpperCAmelCase__ ) self.assertEqual(k...
356
from __future__ import annotations from random import random class UpperCamelCase : def __init__( self , UpperCAmelCase__ = None ): A__ = value A__ = random() A__ = None A__ = None def __repr__( self )...
198
0
'''simple docstring''' def __lowerCamelCase ( __snake_case : Dict, __snake_case : List[Any], __snake_case : Union[str, Any], __snake_case : Tuple, __snake_case : List[str], __snake_case : List[str] ) -> List[Any]: """simple docstring"""...
134
'''simple docstring''' from graphs.minimum_spanning_tree_kruskal import kruskal def __lowerCamelCase ( ) -> int: """simple docstring""" A__ : int =9 A__ : int =[ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7,...
134
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = {'configuration_deit': ['DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP',...
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor __UpperCAmelCase = logging.get_logger(__name__) class _SCREAMING_SNAKE_CASE ( A__ ): def __init__( self , *__A , ...
1
1
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' __lowerCamelCase : Union[str, Any] = "EncodecFeatureExtractor...
116
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE_:str = { """configuration_transfo_xl""": ["""TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TransfoXLConfig"""], """tokenization_tr...
116
1
'''simple docstring''' from __future__ import annotations from random import random class A : def __init__( self , SCREAMING_SNAKE_CASE = None ) -> Tuple: """simple docstring""" A : Optional[Any] = ...
311
'''simple docstring''' import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py lowercase : Any = 'src/transform...
311
1
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py lowerCamelCas...
47
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer _UpperCamelCase = {'''vocab_file''': '''vocab.txt''', '''tokenizer_f...
254
0
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_util...
249
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Tuple = { "configuration_convnext": ["CONVNEXT_PRE...
249
1
"""simple docstring""" # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for test...
98
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def _snake_case ( _snake_case : list[list[float]] ): lowerCAmelCase : str = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implement...
60
0
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_t...
350
"""simple docstring""" def _A ( ): """simple docstring""" return [list(range(1_0_0_0 - i , -1_0_0_0 - i , -1 ) ) for i in range(1_0_0_0 )] UpperCAmelCase =generate_large_matrix() UpperCAmelCase =( [[4, 3, 2, -1], [3, ...
77
0
"""simple docstring""" import math def _snake_case ( UpperCAmelCase_ : float , UpperCAmelCase_ : float ): if initial_intensity < 0: raise ValueError("""The value of intensity cannot be negative""" ) # handling of negative values of ini...
335
"""simple docstring""" import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC SCREAMING_SNAKE_CASE_ : str = parse(importlib.metadata.version('torch')) def _snake_case ( Uppe...
335
1
"""simple docstring""" import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging log...
271
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, At...
271
1
"""simple docstring""" import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_...
160
"""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 fr...
160
1
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py SCREAMING_SNAKE_CASE_:List[Any] ...
360
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 import FlaxGenerationTesterMixin ...
115
0
"""simple docstring""" from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerat...
109
"""simple docstring""" import functools from typing import Any def _snake_case ( lowercase__ , lowercase__ ): # Validation if not isinstance(lowercase__ , lowercase__ ) or len(lowercase__ ) == 0: raise ValueError('the string shou...
96
0
'''simple docstring''' def _lowercase ( __A = "The quick brown fox jumps over the lazy dog" ,): '''simple docstring''' __UpperCamelCase = set() # Replace all the whitespace in our sentence __UpperCamelCase = input_str.replace(""" """ ,"""""" ) f...
243
'''simple docstring''' def _lowercase ( __A ): '''simple docstring''' if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
243
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer a__: Optional[int] = logging.get_logger(__name__) a_...
193
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase__( UpperCamelCase__ : Any , UpperCamelCase__ : int , UpperCamel...
193
1
import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig from transformers.models.bar...
360
'''simple docstring''' from __future__ import annotations class __lowerCamelCase : """simple docstring""" def __init__( self : Optional[Any] , SCREAMING_SNAKE_CASE : Tuple=None): _A : Any = data _A : Optional[Any] =...
227
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_di...
257
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any =logging.get_logger(__name__) lowerCAmelCase__ : str ={ '''microsoft/unispeech-sat-base-100h-libri-ft''': ( '''https://huggingfac...
257
1
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> "list[int]": if upper_limit < 0: raise ValueError('Limit for the Catalan sequence must be ≥ 0' ) __lowerCamelCase : List[str] = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 __lowerCamelCase : Dict = 1 ...
113
import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py a ="""src/transformers""" a ="""docs/source/en""" ...
113
1
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __magic_name__ ( __a : bytes , __a : int ): '''simple docstring''' UpperCamelCase__ = f"{sampling_rate}" UpperCamelCase__ = ""...
244
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import GenerationTeste...
244
1
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { '''nielsr/canine-s''': 20_48, } # Unicode d...
62
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase_ : int = { '''microsoft/swinv2-tiny-patch4-window8-256''': ( '''https://huggingface.co/microsoft/swinv2-tiny-pa...
62
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE ( metaclass=a_ ): """simple docstring""" lowercase__ = ["speech"] def __init__( self : Tuple ,*lowercase_ : Tuple ,**lowercase_ ...
106
"""simple docstring""" __A : Any = { '''Pillow''': '''Pillow''', '''accelerate''': '''accelerate>=0.11.0''', '''compel''': '''compel==0.1.8''', '''black''': '''black~=23.1''', '''datasets''': '''datasets''', '''filelock''': '''filelock''', '''flax''':...
33
0
"""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_...
182
"""simple docstring""" lowerCamelCase__ = """0.21.0""" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader imp...
182
1
def a ( A__ : int ) -> bool: """simple docstring""" return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
205
import argparse import json import os 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 accelerat...
205
1
def lowerCAmelCase_ ( UpperCamelCase_ ) -> int: UpperCamelCase_ = len(UpperCamelCase_ ) UpperCamelCase_ = len(matrix[0] ) UpperCamelCase_ = min(UpperCamelCase_ , UpperCamelCase_ ) for row in range(UpperCamelCase...
361
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCAmelCase = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'], } try: if not i...
328
0
import unittest from transformers import BertGenerationConfig, 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...
128
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling_roberta_series import ...
128
1
def a__ ( UpperCAmelCase : int ): UpperCAmelCase : int = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def a__ ( UpperCAmelCase : int = 5_000 ): UpperCAmelCase : int = [(i * (3 * i - 1)) // 2 for i in range(1 , UpperCAm...
350
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common imp...
99
0
'''simple docstring''' 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...
164
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __A = { "configuration_blip": [ "BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "BlipConfi...
164
1
"""simple docstring""" # This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def lowerCAmelCase (__UpperCam...
85
"""simple docstring""" import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowerCAmelCase (__UpperCamelCase : int ): """simple docstring""" __UpperCamelCase =FileLock(str(tmpdir / '''foo.lock''' ) ) __UpperCamelCase =F...
85
1
import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available, loggi...
24
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, Tens...
53
0
"""simple docstring""" import collections import os import re from pathlib import Path UpperCAmelCase__ = """src/transformers""" # Matches is_xxx_available() UpperCAmelCase__ = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} UpperCAmelCase__ ...
30
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { """Visual-Attention-Network/van-base""": ( """https://huggingface.co/Visual-Attention-Network/van-base/blo...
30
1
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the r...
209
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, ...
209
1
import os import pytest from transformers.dynamic_module_utils import get_imports _A = "\nimport os\n" _A = "\ndef foo():\n import os\n return False\n" _A = "\ndef foo():\n def bar():\n if True:\n import os\n return False\n return bar()\n" _A = ...
371
from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { "google/realm-cc-news-pretrained-embedder": ( "https://huggingface.co/google/realm-cc-news-pretrained-embedder/resolve/main/config.json" ), "google/realm-c...
137
0
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class A__ : """simple docstring""" def __init__( self , lowercase = None) -> Dict: '''simple docstring''' if components...
99
"""simple docstring""" import os from typing import Dict, List, Tuple, TypeVar, Union UpperCAmelCase : Union[str, Any] = TypeVar("T") UpperCAmelCase : Dict = Union[List[T], Tuple[T, ...]] UpperCAmelCase : int = Union[T, List[T], Dict[str, T]] UpperCAmelCase : ...
136
0
'''simple docstring''' import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration...
55
'''simple docstring''' from __future__ import annotations def a_ ( lowerCamelCase : list[float] , lowerCamelCase : list[float] ): lowerCAmelCase = sorted(numsa + numsa ) lowerCAmelCase , lowerCAmelCase = divmod(len(lowerCamelCas...
55
1
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenize...
58
'''simple docstring''' 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, ) lowercase_ = {"""configuration_mbart""": ["...
58
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _a = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], ...
100
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { """microsoft/biogpt""": """https://huggingface.co/microsoft/biogpt/resolve/main/config.json""", # See all BioGPT mo...
100
1
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class _UpperCamelCase ( UpperCamelCase__ ): def __init__( self :Optional[Any] , lowerCamelCase :Optional[Any] , lowerCamelCase :Optional[Any] ) -> Dict: Upp...
169
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from tra...
95
0
"""simple docstring""" import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def lowerCAmelCase_( *lowercase_ : Tuple , lowercase_ : Tuple = None , lowercase_ : Tuple=True , lowercase_ : List[...
366
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_f...
73
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE : Dict = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Union[str, Any] ...
21
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_...
21
1
import warnings from ..trainer import Trainer from ..utils import logging _UpperCAmelCase : List[Any] = logging.get_logger(__name__) class lowerCAmelCase ( __UpperCamelCase ): def __init__( self : Optional[int] , UpperCAmelCase : str=None , **Up...
45
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : int = { """configuration_bigbird_pegasus""": [ """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BigBirdPegasusConfig""", ""...
45
1
'''simple docstring''' from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class _snake_case : lowerCAmelCase_ : torch.Tensor # [batch_size x 3] lowerCAmelCase_ : torch.Tensor # [batch_size x 3] lowerCAmelCase_ : to...
85
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _SCREAMING_SNAKE_CASE : int = { ...
85
1
"""simple docstring""" from queue import PriorityQueue from typing import Any import numpy as np def __SCREAMING_SNAKE_CASE ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ...
352
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput ...
336
0
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, ...
334
'''simple docstring''' def UpperCAmelCase ( a_ = 1_0_0 ) -> int: """simple docstring""" A_ : Dict = n * (n + 1) * (2 * n + 1) / 6 A_ : Optional[int] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __n...
344
0
"""simple docstring""" import numpy as np def UpperCamelCase_ ( lowerCAmelCase__ : Optional[int] , lowerCAmelCase__ : int , lowerCAmelCase__ : Optional[Any] , lowerCAmelCase__ : Optional[Any] , lowerCAmelCase__ : Dict )...
289
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) lowercase__ : Optional[int] = { """configuration_...
289
1
'''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 specifi...
223
'''simple docstring''' import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slo...
223
1
"""simple docstring""" def _A ( _a : List[Any] , _a : List[str] ): """simple docstring""" if discount_rate < 0: raise ValueError("""Discount rate cannot be negative""" ) if not cash_flows: raise ValueError(...
363
"""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__ ( SC...
77
0
'''simple docstring''' import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAP...
85
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetYaagf, RegNetYaagf, R...
59
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase_ = { 'configuration_ctrl': ['CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CTRLConfig'], 'tokenization_ctrl': ['CTRLTokenizer'], } ...
359
"""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 i...
303
0
def UpperCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ ): '''simple docstring''' return int(input_a == input_a == 0 ) def UpperCamelCase ( ): '''simple docstring''' print('''Truth Table of NOR Gate:''' ) print('''| Input 1 | Input 2 | Output |'''...
101
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_image, load_n...
219
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from ...
364
'''simple docstring''' from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class __magic_name__ : lowerCAmelCase : str = field( ...
107
0
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_channel_dim...
327
import sys _SCREAMING_SNAKE_CASE = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" """6...
327
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) SCREAMING_SNAKE_CASE_ : Optional[Any] = { ...
69
"""simple docstring""" from pathlib import Path import fire from tqdm import tqdm def _snake_case ( UpperCAmelCase_ : int="ro" , UpperCAmelCase_ : Optional[int]="en" , UpperCAmelCase_ : List[Any]="wmt16" , UpperCAmelCase_ : str=None ): ...
69
1
def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ) -> bool: # 1. Validate that path exists between current and next vertices if graph[path[curr_ind - 1]][next_ver] == 0: return False # 2. Validate that nex...
50
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast UpperCAmelCase : Union[str, Any] = datasets.utils.logging.get_logger(__name__) @dataclass class __low...
252
0
"""simple docstring""" from __future__ import annotations import typing from collections.abc import Iterable import numpy as np lowercase_ = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 lowercase_ = typing.Union[np.floataa, int, float] # noqa: ...
354
"""simple docstring""" from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline lowercase_ ...
11
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, AutoModelForQue...
184
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization...
34
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch ...
370
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProc...
26
0
"""simple docstring""" import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeqLogg...
165
"""simple docstring""" import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class lowerCamelCase (nn.Module ): lowerCamelCase__ : int lowerCame...
165
1
def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : int , __UpperCamelCase : int ) -> int: """simple docstring""" return int(input_a == input_a == 0 ) def __SCREAMING_SNAKE_CASE ( ) -> None: """simple docstring""" p...
204
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils imp...
204
1
from __future__ import annotations def UpperCAmelCase__ ( lowerCamelCase ): if not nums: return 0 lowercase :Union[str, Any] = nums[0] lowercase :Union[str, Any] = 0 for num in nums[1:]: lowercase , lowercase :Any = ( max_excluding + num, ...
236
import numpy # List of input, output pairs _UpperCAmelCase : List[str] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) _UpperCAmelCase : Optional[Any] = (((515, 22, 13), 555), ((61, 35, 49), 150)) _UpperCAmelCase : Tuple = [2, 4, 1, 5...
236
1
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets a : int = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass clas...
150
"""simple docstring""" import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import Auto...
150
1
"""simple docstring""" def _lowerCAmelCase ( lowercase_ , lowercase_ = " " ): UpperCAmelCase = [] UpperCAmelCase = 0 for index, char in enumerate(lowercase_ ): if char == separator: split_words.append(string[l...
78
"""simple docstring""" from __future__ import annotations def _lowerCAmelCase ( lowercase_ , lowercase_ , lowercase_ ): UpperCAmelCase = list(range(len(lowercase_ ) ) ) UpperCAmelCase = [v / w for v, w in zip(lowercase_ , lowercase_ ...
78
1
"""simple docstring""" import argparse import logging import pickle from collections import Counter logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO ) __UpperCamelCase = logging.getLogger(__n...
357
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __UpperCamelCase = { '''configuration_mvp''': ['''MVP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MvpConfig''', '''MvpOnnxCon...
38
0
"""simple docstring""" import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available...
261
"""simple docstring""" import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def _lowerCamelCase( a ...
261
1
'''simple docstring''' from cva import destroyAllWindows, imread, imshow, waitKey def lowercase__ ( __UpperCamelCase )-> Tuple: # getting number of pixels in the image UpperCamelCase ,UpperCamelCase = img.shape[0], img.shape[1] # converting each p...
368
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) ...
183
0
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
4
"""simple docstring""" import requests UpperCAmelCase__ = """""" # <-- Put your OpenWeatherMap appid here! UpperCAmelCase__ = """https://api.openweathermap.org/data/2.5/""" def __UpperCAmelCase ( lowercase = "Chicago" ,lowercase = APPID ): """simple docstring""" ...
289
0
from __future__ import annotations from collections.abc import Generator def __lowerCamelCase ( ): '''simple docstring''' lowerCamelCase = {} lowerCamelCase = 2 while True: lowerCamelCase = factor_map.pop(lowerCamelCase_ , low...
367
import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice...
66
0
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : str ) ->str: '''simple docstring''' return " ".join( "".join(word[::-1] ) if len(_lowercase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__":...
105
"""simple docstring""" def _UpperCAmelCase ( __lowerCamelCase : list , __lowerCamelCase : int = 0 ) -> list: _snake_case = length or len(__lowerCamelCase ) _snake_case = False for i in range(length - 1 ): if list_data[i] > lis...
288
0
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": lowercase_ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned' ' Distillatio...
369
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : str = 0 __lowerCamelCase : Tuple = len(SCREAMING_SNAKE_CASE__ ) for i in range(n - 1 ): for j in range(i + 1 , SCREAMING_SNAKE_CASE__ ): if arr[i] > arr[j]: num_inversions +=...
194
0
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging _snake_case = logging.get_logger(__name__) def A ( _lowerCamelCase , _lowerCamelCase ): '''simple docstr...
36
from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.rob...
36
1
'''simple docstring''' 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 sklea...
184
'''simple docstring''' def _SCREAMING_SNAKE_CASE ( UpperCamelCase = 1000 ): """simple docstring""" lowerCAmelCase__ : Union[str, Any] = -1 lowerCAmelCase__ : Optional[Any] = 0 for a in range(1 , n // 3 ): # Solving the two equa...
184
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config.json""", # See all PEGASUS models at https://h...
140
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) _UpperCAmelCase = models.Sequential() # Step 1 - Convolution #...
140
1
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _lowercase: List[str] = Lock() def a( A , A , A , A , A , A , A ) -> List[str]: """simple docstring""" global pr...
351
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
71
0
A__ : int = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) A__ : List[Any] = frozenset(['prompt', 'negative_prompt']) A_...
207
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def a ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ): '''simple docstring''' lowercase__ = ('''dense.weight''', '''attention.self.query''', ''...
207
1
'''simple docstring''' import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE ...
3
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor,...
3
1
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class SC...
24
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class UpperCAmelCase ( datasets.BuilderConfig ): _l...
70
0
"""simple docstring""" def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): UpperCAmelCase_ = len(lowerCAmelCase__ ) + 1 UpperCAmelCase_ = len(lowerCAmelCase__ ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefi...
353
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva lowerCamelCase = """""" lowerCamelCase = """""" lowerCamelCase = """""" lowerCamelCase = 1 # (0 is vertical, 1 is horizontal) de...
241
0
'''simple docstring''' from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_imag...
53
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logg...
90
0
"""simple docstring""" from collections import deque def A_ ( _lowerCAmelCase : Any ): """simple docstring""" _a = len(_lowerCAmelCase ) _a = deque() _a = [False for _ in range(_lowerCAmelCase )] _a = [-1 for _ in range...
361
"""simple docstring""" # 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 ...
153
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 if is_tf_available(): import tensorflow as tf from transformers import AutoTokenizer, TFAutoModelForSeqaSeqLM ...
140
import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput _UpperCAmelCase = """scheduler_config.json""" class UpperCAmelCase ( __A ): '''simple docstring'...
140
1
def _a ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ) -> Optional[int]: '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) SCREAMING_SNAKE_CASE__ ...
364
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated _lowerCamelCase : Tuple = collections.namedtuple('''_D...
191
0
print((lambda quine: quine % quine)("print((lambda quine: quine %% quine)(%r))"))
26
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: ...
126
0
def __magic_name__ ( __lowerCAmelCase : list[int] ) -> float: if not nums: # Makes sure that the list is not empty raise ValueError('''List is empty''' ) __lowerCamelCase = sum(__lowerCAmelCase ) / len(__lowerCAmelCase ) # Calculate the a...
339
from collections import namedtuple import requests from lxml import html # type: ignore SCREAMING_SNAKE_CASE__ : List[Any] = namedtuple("covid_data", "cases deaths recovered") def __magic_name__ ( __lowerCAmelCase : str = "https://www.worldometers.info/coronavirus/" ...
339
1
'''simple docstring''' import requests from bsa import BeautifulSoup def snake_case_ (_a : str = "https://www.worldometers.info/coronavirus" ): UpperCAmelCase = BeautifulSoup(requests.get(_a ).text , '''html.parser''' ) UpperCAmelCase = sou...
34
"""simple docstring""" from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState ...
221
0
'''simple docstring''' from __future__ import annotations def a__ ( lowerCAmelCase__ ) -> float: if not nums: raise ValueError('''List is empty''' ) return sum(lowerCAmelCase__ ) / len(lowerCAmelCase__ ) if __name__ == "__main__": import doctest ...
299
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import c...
299
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { '''google/fnet-base''': '''https://huggingface.co/google/fnet-base/resolve/main/config.json''', '''google/fnet-large''': ''...
320
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda ...
259
0
import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weig...
221
import random def _A ( lowerCAmelCase_ : list , lowerCAmelCase_ : List[str] ): """simple docstring""" lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ = [], [], [] for element in data: if element < pivot: ...
221
1
'''simple docstring''' import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() lowercase : List[str] = logging.get_logger(__name__) lowercase : str = {...
3
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase : Union[str, Any] = logging.get_logger(__name__) lowercase : str ...
3
1
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_available...
33
import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import version from .. import __versi...
33
1