code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" import torch def a_ ( ): if torch.cuda.is_available(): A__ = torch.cuda.device_count() else: A__ = 0 print(f'''Successfully ran on {num_gpus} GPUs''' ) if __name__ == "__main__": main()...
571
"""simple docstring""" def a_ ( __a , __a ): return int(input_a == input_a == 0 ) def a_ ( ): print('''Truth Table of NOR Gate:''' ) print('''| Input 1 | Input 2 | Output |''' ) print(f'''| 0 | 0 | {nor_gate...
571
1
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTe...
715
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase = { "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_torch_available(): raise ...
583
0
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def __magic_name__ ( ) -> Optional[int]: """simple docstring""" import os as original_os from os import path as original_path from os import renam...
458
'''simple docstring''' 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 PreTrainedTokenizer from ...utils import logging lowerCAmelCase: Tuple = logging.get_lo...
526
0
def __lowerCAmelCase ( UpperCAmelCase__ : int , UpperCAmelCase__ : int ) -> str: if number < 0 or shift_amount < 0: raise ValueError("""both inputs must be positive integers""" ) lowerCamelCase_ = str(bin(UpperCAmelCase_...
103
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer lowercase = logging.get_logger(__name__) lowercase ...
103
1
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402 # This is the refer...
109
"""simple docstring""" import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('''.''') def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' __SCREAMING_SNAKE_C...
682
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ : int = logging.get_logger(__name__) lowercase_ : Dict = { '''RWKV/rwkv-4-169m-pile''': '''https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config....
718
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase_ : Optional[Any] = logging.get_logger(__name__) lowercase...
653
0
import os import pytest from transformers.dynamic_module_utils import get_imports __a : List[str] = "\nimport os\n" __a : str = "\ndef foo():\n import os\n return False\n" __a : List[str] = "\ndef foo():\n def bar():\n if True:\n import os\n...
637
import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaXLForSequence...
637
1
from __future__ import annotations def _lowerCamelCase ( _a ): """simple docstring""" if not nums: raise ValueError('''List is empty''' ) return sum(_a ) / len(_a ) if __name__ == "__main__": import doctest doctest.testmod()
297
def _lowerCamelCase ( _a ): """simple docstring""" if bit_count < 0: raise ValueError('''The given input must be positive''' ) # get the generated string sequence _lowerCamelCase = gray_code_sequence_string(_a ) # # convert them to integers for i in range(len(_a ...
297
1
'''simple docstring''' from __future__ import annotations lowerCAmelCase: str = 'Muhammad Umer Farooq' lowerCAmelCase: List[str] = 'MIT' lowerCAmelCase: Tuple = '1.0.0' lowerCAmelCase: List[Any] = 'Muhammad Umer Farooq' lowerCAmelCase: Optional[Any] = 'contact@muhammadumerf...
526
'''simple docstring''' import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore lowerCAmelCase: Optional[int] = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" lowerCAmelCase: O...
526
1
'''simple docstring''' from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def lowerCamelCase ( _snake_case : int ,_snake_case : int ,_snake_case : float = 1 / sqrt(2 ) ): '''simple docstring''...
539
'''simple docstring''' import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class snake_case (tf.keras.layers.Layer ): ...
539
1
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np snake_case__ : Union[str, Any] = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 snake_case__ : Any = typing.Union[np.floata...
23
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class A ( UpperCamelCase_ ): UpperCamelCase__ : List[str] =(PNDMScheduler,) UpperCamelCase__ : Dict =(('num_inference_steps', 50),) def lowerCamelCase ...
464
0
"""simple docstring""" import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class UpperCamelCase__ ( __lowerCAmelCase ): """simple docstring""" A__ : Any = (UnCLIPScheduler,) def ...
715
"""simple docstring""" import numpy as np def _lowerCamelCase ( UpperCAmelCase_ : np.array ) -> np.array: """simple docstring""" return 1 / (1 + np.exp(-vector )) def _lowerCamelCase ( UpperCAmelCase_ : np.array ...
562
0
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_t...
20
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { 'shi-l...
582
0
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def __a(SCREAMING_SNAKE_CASE_ : Any , SCREAMING_SNAKE_CASE_ : Optional[int] , SCREAMING_SNAKE_CASE_ : Dict ): '''simple docstring''' _lowerCAmelCase = ...
489
'''simple docstring''' from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import f...
489
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class snake_case__ ( metaclass=UpperCamelCase): a_ = ["torch", "scipy"] def __init__( self : int , *_A : Optional[int] , **_A : List[str] ) -> int: requires_backe...
541
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available _UpperCamelCase : Tuple = { 'configuration_audio_spectrogram_transformer': [ 'AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAIN...
541
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, ) __a = {"configuration_mbart": ["MBART_PRETRAINED_C...
713
def a ( snake_case__: int ): '''simple docstring''' lowercase_ = [0] * len(snake_case__ ) lowercase_ = [] lowercase_ = [] lowercase_ = 0 for values in graph.values(): for i in values: ...
409
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowercase : str = logging.get_logger(__name__) __lowercase : Dict = { '''facebook/convnextv2-tiny-...
36
'''simple docstring''' # using dfs for finding eulerian path traversal def _lowercase ( __A ,__A ,__A ,__A=None ): '''simple docstring''' __UpperCamelCase = (path or []) + [u] for v in graph[u]: if visited_edge[u][v] is False: __UpperCamelCase...
601
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _UpperCamelCase: int =logging.get_logger(__name__) _UpperCamelCase: Union[str, Any] ={ 'junnyu/roformer_chinese_small': 'htt...
716
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...
585
0
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 t...
79
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Any = { """huggingface/informer-tourism-monthly""": ( ...
79
1
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def _UpperCAmelCase ( UpperCamelCase: str , UpperCamelCase: complex , UpperCamelCase: str = "x" , UpperCamelCase: float = 1_0**-1_0 , UpperCamelCase: int = 1 , ): ...
376
import math import sys def _UpperCAmelCase ( UpperCamelCase: str ): """simple docstring""" __lowerCAmelCase = "" try: with open(UpperCamelCase , "rb" ) as binary_file: __lowerCAmelCase = binary_file.read() for dat in data: __lowerCAmelCase ...
376
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A_: int = { 'configuration_poolformer': [ 'POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PoolFormerConfig', 'PoolFormerOnnxConfig', ] } tr...
398
def a ( a ) ->List[Any]: '''simple docstring''' SCREAMING_SNAKE_CASE = len(a ) while cur > 1: # Find the maximum number in arr SCREAMING_SNAKE_CASE = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi SCREAMING_SNAKE_CASE = arr[mi::-1] +...
201
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 lowercase : Dict ...
159
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature...
159
1
"""simple docstring""" # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatt...
247
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class lowerCAmelCase ( ...
247
1
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def lowerCAmelCase ( _lowerCAmelCase : Optional[int] ) -> str: """simple docstring""" monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings" , ...
703
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _lowerCAmelCase : Optional[int] = { "configuration_gpt_neo": ["GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoConfig", "GPTNeoOnnxConfig"], } try: if not is_t...
364
0
import qiskit def A ( lowercase__ : Any , lowercase__ : Union[str, Any] ) -> List[str]: UpperCamelCase__ :Any = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit acting on the q register UpperCamelCase__ :List[str] = qiskit.QuantumCircuit(_A , _...
45
def lowerCamelCase__ ( _A ): '''simple docstring''' snake_case_ = 1 for i in range(1 , num + 1 ): fact *= i return fact def lowerCamelCase__ ( _A ): '''simple docstring''' snake_case_ ...
376
0
import argparse import json from tqdm import tqdm def SCREAMING_SNAKE_CASE ( ): __a = argparse.ArgumentParser() # Required parameters parser.add_argument( '--src_path' , type=a_ , default='biencoder-nq-dev.json' , help='Path to raw DPR tra...
717
'''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_ = { "configuration_roformer": [...
490
0
'''simple docstring''' import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def lowercase__ ( __UpperCamelCase : int ): '...
566
'''simple docstring''' def lowercase__ ( __UpperCamelCase : list , __UpperCamelCase : int , __UpperCamelCase : int = 0 , __UpperCamelCase : int = 0 ): '''simple docstring''' __lowercase = right or len(__UpperCamelCase ) - 1 if...
566
1
from typing import TYPE_CHECKING from ...utils import _LazyModule _SCREAMING_SNAKE_CASE : Dict = {'''processing_wav2vec2_with_lm''': ['''Wav2Vec2ProcessorWithLM''']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys _SCREAMI...
472
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 _SCREAMING_SNAKE_CASE : Union[str, Any] = loggi...
472
1
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from tra...
99
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, AutoToken...
297
0
import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments A : List[str] = logging.getLogger(__name__) @dataclass class UpperCamelCase( _a ): ...
709
import os from typing import Dict, List, Tuple, TypeVar, Union A : List[Any] = TypeVar('T') A : Dict = Union[List[T], Tuple[T, ...]] A : Any = Union[T, List[T], Dict[str, T]] A : Optional[int] = Union[str, b...
473
0
import flax.linen as nn import jax import jax.numpy as jnp class __magic_name__ ( nn.Module): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Union[str, Any] = 42 SCREAMING_SNAKE_CASE__ : int = jnp.floataa ...
234
"""simple docstring""" from collections.abc import Callable import numpy as np def lowercase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> np.array: __magic_name__ = int(np.ceil((x_end - xa) / step_size ) ) __magic_nam...
490
0
'''simple docstring''' 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_...
47
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : List[str] = logging.get_logger(__name__) UpperCAmelCase : Dict = { 'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d...
47
1
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def a_ ( ): '''simple docstring''' _lowerCamelCase , _lowerCamelCase : Optional[int] =9, 14 # noqa: F841 _lowerCamelCase : Dict ...
464
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class a : def __init__( self : str ): """simple docstring""" __lowerCAmelCase = "" __lowerCAmelCase = "" __lowerCAmelCase = [] __lowerCAmelC...
611
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _UpperCamelCase : Any ={} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependen...
575
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, lo...
575
1
def _a ( SCREAMING_SNAKE_CASE__ : int ) -> bool: '''simple docstring''' return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('''Program to check whether a number is a Perfect number ...
663
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class lowerCamelCase (__lowerCamelCase ): """simple docstring""" UpperCAmelCase_ = ["image_processor", "tokenizer"] UpperC...
663
1
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase__(__snake_case ,__snake_case ,__snake_case ) -> str: '''simple docstring''' lo...
29
import string from math import logaa def lowerCAmelCase__(__snake_case ,__snake_case ) -> int: '''simple docstring''' lowerCamelCase__ = document.translate( str.maketrans('''''' ,'''''' ,string.punctuation ) ).replace('''\n''' ,'''''' ) lower...
29
1
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_CASE ( lowerCamelCase__ ): ...
225
import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tok...
225
1
import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, Trainer, T...
392
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class A__ ( __UpperCAmelCase ): """simple docstring""" __A : Tuple = ['''image_processor''', '''tokenizer'''] __A : Any = ...
392
1
import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def _SCREAMING_S...
70
"""simple docstring""" import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ...
581
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase :Union[str, Any] = { "configuration_longformer": [ "LONGFORMER_PRETRAINED_CONFIG_ARCHIVE_...
26
import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data import IterableDataset fro...
26
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transfo...
432
'''simple docstring''' import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy ...
294
0
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE = 10**9 ) -> int: SCREAMING_SNAKE_CASE_ : Union[str, Any] = 1 SCREAMING_SNAKE_CASE_ : Union[str, Any] = 2 SCREAMING_SNAKE_CASE_ : List[str] = 0 SCREAMING_SNAKE_CASE_ : str = 0 SCREAMING_SNAKE_CASE_ ...
311
from string import ascii_lowercase, ascii_uppercase def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ) -> str: if not sentence: return "" SCREAMING_SNAKE_CASE_ : int = dict(zip(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) ) return lower_to_upper.get(sentence[0]...
311
1
import importlib import inspect import os import re # 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 _lowerCAmelCase = """src/transformers""" # This is to make sure the transformers module imported ...
137
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging _lowerCAmelCase = logging.get_logger(__name__) def lowercase ( _a=None ,_a=None ) -> List[Any]: return field...
137
1
'''simple docstring''' def UpperCamelCase ( __lowercase : int ): '''simple docstring''' A_ : List[str] = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
718
import random def UpperCamelCase ( __lowercase : int ): '''simple docstring''' A_ : Tuple = num - 1 A_ : Optional[Any] = 0 while s % 2 == 0: A_ : Optional[int] = s // 2 t += 1 for _ in range(5 ): A_ ...
70
0
'''simple docstring''' def a ( _UpperCAmelCase ) -> Union[str, Any]: """simple docstring""" a_ = '' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def a ( _Uppe...
697
'''simple docstring''' from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging ...
446
0
"""simple docstring""" import os import unittest from transformers import MobileBertTokenizer, MobileBertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from tra...
292
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available snake_case_ : Dict = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfi...
292
1
'''simple docstring''' def lowerCAmelCase_ ( snake_case_ : int , snake_case_ : int ) -> Union[str, Any]: '''simple docstring''' if b == 0: return 1 if (b % 2) == 0: return actual_power(snake_case_ , int(b / 2 ) ) *...
78
'''simple docstring''' import requests def lowerCAmelCase_ ( snake_case_ : str , snake_case_ : str ) -> None: '''simple docstring''' UpperCAmelCase_ = {"Content-Type": "application/json"} UpperCAmelCase_ = requests.post(snake...
78
1
def A ( _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : int = len(_lowerCamelCase ) for i in range(1 , _lowerCamelCase ): _lowerCAmelCase : List[Any] = collection[i] ...
658
from __future__ import annotations def A ( _lowerCamelCase ): '''simple docstring''' if not nums: raise ValueError("List is empty" ) return sum(_lowerCamelCase ) / len(_lowerCamelCase ) if __name__ == "__main__": import ...
658
1
'''simple docstring''' from __future__ import annotations def a ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , ) -> None: """simple docstring""" a_ = len(_UpperCAmelCase ) # If row is ...
697
'''simple docstring''' def a ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase=False ) -> Optional[Any]: """simple docstring""" if isinstance(_UpperCAmelCase , _UpperCAmelCase ) and isinstance(_UpperCAmelCase , _UpperCAmelCase ): ...
697
1
import torch from diffusers import StableDiffusionPipeline _A = '''path-to-your-trained-model''' _A = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to('''cuda''') _A = '''A photo of sks dog in a bucket''' _A = pipe(prompt, num_infe...
708
import torch from transformers import AutoModel class A ( torch.nn.Module ): def __init__( self, UpperCamelCase__="sayef/fsner-bert-base-uncased" ): """simple docstring""" super(UpperCamelCase__, self ).__init__() lowerCAmelCase_ = AutoMo...
325
0
'''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...
133
'''simple docstring''' class SCREAMING_SNAKE_CASE__ ( lowercase_ ): pass class SCREAMING_SNAKE_CASE__ ( lowercase_ ): pass class SCREAMING_SNAKE_CASE__ : def __init__( self: Optional[Any]) ->List[str]: '''simple docstring''' a_ = [ ...
685
0
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class UpperCamelCase_ ( ...
700
"""simple docstring""" from math import asin, atan, cos, radians, sin, sqrt, tan a__ : List[str] = 6_37_81_37.0 a__ : Tuple = 6_35_67_52.31_42_45 a__ : str = 6_3_7_8_1_3_7 def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ ,...
553
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mob...
406
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __a ( lowerCAmelCase_ : Dict ) -> List[Any]: ...
593
0
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch...
136
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class lowerCAmelCase_ : def __init__( self : List[str], _snake_case : int ): '''simple docstring''' snake_case : Optional[...
136
1
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.f...
136
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(...
136
1
import os import re import shutil import sys import tempfile import unittest import black a :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 check_copies # noqa: E402 # This is the reference code that will be...
718
"""simple docstring""" import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...
12
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a__ : Any = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerCo...
51
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a__ : Any = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
51
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available UpperCAmelCase_ = { '''configuration_audio_spectrogram_transformer''': [ '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AS...
701
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { '''BridgeTower/bridgetower-base''': '''https://huggingface.co/BridgeTower/bridge...
476
0
'''simple docstring''' import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase fro...
474
'''simple docstring''' import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) lowerCamelCase = loggin...
474
1
'''simple docstring''' _lowerCamelCase : Dict = 8.3_144_598 def _lowerCAmelCase ( __a , __a ) -> float: '''simple docstring''' if temperature < 0: raise Exception("""Temperature cannot be less than 0 K""" ) if molar_m...
512
'''simple docstring''' import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () _lowerCamelCase : Optional[int] = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two f...
512
1
from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging _A ...
100
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow snake_case__ = logging.getLogger() @unittest.skip('Temporarily disable the doc tests.') @require_t...
395
0
from collections import OrderedDict from typing import Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...feature_extraction_utils import FeatureExtractionMixin from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...tokenization_utils...
715
import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem UpperCamelCase : Dict = importlib.util.find_spec("""s3fs""") is not None if _has_safs: from .safilesystem ...
151
0
'''simple docstring''' _snake_case = { 'km/h': 1.0, 'm/s': 3.6, 'mph': 1.6_0_9_3_4_4, 'knot': 1.8_5_2, } _snake_case = { 'km/h': 1.0, 'm/s': 0.2_7_7_7_7_7_7_7_8, 'mph': 0.6_2_1_3_7_1_1_9_2, 'knot': 0.5_3_9_9_5_6_8_0_3, } def _A ( snake_case , ...
245
'''simple docstring''' 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_num...
603
0
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class a ( unittest.TestCase ,_UpperCame...
713
'''simple docstring''' from __future__ import annotations import math def A ( A_ : int ): if num <= 0: snake_case : List[Any] = F"""{num}: Invalid input, please enter a positive integer.""" raise ValueError(A_ ) snake_case ...
555
0
'''simple docstring''' from __future__ import annotations from cmath import sqrt def _a ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ) -> tuple[complex, complex]: """simple docstring""" if a == 0: raise ValueError("""C...
26
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class __lowerCAmelCase ( lowerCAmelCase__ ): def __init__( self , __UpperCAmelCase , __UpperCAmelCase = None ...
175
0
"""simple docstring""" 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 lowerCAmelCase__ : int = ...
712
"""simple docstring""" import re def a_ ( lowerCamelCase ): return [char.split() for char in re.split(r'[^ a-z A-Z 0-9 \s]' , str_ )] def a_ ( lowerCamelCase ): UpperCAmelCase__ = split_input(str_ ) return "".join( [''.join([char.capitalize() for ...
632
0
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common ...
87
from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('''To use the rich extension, install rich with `pip install rich`''')
36
0
import unittest import numpy as np from transformers import BertConfig, 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(): from transfo...
643
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import ...
643
1
"""simple docstring""" from __future__ import annotations from statistics import mean def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE : list[int] , SCREAMING_SNAKE_CASE : list[int] , SCREAMING_SNAKE_CASE : int ): '''simple docs...
179
"""simple docstring""" from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTest...
179
1
'''simple docstring''' import math import sys def UpperCAmelCase__ ( UpperCAmelCase__ ) -> int: if number != int(UpperCAmelCase__ ): raise ValueError("""the value of input must be a natural number""" ) if number < 0: raise Val...
714
'''simple docstring''' 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, ge...
667
0
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...feat...
35
import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available a_ :List[Any] = logging.getLogger(__name__) @dataclass class ...
35
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "SCUT-DLVCLab/lilt-roberta-en-base": ( "https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.json" ...
708
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils im...
352
0
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter UpperCamelCase_ = True excep...
132
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def SCREAMING_SNAKE_CASE ( snake_case__ , snake_c...
132
1
def a ( snake_case__: Union[str, Any] , snake_case__: Optional[Any] , snake_case__: Optional[Any] , snake_case__: Tuple ): '''simple docstring''' if graph[path[curr_ind - 1]][next_ver] == 0: return False # 2. Validate that next vert...
707
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...tes...
409
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() ...
201
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { 'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json', } class lowerCamelCas...
201
1
"""simple docstring""" # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def UpperCamelCase_ ( lowerCamelCase : Optional[int] , lowerCamelCase : Tuple , lowerCamelCase : List[Any] , lowerCamelCase : Tuple ) -> Dict: ...
147
"""simple docstring""" import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow A = logging.getLogger() @unittest.skip('Temporarily disable the doc tests.' ) @require...
147
1
'''simple docstring''' from ... import PretrainedConfig __snake_case : int = { '''sijunhe/nezha-cn-base''': '''https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json''', } class lowercase_ ( __lowerCamelCase ): a_ = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP a_ ...
660
import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig lowerCamelCase_ = { "facebook/maskformer-swin-base-ade": ( "https://huggi...
151
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, ...
474
'''simple docstring''' import requests from bsa import BeautifulSoup def __magic_name__( lowerCamelCase, lowerCamelCase): __lowerCAmelCase = BeautifulSoup(requests.get(lowerCamelCase, params=lowerCamelCase).content, '''html.parser''') __lowerCAmelCase ...
474
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionXLIm...
474
'''simple docstring''' def _A ( _lowerCAmelCase = 50 ): """simple docstring""" __lowercase =[[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for t...
474
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule UpperCamelCase__ = {'tokenization_wav2vec2_phoneme': ['Wav2Vec2PhonemeCTCTokenizer']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys UpperCamelCase__ = _LazyMo...
711
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { 'abeja/gpt-neox-japanese-2.7b': 'https://huggingface.co/abeja/gpt-neox-japanese-2.7b/resolve/main/config.json', } class ...
640
0
'''simple docstring''' import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def __UpperCamelCase ( UpperCAmelCase = 8 ): lowercase__ : List[str] = ascii_letters + digits + punctuation return "".join(secrets.ch...
152
import pytest import datasets # Import fixture modules as plugins a__: Dict = ['tests.fixtures.files', 'tests.fixtures.hub', 'tests.fixtures.fsspec'] def UpperCamelCase__( UpperCamelCase__ : List[Any] , UpperCamelCase__ : Tuple )->List[str]: # M...
190
0
"""simple docstring""" def snake_case__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->Union[str, Any]: UpperCAmelCase__ = word.split() def justify(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> str: UpperCAmelCase__ = max_wid...
704
"""simple docstring""" import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class _UpperCamelCase ( __UpperCamelCase ): '''simple docstring''' def A__ ( self , __lowercase ): with open(__lowercase , encoding="...
422
0
'''simple docstring''' import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_iden...
582
'''simple docstring''' import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node SCREAMING_SNAKE_CASE_ = 4 SCREAMING_SNAKE_CASE_ = 3 class lowerCAmelC...
582
1
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common imp...
703
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase : str = { 'configuration_vision_encoder_decoder': ['VisionEncoderDecoderConfig', 'VisionEnco...
94
0
'''simple docstring''' from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent lowerCAmelCase :List[Any] = {'''UserAgent''': UserAgent().random} def lowerCamelCase ( lowerCAmelCase : Tuple ): ...
561
'''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 TFModelTesterMixin, fl...
561
1
"""simple docstring""" from __future__ import annotations def SCREAMING_SNAKE_CASE ( __UpperCAmelCase , __UpperCAmelCase ) -> list[list[int]]: SCREAMING_SNAKE_CASE__ = [] create_all_state(1 , __UpperCAmelCase , __UpperCAmelCase , [] , ...
538
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image ...
538
1
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 RoFormerTokeni...
592
import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { 'xlnet-base-cased': 'https://huggingface.co/xlnet-base-cased/resolve/main/config.json', 'xlnet-large-c...
592
1
'''simple docstring''' import importlib.metadata import operator import re import sys from typing import Optional from packaging import version snake_case_ = { """<""": operator.lt, """<=""": operator.le, """==""": operator.eq, """!=""": operator.ne, """>=""": operator.ge, """>""":...
704
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { """facebook/nllb-moe-54B""": """https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json""", } class a__ ( _lo...
355
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE :Union[str, Any] = { """configuration_mobilenet_v2""": [ """MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Mobil...
628
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> str: """simple docstring""" if isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(SCREAMING_SNAKE_CASE_ , ...
628
1
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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamplin...
520
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
520
1
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( ...
454
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _lowerCAmelCase : Optional[int] = logging.get_logger(__name__) _lowerCAmelCase : List[str] = { '''google/umt...
454
1
'''simple docstring''' import re def UpperCAmelCase ( lowerCamelCase_ :str ): '''simple docstring''' snake_case_ : str = re.compile( R"""^(?:0|94|\+94|0{2}94)""" R"""7(0|1|2|4|5|6|7|8)""" R"""(-| |)""" R"""\d{7}$""" ) return bool(re.search(_lowerCamelCase ...
706
'''simple docstring''' import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START...
267
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 transform...
601
'''simple docstring''' import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow ...
601
1
"""simple docstring""" from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.sche...
147
"""simple docstring""" def UpperCamelCase_ ( lowerCamelCase : float ) -> float: """simple docstring""" return 10 - x * x def UpperCamelCase_ ( lowerCamelCase : float , lowerCamelCase : float ) -> float: """simpl...
147
1
'''simple docstring''' def lowercase__ ( __UpperCamelCase : List[Any] , __UpperCamelCase : Any ): '''simple docstring''' __lowercase = len(__UpperCamelCase ) print("""The following activities are selected:""" ) # The first activity is always selec...
566
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available A_ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: A_ = ["MLukeTokeniz...
393
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase = { """configuration_lilt""": ["""LILT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LiltConfig"""], } try: if not is_torch_available()...
323
'''simple docstring''' from typing import Any def a__ ( _SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE : dict , _SCREAMING_SNAKE_CASE : dict , _SCREAMING_SNAKE_CASE : dict , ) ->...
323
1
"""simple docstring""" import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table imp...
200
"""simple docstring""" import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from ...
200
1
from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class __A ( UpperCamelCase__ ): def __lt__( self :List[Any] , __snake_case :Dict ): '''simple docstring''' ...
367
UpperCAmelCase_ : int = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] ...
367
1
import qiskit def _lowerCAmelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> List[str]: '''simple docstring''' __snake_case = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit acting on the q register _...
371
'''simple docstring''' # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.vers...
211
0
"""simple docstring""" import flax.linen as nn import jax import jax.numpy as jnp class _lowerCAmelCase ( nn.Module ): __lowerCAmelCase : int __lowerCAmelCase : jnp.dtype = jnp.floataa def _lowerCAmelCase ( self : Any ) -> ...
718
"""simple docstring""" import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvis...
396
0