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 unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if...
42
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __UpperCAmelCase ( tf.keras.layers.Layer ): def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=1 , ...
42
1
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def lowerCamelCase_ ( _lowerCamelCase , _lowerCamelCase=7 ): lowerCamelCase__ : List[str] = None if token is not None: l...
316
"""simple docstring""" import cva import numpy as np class a_ : '''simple docstring''' def __init__(self, lowerCamelCase_, lowerCamelCase_ ): '''simple docstring''' if k in (0.04, 0.06): lowerCamelCase__ : Tuple = k lower...
316
1
from __future__ import annotations def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' if not nums: raise ValueError('''List is empty''' ) return sum(SCREAMING_SNAKE_CASE ) / len(SCREAMING_SNAKE_CASE ) if __name__ == "__main__": import doctest doctest.testmod(...
43
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 ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils import logging logging.s...
326
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a = logging.get_logger(__name__) a = { 'google/mobi...
370
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _snake_case ( _snake_case : Dict ) -> Any: '''simple docstring''' if ( (cp >= 0X4e00 and cp <= 0X9fff) o...
271
0
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def __lowerCamelCase ( UpperCAmelCase_ : List[str] ): """simple docstring"""...
94
from __future__ import annotations def __lowerCamelCase ( UpperCAmelCase_ : dict , UpperCAmelCase_ : str ): """simple docstring""" a , a :Optional[Any] = set(UpperCAmelCase_ ), [start] while stack: a :Optional[int...
94
1
"""simple docstring""" import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVi...
350
"""simple docstring""" 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 _lowerCamelCase ( a_ ): # to overwrite at feature extractactor spe...
212
0
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from u...
315
"""simple docstring""" from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def UpperCamelCase ( UpperCAmelCase ) ->List[Any]: """simple docstring""" def is_in_circle(UpperCAmelCase , UpperCAmelCase ) -> bool: a_...
243
0
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.models.mbart.modeling_mbart impo...
216
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def snake_case__ ( SCREAMING_SNAKE_CASE_ : BertModel , SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' ...
216
1
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ) -> int: if not isinstance(_lowerCamelCase ,_lowerCamelCase ): raise ValueError("""multiplicative_persistence() only accepts integral values""" ) if num < 0: raise ValueError("""multiplicative_...
44
"""simple docstring""" _a : List[str] = { 'Pillow': 'Pillow', 'accelerate': 'accelerate>=0.11.0', 'compel': 'compel==0.1.8', 'black': 'black~=23.1', 'datasets': 'datasets', 'filelock': 'filelock', 'flax': 'flax>=0.4.1', 'hf-doc-builder': 'hf-doc-builder>=0.3.0', ...
44
1
import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def snake_case () -> str: ...
370
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py A_ : List[str] = '.' if __name__ == "__main__": A_ : Dict = os.path.join(REPO_PATH, 'utils/documentation_tests.txt') ...
292
0
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tok...
37
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_...
37
1
from ..utils import DummyObject, requires_backends class __lowerCAmelCase ( metaclass=lowerCAmelCase): _a = ['''torch''', '''transformers''', '''onnx'''] def __init__( self: List[str] , *_lowerCAmelCase: Optional[Any] , **_lowerCAmelCase: Union[str, Any] ...
158
# 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.configuration_utils import Con...
158
1
"""simple docstring""" def lowercase ( lowerCAmelCase__ : Union[str, Any] ) -> Optional[int]: __a = len(lowerCAmelCase__ ) __a = sum(lowerCAmelCase__ ) __a = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i ...
45
"""simple docstring""" from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def lowercase ( lowerCAmelCase__ : Namespace ) -> Tuple: return ConvertCommand( args.model_type , args.tf_checkpoint ...
45
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : Any = { '''configuration_albert''': [...
365
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_tor...
130
0
'''simple docstring''' from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import stab...
104
'''simple docstring''' import os import sys import unittest _lowerCamelCase : Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 ...
258
0
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging lowe...
215
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransfor...
215
1
from __future__ import annotations def __lowercase ( _UpperCamelCase, _UpperCamelCase = None ) ->list[list[str]]: """simple docstring""" lowercase : Dict = word_bank or [] # create a table lowercase : int = len(_UpperCamelCase ) + 1...
337
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging __a = logging.get_logger(__name__) def __lowercase ( _UpperCamelCase ) ->List[int]: """simple docstring""" if isinstance(_UpperCamelCase, np.ndarray ): ...
337
1
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_a...
361
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: int ) -> int: if not isinstance(lowerCAmelCase , lowerCAmelCase ): raise TypeError("Input value must be an 'int' type" ) _UpperCAmelCase : List[Any] = 0 while number: position += 1 number ...
189
0
'''simple docstring''' import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jn...
237
'''simple docstring''' # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controln...
237
1
"""simple docstring""" def UpperCAmelCase ( a_ ) -> bool: """simple docstring""" if num < 0: return False __A = num __A = 0 while num > 0: __A = rev_num * 1_0 + (num % 1_0) num //= 1_0 ret...
365
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class UpperCAm...
124
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __A = {"""configuration_reformer""": ["""REFORMER_PRETRAINED_CONFIG_ARCHIVE_...
293
"""simple docstring""" 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_M...
293
1
"""simple docstring""" import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor UpperCamelCase : str = logging.getLogger(__name__) UpperCamelCase ...
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""" import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class lowercase ( unittest.TestCase ): def _snake_case ( self ) -> None: lowerCAmelCase ...
46
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available snake_case_ = { """configuration_longt5""": ["""LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LongT5Config""", """LongT5On...
78
0
"""simple docstring""" def lowerCAmelCase_ ( __a ) -> list[list[int]]: """simple docstring""" lowerCamelCase__: List[str] =[] if len(_lowerCamelCase ) == 1: return [nums.copy()] for _ in range(len(_lowerCamelCase ) ): lowerCamelCase__: Tuple =num...
370
from __future__ import annotations from typing import Any class _SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__(self : Any , UpperCAmelCase_ : int) ->None: '''simple docstring''' lowerCamelCase__: int =num_of_nodes lowerCamelCase__...
273
0
'''simple docstring''' from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_availa...
104
'''simple docstring''' import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelT...
104
1
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def A_ ( _lowerCAmelCase : BertModel, _lowerCAmelCase : str, _lowerCAmelCase : str ): """simple docstring""" ...
360
"""simple docstring""" def A_ ( _lowerCAmelCase : int ): """simple docstring""" if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True _a = 4 _a = (1 << p) - 1 for _ in range(p - 2...
153
0
'''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 a : Union[str, Any] = loggi...
56
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _snake_case : Union[str, Any] = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig...
292
0
'''simple docstring''' import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline lowerCamelCase : int = version.parse...
114
'''simple docstring''' def _lowerCAmelCase ( _UpperCamelCase : str ) -> bool: """simple docstring""" _SCREAMING_SNAKE_CASE =0 for ch in input_str: _SCREAMING_SNAKE_CASE =ord(_UpperCamelCase ) _SCREAMING_SNAKE_CASE =pow(2 ...
114
1
import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel _snake_case : Tuple = logging.getLogger(__n...
123
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path _snake_case : Dict = Path(__file__).resolve().parents[3] / "src" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa im...
123
1
import datasets from .evaluate import evaluate __UpperCAmelCase = '''\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={EMNLP}, year={2016} } '...
42
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCAmelCase = {'''configuration_xlnet''': ['''XLNET_PRETRAINED_CONFIG_ARCHIVE_M...
42
1
"""simple docstring""" import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) a_ = pytest.mark.integration @pytest.m...
249
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STAN...
327
0
"""simple docstring""" def UpperCamelCase_( snake_case__: Any ) -> set: UpperCAmelCase__ = set() # edges = list of graph's edges UpperCAmelCase__ = get_edges(__lowerCAmelCase ) # While there are still elements in edges list, take an arbitrary edge...
362
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ...
335
0
import os import sys _a = os.path.join(os.path.dirname(__file__), '''src''') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoModelForSequenceClassificati...
39
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 __snake_case ( lowerCamelCase_ ...
219
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase : Optional[Any] = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-finetuned-audioset-10-10-...
66
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
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ : Optional[int] = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP",...
270
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Optional[Any] = {"configuration_wavlm": ["WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "WavLMConfig"]} try: if not is_torch_available(): raise Opt...
270
1
import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowercase__ =get_tests_dir('fixtures/spiece.model') @req...
368
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.models.mbart.modeling_mbart impor...
90
0
def UpperCamelCase( __UpperCamelCase : int ,__UpperCamelCase : int ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) lowerCAmelCase_ : Optional[int] = str(bin(__UpperCamelCase ) )[2:] # remove the leading "0b" lowerCAmelCase_ :...
103
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline __snake_case = argparse.ArgumentParser('''Stable Diffusion script with intel optimization''', add_help=False) parser.add_argument('''--dpm''', action='''store_tru...
348
0
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, ...
245
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): A_ :Any = yaml.safe_load( '''\ name: "" allow_empty: false allow_empty_text: true subsections: - name:...
245
1
'''simple docstring''' from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_sing...
58
'''simple docstring''' from __future__ import annotations import math def lowerCamelCase ( __lowerCamelCase : int ) ->list[int]: if num <= 0: _SCREAMING_SNAKE_CASE = F'{num}: Invalid input, please enter a positive integer.' raise ValueError(__lowerCamelCas...
58
1
'''simple docstring''' import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy ...
21
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline _lowercase : Union[str, Any] = logging.get_logger(__name__) # pylint: disable=invalid-name cla...
21
1
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...uti...
157
def _UpperCamelCase ( snake_case__ ) -> bool: if not isinstance(snake_case__, snake_case__ ): raise ValueError("check_bouncy() accepts only integer arguments" ) __UpperCAmelCase : Optional[int] = str(snake_case__ ) __UpperCAmelC...
157
1
def a__ ( UpperCAmelCase : Union[str, Any] , UpperCAmelCase : Union[str, Any] ) -> Dict: # Check if the input is valid if not len(UpperCAmelCase ) == len(UpperCAmelCase ) == 3: raise ValueError('''Please enter a valid equation.''' ) if equatio...
371
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
99
0
"""simple docstring""" def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase ) -> float: if density <= 0: raise ValueError('Impossible fluid density' ) if bulk_modulus <= 0: raise ValueError('Impossible bulk modulus' ) return (bulk_modulu...
69
'''simple docstring''' __SCREAMING_SNAKE_CASE : Dict = 8.3_1_4_4_6_2 # Unit - J mol-1 K-1 def UpperCamelCase_ ( _UpperCAmelCase : float , _UpperCAmelCase : float , _UpperCAmelCase : float ) -> float: """simple docstring""" if moles < ...
31
0
'''simple docstring''' def A__ ( UpperCAmelCase_ , UpperCAmelCase_ ): if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) _UpperCamelCase : List[Any] = str(bin(A__ ) )[2:] # remove the leading "0b" _UpperCa...
357
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available snake_case_ : Any = { 'configuration_mvp': ['MVP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MvpConfig', 'MvpOnnxConfig'], 'tokenization_mvp'...
236
0
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": a : Any = argparse.ArgumentParser( description=( "Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned" ...
114
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class a ( lowercase__ ): """simple docstring""" ...
114
1
from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionP...
363
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeature...
256
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer UpperCAmelCase_ : Optional[Any] = logging.get_logger(__name__) Upper...
38
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
0
'''simple docstring''' import inspect import unittest from transformers import ConvNextConfig 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_backbone_common ...
356
'''simple docstring''' import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as tr...
187
0
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class UpperCAmelCase...
70
import datasets from .evaluate import evaluate _A : Optional[int] = '\\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 year={2016...
142
0
import os import string import sys A_ : Any = 1 << 8 A_ : int = { 'tab': ord('\t'), 'newline': ord('\r'), 'esc': 27, 'up': 65 + ARROW_KEY_FLAG, 'down': 66 + ARROW_KEY_FLAG, 'right': 67 + ARROW_KEY_FLAG, 'left': 68 + ARROW_KEY_FLAG, 'mod_int': 91, 'undefined': s...
365
import argparse from collections import defaultdict def UpperCamelCase (lowercase_: List[str] , lowercase_: Optional[int] , lowercase_: Optional[Any] , lowercase_: Union[str, Any] , lowercase_: Any ) -> int: A__ : Optional[Any] = f"""{file}_{class_name}...
141
0
"""simple docstring""" import math def _snake_case ( lowercase__ ): if not isinstance(lowercase__ , lowercase__ ): _lowerCamelCase : Any = f'''Input value of [number={number}] must be an integer''' raise TypeError(lowercase_...
96
"""simple docstring""" import math def _snake_case ( lowercase__ ): return math.sqrt(lowercase__ ) * math.sqrt(lowercase__ ) == num def _snake_case ( lowercase__ ): _lowerCamelCase : Optional[int] = 0 _lowerCamelCase...
96
1
from manim import * class SCREAMING_SNAKE_CASE__ ( UpperCAmelCase ): '''simple docstring''' def A ( self : Dict ): '''simple docstring''' _snake_case = Rectangle(height=0.5 , width=0.5 ) _snake_case = Rectangle(heigh...
130
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, slow from ...test_tokenization_common import Tok...
130
1
UpperCAmelCase_ = 8.314_4598 def lowerCAmelCase_ ( __UpperCAmelCase: float , __UpperCAmelCase: float ) -> float: if temperature < 0: raise Exception('''Temperature cannot be less than 0 K''' ) if molar_mass <= 0: raise Exception('''...
201
def lowerCAmelCase_ ( __UpperCAmelCase: float , __UpperCAmelCase: int ) -> float: if digit_amount > 0: return round(number - int(__UpperCAmelCase ) , __UpperCAmelCase ) return number - int(__UpperCAmelCase ) if __name__ == "__main__": print...
201
1
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...t...
355
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging __a = logging.get_logger(__name__) def lowerCamelCase__ ( _lowercase ): '''simple docstring''' UpperCAmelCase_ ...
235
0
from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ChannelDimension, Ima...
245
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 ..image_utils import load_image if ...
245
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable snake_case : Tuple = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfig''']}...
109
def __lowercase ( __lowerCAmelCase : int ): if num <= 0: raise ValueError('Input must be a positive integer' ) a__ = [True] * (num + 1) a__ = 2 while p * p <= num: if primes[p]: for i i...
109
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _SCREAMING_SNAKE_CASE : str = { '''configuration_canine''': ['''CANINE_PRETRAINED_CONFIG_ARCHIVE...
183
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin _SCREAMING_SNAKE_CASE : Optional[int] = ''' Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Tho...
183
1
'''simple docstring''' import math import flax.linen as nn import jax.numpy as jnp def a_ ( __snake_case : jnp.ndarray , __snake_case : int , __snake_case : float = 1 , __snake_case : float = 1 , __snake_case : floa...
363
'''simple docstring''' from ..utils import DummyObject, requires_backends class __UpperCamelCase ( metaclass=lowerCamelCase__ ): lowercase : str =['speech'] def __init__( self, *lowerCAmelCase, **lowerCAmelCase ): """simple docstring""" ...
6
0
'''simple docstring''' import argparse from collections import defaultdict import yaml __lowerCamelCase = '''docs/source/en/_toctree.yml''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> List[str]: A_ = defaultdict(UpperCAmelCase__ ) for doc in model_doc: ...
162
'''simple docstring''' from __future__ import annotations def UpperCAmelCase__ ( UpperCAmelCase__ ) -> bool: A_ = len(UpperCAmelCase__ ) # We need to create solution object to save path. A_ = [[0 for _ in range(UpperCAmelCase__ )] for _ in range(UpperCAmelCase_...
162
1
import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizerBase def a( A...
365
def a( A : int , A : float , A : float ) -> float: """simple docstring""" return round(float(moles / volume ) * nfactor ) def a( A : float , A : float , A : float ) -> float: """simple docstring""" return round(float((moles * 0.0_...
71
0
import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _a ( SCREAMING_SNAKE_CASE ...
110
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @...
110
1
import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available...
348
import requests __A = "https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=" def lowerCamelCase_ ( UpperCamelCase__ : str ) -> None: """simple docstring""" __lowerCamelCase = requests.get(_NEWS_API + bbc_news_api_key ).jso...
348
1
def _UpperCAmelCase ( a__ , a__): '''simple docstring''' print("""\nThe shortest path matrix using Floyd Warshall algorithm\n""") for i in range(a__): for j in range(a__): if dist[i][j] != float("""inf"""): print(int(dist[i][j]) , end="""\t""") else...
248
# Algorithm for the pigeonhole sorting def _UpperCAmelCase ( a__): '''simple docstring''' a_ : List[Any] = min(a__) # min() finds the minimum value a_ : List[str] = max(a__) # max() finds the maximum value a_ : str = max_val - min_val + 1 ...
248
1
'''simple docstring''' from __future__ import annotations def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): _UpperCAmelCase : list[list[int]] = [] _UpperCAmelCase : list[int] = [] _UpperCAmelCase : str = 0 _UpperCAmelCase : Dict ...
368
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar lowerCamelCase__ = TypeVar('T') class lowerCAmelCase__ ( Generic[T] ): def __init__( self : Union[str, Any]...
322
0
'''simple docstring''' def _lowerCAmelCase ( _UpperCamelCase : int ) -> int: """simple docstring""" if not isinstance(_UpperCamelCase , _UpperCamelCase ): raise ValueError('Input must be an integer' ) if input_num <= 0: raise ValueE...
47
'''simple docstring''' import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torc...
324
0
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchm...
157
"""simple docstring""" import torch from diffusers import StableDiffusionPipeline _SCREAMING_SNAKE_CASE : Optional[int] = """path-to-your-trained-model""" _SCREAMING_SNAKE_CASE : Optional[Any] = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""") ...
157
1
"""simple docstring""" from collections import defaultdict def lowercase ( __snake_case : str , __snake_case : str ): lowercase_ : int = first_str.lower().strip() lowercase_ : Any = second_str.lower().strip() # Remove whitespace...
33
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
143
0
'''simple docstring''' import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class _SCREAMING_SNAKE_CASE : def __init__( self : Optional[Any] , ...
364
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", "ClapT...
98
0
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def __lowerCamelCase ( lowerCamelCase__ ): """simple docstring""" lowercase__ : Union[str, Any] = SwinConfig(ima...
130
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property from ...test_t...
130
1
"""simple docstring""" import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC a : Optional[Any] = parse(importlib.metadata.version('''torch''')) def _SCREAMING_SNA...
79
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def _SCREAMING_SNAKE_...
79
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Any = {} try: if not is_sentencepiece_available(): ra...
91
"""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.testing_uti...
91
1
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...
371
import math def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes ...
180
0
'''simple docstring''' def snake_case_ (_a : Union[str, Any] , _a : Dict ): UpperCAmelCase = len(snake_case__ ) + 1 UpperCAmelCase = len(snake_case__ ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # leng...
34
import unittest import numpy as np def SCREAMING_SNAKE_CASE_ ( snake_case__ , snake_case__ , snake_case__ , snake_case__ = None , ) -> np.ndarray: lowerCAmelCase = np.shape(snake_case__ ) lowerCAmelCase = np.shape(snake_case__ ) lowerCAmelCase ...
338
0
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(__name__) _A = ...
167
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 = False class A ( unittest.TestCase ): pass @nightly @requ...
167
1
from __future__ import annotations def A ( _UpperCAmelCase : Any , _UpperCAmelCase : Dict ) -> list[int]: '''simple docstring''' _UpperCAmelCase = 0 _UpperCAmelCase = len(a__ ) - 1 while i < j: if nums[i] + nums[j] == target: ...
339
from __future__ import annotations import typing from collections import Counter def __lowerCAmelCase ( a__ ) -> typing.Counter[int]: __a = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(a__ , max_perimeter + 1 ): ...
6
0
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __lowercase ( pl.LightningModule ): """simple docstring""" def __init__( self , A ) -> Any: ...
66
import math import tensorflow as tf from packaging import version def __lowerCamelCase ( lowerCamelCase__ : Optional[Any] ): '''simple docstring''' lowerCamelCase = tf.convert_to_tensor(lowerCamelCase__ ) lowerCamelCase = 0.5 * (1.0 + tf.math....
66
1
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Optional[Any] = prime_factors(lowerCamelCase_ ) if is_square_free(lowerCamelCase_ ): return -1 if len(lower...
21
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def UpperCamelCase_( lowerCamelCase_ ) -> bool: _lowercase : int = int(number**0.5 ) return number == sq * sq def UpperCamelCase_( lowerCamelCase_ , lowerCam...
21
1
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, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, S...
361
def a_ ( __lowercase : int = 50_000_000 ) -> int: _snake_case = set() _snake_case = int((limit - 24) ** (1 / 2) ) _snake_case = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(3 , prime_square_limit + 1 , 2 ...
130
0
"""simple docstring""" import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate _a : int= TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=Data...
172
"""simple docstring""" import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import ded...
172
1
# Copyright (c) 2021-, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
36
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def lowerCAmelCase__ ( ): snake_case_ : str = ArgumentParser( description=( "PyTorch TPU distributed training l...
36
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a_ : Any = logging.get_logger(__name__) a_ : List[str] = { ...
75
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __UpperCamelCase ( lowerCamelCase__ ): def lowercase__ ( self, lowerCAmelCase ): """si...
75
1
class UpperCamelCase : def __init__( self ): A__ = {} def __A ( self ): print(self.vertex ) for i in self.vertex: print(UpperCAmelCase__ , " -> " , " -> ".join([str(UpperCAmelCase__ ) for j in self.vertex[i]] ) ) def __...
355
import argparse import struct import unittest class UpperCamelCase : def __init__( self , UpperCAmelCase__ ): A__ = data # Initialize hash values A__ = [ 0x6A_09E_667, 0xBB_67A_E85, 0x3C_6EF_372, 0xA...
198
0
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class a ( __lowerCAmelCase ,...
180
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers.model...
180
1
'''simple docstring''' import pprint import requests UpperCamelCase_ : Tuple = '''https://zenquotes.io/api''' def __a ( ) -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + "/today" ).json() def __a ( ) ...
364
'''simple docstring''' def __a ( _UpperCamelCase: int ) -> str: """simple docstring""" if number > 0: raise ValueError("input must be a negative integer" ) _snake_case = len(bin(_UpperCamelCase )[3:] ) _snake_case = bin(abs(_...
142
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunDiscreteScheduler from ....
262
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Optional[Any] =logging.get_logger(__name__) lowerCAmelCase : Tuple ={ '''facebook/vit-mae-base''': '''https://huggingface.co/faceb...
223
0
'''simple docstring''' from copy import deepcopy class __SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self : List[str] , __a : list[int] | None = None , __a : int | None = None ): if arr is None and size is not None: _a ...
346
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __SCREAMING_SNAKE...
346
1
import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__=7 ): snake_case_ = None if token is not None: snake_case_ = {'''Accep...
8
"""simple docstring""" import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def UpperCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): ...
221
0
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common impor...
265
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def _a ( *UpperCAmelCase , UpperCAmelCase = None , UpperCAmelCase=True , UpperCAmelCase=2 ) -> str: """simple docstring""" from .. import __version__ ...
265
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable UpperCamelCase = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DPTConfig''']} try...
87
from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class _lowerCAmelCase ( __a ): _lowercase ='''megatron-bert''' def _...
231
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ ...
111
'''simple docstring''' import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset lowerCamelCase_ = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5,...
111
1
'''simple docstring''' import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import c...
41
'''simple docstring''' lowerCamelCase : Any = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" low...
47
0
from sklearn.metrics import matthews_corrcoef import datasets SCREAMING_SNAKE_CASE :Optional[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 classifications. ...
360
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> list: """simple docstring""" if len(SCREAMING_SNAKE_CASE_ ) <= 1: return lst UpperCamelCase_ = 1 while i < len(SCREAMING_SNAKE_CASE_ ): if lst[i - 1] <= lst[i]: i += 1 else: ...
60
0
"""simple docstring""" import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def a__ ( SCREAMING_SNAKE_CASE : dict ): ...
108
UpperCAmelCase_ = 'Input must be a string of 8 numbers plus letter' UpperCAmelCase_ = 'TRWAGMYFPDXBNJZSQVHLCKE' def lowerCAmelCase_ ( __UpperCAmelCase: str ) -> bool: if not isinstance(__UpperCAmelCase , __UpperCAmelCase ): UpperCamel...
201
0
import math from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : Dict = logging.get_logger(__name__) lowerCamelCase_ : str = { """facebook/data2vec-base-960h""": """https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main/config.json"...
355
import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( BarkCoarseConfig, Ba...
223
0
import os from datetime import datetime as dt from github import Github A : Dict = [ "good first issue", "good second issue", "good difficult issue", "enhancement", "new pipeline/model", "new scheduler", "wip", ] def lowercase_ ( ): """...
184
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, PreTrainedTokenizer...
341
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase ( metaclass=__lowerCAmelCase ): snake_case_ = ['''note_seq'''] def __init__( self, *lowercase_, **lowercase_ ) -> str: requires_backends(self, ['note_seq'] ) @cla...
358
'''simple docstring''' import pytest lowerCAmelCase_ = "__dummy_dataset1__" lowerCAmelCase_ = "\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = \"https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/\"\nURLS = {\"train\": REPO_URL + \"wikiann-bn-train.jsonl\", ...
332
0
"""simple docstring""" import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_fo...
183
"""simple docstring""" from __future__ import annotations from typing import Generic, TypeVar _SCREAMING_SNAKE_CASE : Optional[Any] = TypeVar('''T''') class a ( Generic[T] ): def __init__( self : List[str] ...
183
1
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ...
350
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class snake_case__ (ctypes.Structure ): """simple docstring""" __lowerCAmelCase :Dict = [("size", c...
266
0
'''simple docstring''' import math def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : Union[str, Any], SCREAMING_SNAKE_CASE__ : Union[str, Any] ) -> int: if ( not isinstance(SCREAMING_SNAKE_CASE__, (int, float) ) or power_factor < -1 ...
125
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __a: List[str] = logging.get_logger(__name__) class UpperCAmelCase ( a__ ): '''simple docstring''' SCREAMING_SNAKE_CASE = "encoder-decoder" ...
198
0
def A (__A : Tuple , __A : str ) -> Tuple: """simple docstring""" UpperCAmelCase_ = 0 UpperCAmelCase_ = len(__A ) - 1 while left <= right: # avoid divided by 0 during interpolatio...
7
from maths.prime_factors import prime_factors def A (__A : int ) -> int: """simple docstring""" if not isinstance(__A , __A ): UpperCAmelCase_ = F"""Input value of [number={number}] must be an integer""" ...
7
1