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""" from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split snake_case__ : List[str] = datasets.load_iris() snake_case__ : Union[str, Any] = np.array(data['''data''']) snake_case__ : Opt...
60
"""simple docstring""" import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def __UpperCAmelCase ( __lowerCamelCase ) -> Optional[int]: if "model" in orig_key: lowercase__ : Tuple = orig_key.replace('''model.''' ...
16
0
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class Uppe...
354
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowerCamelCase : Union[str, Any] = { """configuration_swiftformer""": [ """SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwiftFormerCon...
231
0
'''simple docstring''' from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_avai...
37
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def __lowercase ( snake_case_ : int ) ->Tuple: '''simple docstring''' if ( (cp >= 0x4e00 and cp <= 0x9fff) or (cp >= ...
179
0
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase = 10**9 ) -> int: '''simple docstring''' lowerCAmelCase : Any = 1 lowerCAmelCase : str = 2 lowerCAmelCase : Union[str, Any] = 0 lowerCAmelCase : Any = 0 lowe...
323
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : Union[str, Any] = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InformerConfi...
323
1
"""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/LI...
332
"""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_available, ...
332
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __A = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mob...
367
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = {} class lowerCamelCase__ ( __magic_name__ ): '''simple docstring''' lowerCamelCase = '''llama''' lowe...
341
0
"""simple docstring""" import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class _lowerCAmelCase ( snake_case_ ): def lowerCamelCase ( self , UpperCamelCase__ ) -> Optional[Any]: '''simple docstring''' wi...
203
"""simple docstring""" def __lowerCAmelCase ( lowercase : list[int] ) -> float: """simple docstring""" if not nums: # Makes sure that the list is not empty raise ValueError("List is empty" ) snake_case : List[str] = sum(lowercase ) / len(lowerca...
203
1
from __future__ import annotations from math import ceil, floor, sqrt def _a ( a :int = 2_000_000 ) -> int: a = [0] a = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_numbers.append(triangle_numbers[-1] + idx ) ...
26
from math import ceil, sqrt def _a ( a :int = 1_000_000 ) -> int: a = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a = max(ceil(sqrt(outer_width**2 - limit ) ) , 1 ) else: a = 1 ...
26
1
'''simple docstring''' def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ) -> Optional[int]: while second != 0: UpperCAmelCase__ : List[Any] = first & second first ^= second UpperCAmelCase__ : Dict = c << 1 ret...
181
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { """google/umt5-small""": """https://huggi...
166
0
'''simple docstring''' import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version _UpperCamelCase = version.parse(importlib_metadata.version('''nltk''')) if NLTK_VERSION >= version.Version('''3.6.4'''): from n...
16
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enab...
16
1
'''simple docstring''' def UpperCamelCase_( snake_case : int ): '''simple docstring''' if not isinstance(snake_case , snake_case ): raise TypeError("only integers accepted as input" ) else: snake_case_ = st...
85
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def UpperCamelCase_( snake_case : Tuple ): '''simple docstring''' snake_case_ = FileLock(str(tmpdir / "foo.lock" ) ) snake_cas...
85
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _a = {"""configuration_speech_encoder_decoder""": ["""SpeechEncoderDecoderConfig"""]} try: if not is_torch_available(...
100
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { """facebook/xlm-rober...
100
1
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 ModelTe...
62
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_images, to_numpy_array, valid_im...
121
0
"""simple docstring""" def _lowerCAmelCase ( UpperCAmelCase__ : list[list] ) ->list[list]: A__ : Tuple = current_set.copy() for row_index, row in enumerate(UpperCAmelCase__ ): A__ : Union[str, Any] = row[0] f...
353
"""simple docstring""" import os from distutils.util import strtobool def _lowerCAmelCase ( UpperCAmelCase__ : List[Any], UpperCAmelCase__ : Optional[Any] ) ->List[str]: for e in env_keys: A__ : List[Any] = int(os.environ.get(UpperCAme...
296
0
"""simple docstring""" import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pi...
81
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : Optional[Any] = { """config...
174
0
'''simple docstring''' import numpy as np class __magic_name__ : def __init__( self) -> Optional[Any]: '''simple docstring''' _UpperCAmelCase : List[str] =(0, 0) _UpperCAmelCase : Any =None ...
367
'''simple docstring''' import datasets from .evaluate import evaluate lowercase ='\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNLP},\n...
242
0
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import Tokeniz...
333
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 accelerate.test_utils ...
333
1
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_SEQUENCE_CLASSIFICATION...
257
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class UpperCamelCase__ ( __SCREAMING_SNAKE_CASE ): """simple docstring""" ...
257
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case =logging.get_logger(__name__) __snake_case ={ """microsoft/biogpt""": """https://huggingface.co/microsoft/biogpt/resolve/main/config.json""", # See all...
4
'''simple docstring''' import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py __snake_case ="""\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, ti...
4
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { "facebook/data2vec-text-base": "https://huggingf...
368
"""simple docstring""" import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCase__ = [ '''word_e...
175
0
"""simple docstring""" import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_t...
268
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin ...
268
1
'''simple docstring''' def _lowerCAmelCase ( lowercase ) -> int: if not numbers: return 0 if not isinstance(lowercase , (list, tuple) ) or not all( isinstance(lowercase , lowercase ) for number in numbers ): raise ValueError("""numbers must...
46
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tenso...
46
1
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> float: if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0.5...
177
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) __A = { "configuration_speecht5": [ "SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP", "SPEECHT5_PRETRAIN...
177
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase = {'''configuration_plbart''': ['''PLBART_PRETRAI...
16
'''simple docstring''' import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from ....
16
1
'''simple docstring''' # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[...
181
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> int: if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(lowerCAmelCase__ , lowerCAmelCase__ ): raise TypeError('''Input value must be a \'int\' type''' ...
181
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pip...
341
"""simple docstring""" from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTest...
341
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_a...
57
"""simple docstring""" from ..utils import DummyObject, requires_backends class a ( metaclass=UpperCAmelCase__ ): UpperCamelCase : Optional[int] = ['torch', 'torchsde'] def __init__( self : Union[str, Any] , *lowerCAmelCase : Any , **lowerCAme...
173
0
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, resize, to_channel_dimen...
176
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import loggi...
176
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor lowerCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple do...
63
'''simple docstring''' from ....utils import logging lowerCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docstring""" def __init__( self : Tuple , __a : int , ...
63
1
'''simple docstring''' import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, ...
55
'''simple docstring''' import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, ...
55
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ : Dict = {"""configuration_...
168
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer import P...
99
0
'''simple docstring''' import os def UpperCAmelCase_ (): """simple docstring""" _a : Any = os.path.dirname(os.path.realpath(__a ) ) _a : Optional[int] = os.path.join(__a , 'triangle.txt' ) with open(__a ) as f: _a : int ...
5
'''simple docstring''' import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class UpperCAmelCase__ ( lowercase__ ...
5
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Union[str, Any] = { "configuration_pix2struct": [ "PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_M...
93
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a__: List[str] = False class SCREAMING_SNAKE_CASE...
193
0
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available f...
149
"""simple docstring""" import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config...
149
1
'''simple docstring''' import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers.m...
215
'''simple docstring''' import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from tr...
215
1
import sys from collections import defaultdict class a__ : def __init__( self ) -> int: __a = [] def __SCREAMING_SNAKE_CASE ( self , UpperCAmelCase ) -> Optional[Any]: return self.node_position[vertex] def __SC...
197
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.util...
197
1
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...
245
# Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar UpperCAmelCase__ : Tuple = TypeVar("""T""") class a__ ( Generic[T] ):...
245
1
import logging from transformers.configuration_utils import PretrainedConfig a =logging.getLogger(__name__) class A_ ( SCREAMING_SNAKE_CASE ): _UpperCAmelCase : List[Any] = '''masked_bert''' def __init__( self : int ,SCREAMING_SNAKE_CASE__ : ...
113
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a ={ """configuration_pix2struct""": [ """PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Pix2StructConfig""", """Pix2StructTextConfig""...
113
1
'''simple docstring''' # Lint as: python3 import itertools import os import re __a = re.compile(R'([A-Z]+)([A-Z][a-z])') __a = re.compile(R'([a-z\d])([A-Z])') __a = re.compile(R'(?<!_)_(?!_)') __a = re.compile(R'(_{2,})') __a = R'^\w+(\.\w+)*$' ...
145
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'kssteven/ibert-roberta-base': 'https:/...
145
1
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _snake_case ( ): with offline(OfflineSimulationMode.CONNE...
69
"""simple docstring""" import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor SCREAMING_SNAKE_CASE_ : int = logging.get_logger(__name__) class a ( _lowerCamelCase ): """simple docstring""" def ...
69
1
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) ...
68
def _a ( UpperCAmelCase , UpperCAmelCase ) -> float: """simple docstring""" return price * (1 + tax_rate) if __name__ == "__main__": print(F'''{price_plus_tax(1_00, 0.25) = }''') print(F'''{price_plus_tax(125.50, 0.05) = }''')
142
0
"""simple docstring""" import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet....
360
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : Optional[Any] , lowerCAmelCase__ : str ) -> List[Any]: """simple docstring""" return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def UpperCamelCase_ ...
289
0
import heapq def lowerCamelCase__ ( A__ : dict ): '''simple docstring''' __lowerCamelCase = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Qu...
12
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_images, to_numpy_array, vali...
12
1
'''simple docstring''' import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class _lowerCAmelCase ( _SCREAMING_SNAKE_CASE ): """simple docstring""" lowerCamelCase = (PNDMScheduler,) lowerCam...
366
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCamelCase__ : Any = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_t...
164
0
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging A =logging.get_logger(__nam...
34
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class _snake_case ( nn.Module ): '''simple docstring''' A__ : int A__ : int A__ : ...
345
0
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME UpperCamelCase : Tuple = ["small", "medium", "large"] UpperCamelCase : Optional[Any] = "lm_head.decoder.weight" UpperCamelCase : List[str] = "lm_head.weight" ...
263
"""simple docstring""" import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import...
263
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __a = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], "tokenization_rag": ["RagTokenizer"], } try: ...
35
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import Ro...
35
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging UpperCamelCase = logging.get_logge...
351
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask fro...
221
0
"""simple docstring""" from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand UpperCAmelCase__ : Optional[int] = logging.get_logger(__name__) # py...
25
"""simple docstring""" from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from .....
25
1
"""simple docstring""" from __future__ import annotations UpperCamelCase_ = list[tuple[int, int]] UpperCamelCase_ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0,...
370
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase_ = { 'configuration_mctct': ['MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MCTCTConfig'], 'feature_extraction_mctct': ['MCTCTFeatureExtractor'], ...
303
0
"""simple docstring""" _a : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_93_44, "knot": 1.8_52, } _a : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_77_77_77_78, "mph": 0.6_21_37_11_92, "knot": 0.5_39_95_68_03, } def SCREAM...
44
"""simple docstring""" from math import ceil def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Union[str, Any] ,_lowerCamelCase : Union[str, Any] ) -> int: _lowerCAmelCase : Dict = list(range(0 ,_lowerCamelCase ) ) _lowerCAmelCase : ...
44
1
"""simple docstring""" import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tenso...
350
"""simple docstring""" 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_av...
86
0
import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class _UpperCamelCase ( unitte...
210
import requests def UpperCAmelCase ( lowercase , lowercase ): """simple docstring""" __lowercase = {'''Content-Type''': '''application/json'''} __lowercase = requests.post(lowercase , json={'''text''': message_body} , headers=lowerca...
210
1
'''simple docstring''' import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import ...
98
'''simple docstring''' import unittest import numpy as np from datasets import load_dataset 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, pre...
98
1
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingfac...
7
class A : """simple docstring""" def __init__( self : Any,lowercase_ : Tuple,lowercase_ : Any,lowercase_ : List[str] )-> List[Any]: '''simple docstring''' A__ = name A__ = ...
7
1
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def lowercase ( _snake_case : int , _snake_case : int , _snake_case : int , _snake_case : int , _sna...
24
"""simple docstring""" import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state imp...
24
1
class _A: """simple docstring""" def __init__( self , _A ): __A : Tuple = set_counts __A : Union[str, Any] = max(_A ) __A : List[str] = len(_A ) __A : Union[str, Any] = [1] * num_set...
280
import math def _SCREAMING_SNAKE_CASE ( a ) -> list[int]: __A : List[str] = [] __A : Any = 2 __A : Union[str, Any] = int(math.sqrt(a ) ) # Size of every segment __A : Any = [True] * (end + 1) __A : Lis...
280
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Any class UpperCAmelCase_ : def __init__( self : str , UpperCAmelCase__ : Any ) -> List[str]: lowerCAmelCase = data l...
358
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if i...
55
0
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowerCAmelCase_ ( __A ) -> str: '''simple docstring''' UpperCAmelCase__ = FileLock(str(tmpdir / "foo.lock" ) ) UpperCAmelCase__ ...
65
"""simple docstring""" import unittest import numpy as np def lowerCAmelCase__ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ = None , ): '''simple docstring''' _a : List[Any] = np.shape(UpperCame...
294
0
def _a ( SCREAMING_SNAKE_CASE__ : int ) -> int: '''simple docstring''' assert isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ), f'''The input value of [n={number}] is not an integer''' if number == 1: return 2 ...
191
def _a ( SCREAMING_SNAKE_CASE__ : int = 50_00_00_00 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE__ : str = set() SCREAMING_SNAKE_CASE__ : Dict = int((limit - 24) ** (1 / 2) ) SCREAMING_SNAK...
191
1
'''simple docstring''' import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def SCREAMING_SNAKE_CASE( __lowercase , __lowercase , __lowercase , __lowercase ) -> Optional[Any]: A: ...
319
'''simple docstring''' import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing impor...
319
1
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class _SCREAMING_SNAKE_CASE : '''simple docstring''' @property def ...
273
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py __A = "src/transformers" # This is to make sure the transformers module...
273
1
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = {'''vocab_file''': '''vocab.json'''} _lowercase = { ''...
74
"""simple docstring""" 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 _lowercase = logging.get_logg...
74
1
"""simple docstring""" from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( snake_case : str , snake_case : list[str] | None = None )-> Union[str, Any]: UpperCAmelCase__ : Any = word_bank or [] # create a table UpperCAmelCase__ : int ...
366
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : List[Any] = logging.get_logger(__name__) _lowerCAmelCase : List[Any] = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=ber...
298
0
"""simple docstring""" import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.tes...
260
"""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 lowercase__ ( self : List[Any] , __Upper...
260
1
"""simple docstring""" def A_ ( _lowerCAmelCase : int = 10_00 ): """simple docstring""" _a = -1 _a = 0 for a in range(1, n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c _a = (n * ...
153
"""simple docstring""" import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class __lowerCamelCase ( unittest.TestCase ): '''simple docst...
153
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { '''facebook/s2t-wav2vec2-large-en-de''': ( '''https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main/confi...
64
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def lowerCamelCase_ ( ): lowerCamelCase_ , lowerCamelCase_ = 9, 1_4 # noqa: F841 lowerCamelCase_ = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7...
19
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { """facebook/nllb-moe-54B""": """https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json""", } class a__ ( snak...
364
import enum import shutil import sys UpperCamelCase__ , UpperCamelCase__ = shutil.get_terminal_size() UpperCamelCase__ = {"""UP""": """A""", """DOWN""": """B""", """RIGHT""": """C""", """LEFT""": """D"""} class a__ ( enum.Enum ): _a : Any = 0 _...
102
0
import enum import warnings from ..tokenization_utils import TruncationStrategy 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 from ..models.auto.modeling_tf_auto...
65
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () UpperCamelCase__ = np.linspace(start=0, stop=7_5, num=7_5, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
65
1
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class snake_case_( a__ ): __UpperCamelCase = (UnCLIPScheduler,) def lowerCamelCase__ ( self : List[str] , **UpperCamelCase_ ...
370
"""simple docstring""" import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def _snake_case ( _snake_case ...
314
0
'''simple docstring''' from collections import namedtuple import requests from lxml import html # type: ignore _snake_case = namedtuple('covid_data', 'cases deaths recovered') def _A ( snake_case = "https://www.worldometers.info/coronavirus/" ) -> str: _lowercase : int = ...
250
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfig...
109
0
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch if is_tf_available()...
28
from math import factorial, pi def __UpperCamelCase ( lowercase__ : float , lowercase__ : int = 30 ) -> float: '''simple docstring''' if not isinstance(lowercase__ , (int, float) ): raise ValueError("""maclaurin_sin() requires either an int or...
28
1
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py...
305
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, SkipDataLoader, ...
330
0
def lowercase( UpperCamelCase_ , UpperCamelCase_ ) -> str: '''simple docstring''' if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) UpperCamelCase = str(bin(a__ ) )[2:] # remove the leading "0b" UpperCamelCase = str(bin...
369
def lowercase( UpperCamelCase_ ) -> int: '''simple docstring''' UpperCamelCase = len(UpperCamelCase_ ) UpperCamelCase = len(matrix[0] ) UpperCamelCase = min(UpperCamelCase_ , UpperCamelCase_ ) for row in range(UpperCamelCase_ ): # Check if dia...
165
0
# flake8: noqa # Lint as: python3 UpperCAmelCase__ = [ "VerificationMode", "Version", "disable_progress_bar", "enable_progress_bar", "is_progress_bar_enabled", "experimental", ] from .info_utils import VerificationMode from .logging import disable_progress_bar, enable_progress_bar, ...
339
import math import unittest def A ( _UpperCAmelCase : int ) -> bool: '''simple docstring''' assert isinstance(_UpperCAmelCase , _UpperCAmelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are prim...
339
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase__ = { """configuration_canine""": ["""CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CanineConfig"""], """tokeniz...
366
"""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 ( ProphetNetFor...
175
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowercase = { '''configuration_deberta''': ['''DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
74
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _lowercase = logging.get_logger(__name__) _lowercase = { '''Intel/dpt-large''': '''https://huggingface.co/Intel/dpt-large/resolve/main/config...
74
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanoramaPipeline, UNeta...
63
from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=lowerCAmelCase ): '''simple docstring''' __A = ['''torch'''] def __init__( self : Any , *lowercase_ : Optional[int] , **lowercase_ : Optional[Any]) -> Opti...
63
1
"""simple docstring""" from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize("""repo_id""" , ["""canonical_dataset_name""", """org-name/dataset-name"""] ) @pytest.mark.parametrize("""path""" , ["""filename.csv""", """filename w...
165
"""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_verbosit...
165
1
"""simple docstring""" import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel fro...
57
"""simple docstring""" # Copyright 2022 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 # #...
57
1
'''simple docstring''' import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class _a : def __init__( self : Any , lowercase : Any , lowercase : int , lowercase : int ): '''simple docstring''' if dst_width <...
34
'''simple docstring''' from __future__ import annotations import math class a_ : def __init__( self , _SCREAMING_SNAKE_CASE ) -> None: """simple docstring""" UpperCamelCase = size # approximate the ov...
321
0
'''simple docstring''' import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask...
362
'''simple docstring''' from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, res...
246
0
'''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 = { """kssteven/ibert...
323
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __A ( lowerCamelCase_ ): "...
323
1
import random from typing import Any def UpperCamelCase (lowercase_: list ) -> list[Any]: for _ in range(len(lowercase_ ) ): A__ : List[Any] = random.randint(0 , len(lowercase_ ) - 1 ) A__ : Optional[int] = random.randint(0 , len(lowercase_ ) - 1 ...
370
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : str = logging.get_logger(__name__) A_ : Any = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiuae/falcon-7b': 'https://huggingface.co/tiiuae/falcon-7b/reso...
141
0
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPMode...
100
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ = 100 ): __SCREAMING_SNAKE_CASE = 0 __SCREAMING_SNAKE_CASE = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "__mai...
100
1
"""simple docstring""" import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tok...
168
"""simple docstring""" import math import random def a__ ( snake_case__ , snake_case__ = False ) -> float: if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value lowerCAmelCase : Dict = 0.0_2 def a__ ( ...
168
1
from __future__ import annotations def snake_case__ ( lowerCAmelCase_, lowerCAmelCase_ ): """simple docstring""" SCREAMING_SNAKE_CASE =[] create_all_state(1, _lowerCamelCase, _lowerCamelCase, [], _lowerCamelCase ) return result def ...
334
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
44
0
"""simple docstring""" import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_...
233
"""simple docstring""" 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 fro...
233
1
import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrogram_diffusion...
65
from __future__ import annotations from collections import deque class A : def __init__(self : Dict , __UpperCAmelCase : list[str] ) -> Optional[int]: """simple docstring""" UpperCAmelCase__ = [] self.adlist.a...
65
1
"""simple docstring""" from __future__ import annotations import math def A_ ( snake_case_ : Optional[Any] ,snake_case_ : int ,snake_case_ : Dict ,snake_case_ : Dict ,snake_case_ : Optional[int] ): '''simple docstring''' if de...
353
"""simple docstring""" import argparse import os import re __A : Dict = '''src/diffusers''' # Pattern that looks at the indentation in a line. __A : Union[str, Any] = re.compile(R'''^(\s*)\S''') # Pattern that matches `"key":" and puts `key` in group 0. __A : Dict ...
27
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 @require_sentencepiece @req...
348
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineTest...
348
1
from math import isclose, sqrt def A ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : str = point_y / 4 / point_x _lowerCAmelCase : Any = 2 * normal_gradient / (1 + normal...
300
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 transformers.utils impo...
300
1
'''simple docstring''' class snake_case : """simple docstring""" def __init__( self , UpperCamelCase , UpperCamelCase ): """simple docstring""" lowerCamelCase_ = name lowerCamelCase_ = val def __str__( self ...
55
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'kssteven/ibert-roberta-base': 'https:/...
145
0
'''simple docstring''' from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): if not arr: return None,...
350
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): try: __UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase ) except ValueError: raise ValueError("Please enter a valid number" ) __UpperCAmelCase : str = decimal - int(_U...
37
0
'''simple docstring''' import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, Conditional...
141
'''simple docstring''' import unittest from transformers import DonutProcessor lowerCamelCase : Tuple = 'naver-clova-ix/donut-base' class __lowerCAmelCase (unittest.TestCase ): '''simple docstring''' def UpperCamelCase__ (self : int ): '...
2
0
import torch from torch import nn class lowerCAmelCase ( nn.Module ): def __init__( self : Tuple , UpperCAmelCase : Dict , UpperCAmelCase : List[Any] , UpperCAmelCase : List[Any] , UpperCAmelCase : Tuple , UpperCAmelCase : ...
45
from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstrings, add_start_docstrin...
45
1
class lowercase__ : def __init__( self : Optional[Any] , UpperCamelCase__ : int ): '''simple docstring''' SCREAMING_SNAKE_CASE : Any = size SCREAMING_SNAKE_CASE : Union[str, Any] = ...
182
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def A ( _lowercase ): if not is_accelerate_available(): return method SCREAMING_SNAKE_CASE : int = version.parse(ac...
182
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=snake_case_ ) class __lowerCamelCase ( snake_case_ ): """simple docstring""" lower...
355
from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class __lowerCamelCase ( snake_case_ ...
297
0
"""simple docstring""" import requests from bsa import BeautifulSoup def __lowerCAmelCase (_UpperCamelCase = "https://www.worldometers.info/coronavirus" ): __lowerCAmelCase : Optional[int] = BeautifulSoup(requests.get(_UpperCamelCase ).text , 'html.parser' ) __lowerCAmelCa...
86
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase__ = {"""configuration_fnet""": ["""FNET_PRETRAINED_CONFIG_ARCHIVE_M...
86
1
import argparse from collections import defaultdict import yaml SCREAMING_SNAKE_CASE : Tuple = "docs/source/en/_toctree.yml" def UpperCamelCase_( lowerCamelCase_ ) -> Tuple: _lowercase : Tuple = defaultdict(lowerCamelCase_ ) _lowercase : int = [] ...
84
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Dict = {name: getattr(transform...
84
1