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""" from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vis...
346
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : Any = {"""configuration_xlnet""": ["""XLNET_PRETRAINED_CONFI...
87
0
'''simple docstring''' import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class a ( unittest.TestCase ): '''simple docstring''' def __UpperCamelCase ( self ) -> None: _a ...
424
'''simple docstring''' 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_ : Any = { "YituT...
424
1
def UpperCamelCase_ ( __a , __a , __a , __a ) -> List[Any]: if height >= 1: move_tower(height - 1 , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) move_disk(__UpperCamelCase , __UpperCamelCase ) move_to...
37
'''simple docstring''' from __future__ import annotations import time import numpy as np snake_case : List[str] = [8, 5, 9, 7] snake_case : int = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] snake_case : Optional[Any] = [ [3, 2, 1, 4...
566
0
from math import sqrt def lowerCamelCase_ ( lowerCAmelCase__ : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negati...
224
from __future__ import annotations def lowerCamelCase_ ( lowerCAmelCase__ : int = 4 ) -> list[list[int]]: '''simple docstring''' A = abs(lowerCAmelCase__ ) or 4 return [[1 + x + y * row_size for x in range(lowerCAmelCase__ )] for y in ran...
224
1
'''simple docstring''' from manim import * class snake_case__ ( snake_case_): def A ( self : Any ) -> Any: UpperCAmelCase_ : List[str] = Rectangle(height=0.5 , width=0.5 ) UpperCAmelCase_ : Dict ...
541
"""simple docstring""" import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSche...
178
0
"""simple docstring""" from __future__ import annotations def lowercase (_snake_case ,_snake_case ) -> bool: '''simple docstring''' if len(_snake_case ) == 0: return False __UpperCamelCase = len(_snake_case ) // 2 if a_list[midpoint] == item: return True if it...
228
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments ...
228
1
'''simple docstring''' from collections import defaultdict def snake_case ( a_ : Optional[int] , a_ : List[Any] ) -> bool: """simple docstring""" UpperCamelCase_ : Any = first_str.lower().strip() UpperCamelCase_ : List[Any]...
208
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
9
0
'''simple docstring''' import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, Musicg...
707
'''simple docstring''' from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docs...
98
0
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __A : Optional[int] = TypeVar('''T''') class _UpperCAmelCase ( Generic[T] ): def __init__( self ...
231
"""simple docstring""" import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def lowercase ( __snake_case ...
231
1
'''simple docstring''' from __future__ import annotations import typing from collections import Counter def _a ( lowerCAmelCase_ ): """simple docstring""" _snake_case : typing.Counter[int] = Counter() for base in range(1 , max_perimeter + 1 ): ...
717
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation Up...
47
0
from math import pi, sqrt, tan def UpperCamelCase_( lowerCamelCase_ ) -> float: if side_length < 0: raise ValueError('surface_area_cube() only accepts non-negative values' ) return 6 * side_length**2 def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ,...
89
from __future__ import annotations def UpperCAmelCase ( UpperCAmelCase ,UpperCAmelCase ,UpperCAmelCase )-> dict[str, float]: '''simple docstring''' if (voltage, current, resistance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0''' ...
393
0
'''simple docstring''' import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever SCREAMING_SNAKE_CASE_: List[str] =logging.getLogger(__name__) class __A ( UpperCamelCase__ ): ...
415
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_: Dict ={ 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Au...
415
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig SCREAMING_SNAKE_CASE__ : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : str = { """Intel/dpt-large""": """https://huggingface.co/Intel/dpt-large/reso...
0
'''simple docstring''' import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing impor...
536
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( Au...
136
'''simple docstring''' from __future__ import annotations from statistics import mean def _a ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ ): snake_case : Dict =[0] * no_of_processes snake_case : Dict =[0] * no_of_processes # Initialize r...
136
1
import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils import is_torc...
377
'''simple docstring''' import json import sys def a__ ( _SCREAMING_SNAKE_CASE : Optional[Any] , _SCREAMING_SNAKE_CASE : int ) -> Tuple: """simple docstring""" with open(_SCREAMING_SNAKE_CASE , encoding="utf-8" ) as f: UpperCAmelCase_ : ...
71
0
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, resize, to_channel_dim...
702
import os import re 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 : Dict = logging.get_logger(__name__) __lowerCamelCase :...
448
0
'''simple docstring''' 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.co...
596
'''simple docstring''' import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNe...
596
1
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, req...
720
import qiskit def _UpperCAmelCase ( UpperCAmelCase : int , UpperCAmelCase : int ): """simple docstring""" __lowerCamelCase : Dict = qiskit.Aer.get_backend("""aer_simulator""" ) __lowerCamelCase : ...
458
0
import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import tensorflow as tf from to...
165
from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline a__ : Union[str, Any] = logging.get_logger(__name__) class lowerc...
165
1
'''simple docstring''' import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : Any = logging.get_logger(__name__) UpperCAmelCase : Union[str, Any] = { 'xlnet-base-cased': 'https://huggingface.co/xlnet-base-cased/resolve/mai...
47
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar UpperCAmelCase : Any = TypeVar('T') UpperCAmelCase : str = TypeVar('U') class lowerCamelCase (Generic[T, U] ): def __init__( self ...
47
1
import os # Precomputes a list of the 100 first triangular numbers a = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def UpperCAmelCase_ ( ): lowercase_ = os.path.dirname(os.path.realpath(_UpperCAmelCase ) ) lowercase_ = os.path.join(_UpperCAmelCase , """w...
412
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : list , _UpperCAmelCase : list , _UpperCAmelCase ...
4
0
'''simple docstring''' from sklearn.metrics import fa_score import datasets _UpperCamelCase : Optional[int] ="\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n" _UpperCamelCase :...
707
'''simple docstring''' import functools def lowerCamelCase_ ( A_ , A_ ): __lowerCamelCase = len(A_ ) __lowerCamelCase = len(A_ ) @functools.cache def min_distance(A_ , A_ ) -> int: # if first word index is overflow - delete all fro...
575
0
'''simple docstring''' def lowercase__( __UpperCamelCase: int ): """simple docstring""" if not isinstance(__UpperCamelCase ,__UpperCamelCase ): raise TypeError('Input value must be an \'int\' type' ) SCREAMING_SNAKE_CASE : i...
28
'''simple docstring''' import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedu...
440
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { "caidas/swin2sr-classicalsr-x2-64": ( "https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/ma...
695
'''simple docstring''' def UpperCamelCase( UpperCAmelCase_ , UpperCAmelCase_ ): return [sentence[i : i + ngram_size] for i in range(len(UpperCAmelCase_ ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
695
1
'''simple docstring''' def SCREAMING_SNAKE_CASE ( a_ : int ): 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 or not...") Upp...
539
'''simple docstring''' import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_g...
539
1
"""simple docstring""" from __future__ import annotations def __a ( A = 4 ): '''simple docstring''' lowercase__ = abs(lowercase_ ) or 4 return [[1 + x + y * row_size for x in range(lowercase_ )] for y in range(lowercase_ )] def __a ( ...
707
"""simple docstring""" from typing import Any import numpy as np def __a ( A ): '''simple docstring''' return np.array_equal(A , matrix.conjugate().T ) def __a ( A , A ): '''simple docstring''' lowercase__ = v.co...
668
0
"""simple docstring""" from collections import namedtuple UpperCAmelCase__ = namedtuple("""from_to""", """from_ to""") UpperCAmelCase__ = { """cubicmeter""": from_to(1, 1), """litre""": from_to(0.001, 1_0_0_0), """kilolitre""": from_to(1, 1), """gallon""": from_to(0.0_0454, 264.172), "...
277
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { """Intel/dpt-large""": """https://huggingface.co/Intel/dpt-large/resolve/main/config.js...
277
1
import os import sys _lowerCAmelCase : Optional[int] = os.path.join(os.path.dirname(__file__), "src") sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoModelForSequenceClassi...
364
import torch from transformers import AutoModel class _UpperCamelCase ( torch.nn.Module ): def __init__( self :str , lowerCamelCase :Tuple="sayef/fsner-bert-base-uncased" ) -> int: super(lowerCamelCase , self ).__init__() UpperCAmelCase__ = ...
364
1
"""simple docstring""" class __snake_case : def __init__( self: List[Any] ): __lowerCamelCase = {} def __a ( self: Optional[Any] ): print(self.vertex ) for i in self.vertex: print(A_ ...
281
'''simple docstring''' import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_...
158
0
'''simple docstring''' import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class lowerCAmelCase ( unittest.TestCase ): def lowercase ( self ): debug_launcher(test_script.main ) def ...
646
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCamelCase ( _A : np.ndarray , _A : float ) -> np.ndarray: """simple docstring""" lowerCAmelCase : Union[str, Any] = math.sqrt(_A ) lowerCAmelCase : ...
646
1
'''simple docstring''' import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class lowercase_ : """simple docstring""" @prop...
41
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel _snake_case : Tuple = False _snake_case : Optional[int] = True _snake_case : Any = False ...
441
0
'''simple docstring''' from __future__ import annotations class _A : '''simple docstring''' def __init__( self : int , lowerCamelCase : int )-> None: snake_case__ : int = order # a_{0} ... a_{k} snake_...
719
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqa...
172
0
from math import ceil def __UpperCamelCase ( A , A ): UpperCamelCase__ = list(range(0 , A ) ) UpperCamelCase__ = [item for sublist in list(device_map.values() ) for item in sublist] # Duplicate check UpperCamelCase__ ...
415
from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_co...
415
1
'''simple docstring''' def snake_case_ ( a__ : int ,a__ : int ): """simple docstring""" return int((input_a, input_a).count(1 ) != 0 ) def snake_case_ ( ): """simple docstring""" assert or_gate(0 ,0 ) == ...
163
'''simple docstring''' from statistics import mean, stdev def snake_case_ ( a__ : list ,a__ : int = 3 ): """simple docstring""" __lowercase = min(a__ ) __lowercase = max(a__ ) # normalize data return [round((x - x_...
163
1
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging UpperCamelCase_ = logging.get_logger(__name__) def _UpperCAmelCase ( UpperCamelCase: Union[tf.Tensor, np.ndarray] ): """simple docstring""" if isinstance(UpperCamelCase ...
611
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...image_pr...
611
1
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def snake_case ( UpperCAmelCase : Tuple ): def wrapper(*UpperCAmelCase : List[str], **UpperCAmelCase : str ): ...
110
from math import factorial class UpperCamelCase : """simple docstring""" def __init__( self : Any ,_SCREAMING_SNAKE_CASE : List[Any] ,_SCREAMING_SNAKE_CASE : List[str] ) -> List[str]: '''simple docstring''' A = real if isinstance(...
110
1
'''simple docstring''' from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_t...
44
from __future__ import annotations import math import random from typing import Any class __lowerCAmelCase : '''simple docstring''' def __init__( self: Dict ): lowercase__ : list[Any] = [] lowercase__ : int = 0 lower...
266
0
'''simple docstring''' import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels __lowerCamelCase = object() # For specifying empty leaf dict `{}` __lowerCamelCase = object...
711
'''simple docstring''' from __future__ import annotations import math def UpperCAmelCase__ ( UpperCAmelCase__ ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Ne...
667
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { """google/pix2struct-textcaps-base""": ( """https://huggingface.co/google/pix2struct-textcaps-base/resolv...
175
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def a__ ( _UpperCamelCase : List[Any] ): if "cls_token" in name: __lowerCamelCase = name.replace('''cls_token''' ,'''vit...
175
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.se...
687
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __snake_case : Optional[int] = { 'configuration_convbert': ['CONVBERT_PRETRAINED_CONFIG_...
687
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCAmelCase : List[str] = { '''configuration_data2vec_audio''': ['''DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Data...
107
"""simple docstring""" import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logg...
680
0
"""simple docstring""" def snake_case__ ( _lowerCamelCase ) ->bool: """simple docstring""" __lowercase : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack __lowercase : set[int] = set() ...
704
"""simple docstring""" def snake_case__ ( _lowerCamelCase ) ->int: """simple docstring""" if a < 0: raise ValueError("Input value must be a positive integer" ) elif isinstance(_lowerCamelCase, _lowerCamelCase ): raise TypeError("Input value must be a 'int' t...
281
0
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, ) _lowerCamelCase = pytest.mark.integration @pytest.mark.parametrize("""path""" , ["""paw...
6
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils i...
229
0
import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("9.1.0"): lowerCamelCase ={ "linear": PIL.Image.Resampling.BILINEAR, "bilinear": PIL.Image.Resampling.BILINEAR, "bic...
462
import math def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ ): UpperCamelCase__ : List[str] = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(UpperCamelCase__ ) def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ = 1 / 1_2_3_4_5 ):...
462
1
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( lowerCAmelCase__): _low...
123
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __lowercase ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): ...
123
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) snake_case_ : List[str] = { '''configuration_trocr''': ['''TROCR_PRETRAINED_CONFIG_ARCHIVE_MA...
709
import os import unittest from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class A_...
191
0
import json import os import shutil import tempfile import unittest from transformers import BatchEncoding, CanineTokenizer from transformers.testing_utils import require_tokenizers, require_torch from transformers.tokenization_utils import AddedToken from transformers.utils import cached_property from ...test_tok...
37
"""simple docstring""" import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed ...
223
0
"""simple docstring""" # flake8: noqa # Lint as: python3 lowerCAmelCase__ = [ '''VerificationMode''', '''Version''', '''disable_progress_bar''', '''enable_progress_bar''', '''is_progress_bar_enabled''', '''experimental''', ] from .info_utils import VerificationMode from ....
681
"""simple docstring""" import math def a__ ( SCREAMING_SNAKE_CASE : int ): '''simple docstring''' return math.sqrt(SCREAMING_SNAKE_CASE ) * math.sqrt(SCREAMING_SNAKE_CASE ) == num def a__ ( SCREAMING_SNAKE_CASE : int ): '''...
681
1
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """google/umt5-small""": """https://huggingface.co/go...
558
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, ) _UpperCAmelCase = pytest.mark.integration @pytest.mark.parametrize('path' ,['...
558
1
"""simple docstring""" from __future__ import annotations def __lowercase ( lowerCamelCase_ : int = 4 ): SCREAMING_SNAKE_CASE__ = abs(lowerCamelCase_ ) or 4 return [[1 + x + y * row_size for x in range(lowerCamelCase_ )] for y in range(lowerCamelCase_ )...
719
"""simple docstring""" import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accele...
112
0
"""simple docstring""" import pprint import requests lowerCamelCase_ = '''https://zenquotes.io/api''' def snake_case ( ): return requests.get(API_ENDPOINT_URL + "/today" ).json() def snake_case ( ): return requests.get(API_ENDPOINT_URL + "/random" ).json() if __name__ ==...
95
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { '''vinvino02/glpn-kitti''': '''https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json''', # See all GLPN models ...
351
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable __lowercase = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DPTConfig"""]} try: if no...
700
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ....tokenization_utils_fast import PreTrainedTokenizerFast from ....utils import logging from .tokenization_retribert import RetriBertTokenizer __lowercase = logging.get_logger(__name__) __lowercase = {...
563
0
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : str ): '''simple docstring''' _UpperCAmelCase = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_n...
602
"""simple docstring""" import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils impor...
602
1
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging lowerCAmelCase = logging.get_logger(__name__) def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) ...
675
import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch lowerCAmelCase = """sshleifer/bart-tiny-random""" lowerCAme...
675
1
'''simple docstring''' import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel lowercase__ : List[str] = { 'text_branch': 'text_model', 'audio_branch': 'audio_model.audio_encoder', 'attn': 'attention.se...
98
'''simple docstring''' def a__ ( lowercase : str ) -> int: """simple docstring""" assert column_title.isupper() _UpperCamelCase = 0 _UpperCamelCase = len(lowercase ) - 1 _UpperCamelCase = 0 while index >=...
98
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """bigcode/gpt_bigcode-santacoder""": """https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json""", } ...
707
'''simple docstring''' import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testing_utils import require...
162
0
'''simple docstring''' import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": lowerCamelCase : Tuple = argparse.ArgumentParser( description=( 'Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for T...
460
'''simple docstring''' from __future__ import annotations from collections import deque class __lowerCAmelCase : '''simple docstring''' def __init__(self : str , UpperCamelCase : list[str] ): '''simple docstring''' lowercas...
460
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ...
705
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INP...
52
0
import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version from torch import nn f...
105
import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class lowercase__ (__snake_case ): """simple docstring""" __UpperCamelCase : Any = (CMStochasticIterativeScheduler,) __UpperCa...
648
0
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class __lowerCAmelCase ( lowerCAmelCase_ ): """simple docstring""" A__ : Optional[Any] = (DDPMScheduler,) def snake_case_ ( self...
284
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class __lowerCAmelCase ( unittest.TestCase ):...
284
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCamelCase ( metaclass=lowercase_ ): lowercase = ['keras_nlp'] def __init__( self ,*__UpperCamelCase ,**__UpperCamelCase ) -> Optional[int]: '''simple docstring''' ...
425
"""simple docstring""" import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def lowercase__( __SCREAMING_SNAKE_CASE : Any , __SCREAMING_SNAKE_CASE : L...
425
1
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from...
291
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
291
1
'''simple docstring''' def _lowerCAmelCase ( __magic_name__ : str ) -> bool: if not all(x.isalpha() for x in string ): raise ValueError('''String must only contain alphabetic characters.''' ) lowercase : List[Any] =sorted(string.lower() ...
92
def lowercase ( _a ) -> int: if not isinstance(_a ,_a ) or number < 0: raise ValueError("Input must be a non-negative integer" ) UpperCAmelCase_: List[Any] = 0 while number: # This way we arrive at next set bit (next 1) instead of looping # through ea...
137
0
'''simple docstring''' def lowercase_ ( _lowercase = 1_000_000 ) -> int: '''simple docstring''' lowerCamelCase_ : str = set(range(3 , _lowercase , 2 ) ) primes.add(2 ) for p in range(3 , _lowercase , 2 ): if p not...
702
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def lowercase_ ( _lowercase ) -> list[list[float]]: '''simple docstring''' lowerCamelCase_ : Tuple = Decimal # Check if the provided matrix has 2 rows and ...
357
0
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) _SCREAM...
550
class A__ : """simple docstring""" def __init__( self , __snake_case ): snake_case = n snake_case = [None] * self.n snake_case = 0 # index of the first element snake_case ...
550
1
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__ = '...
712
'''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 lowerCAmelCase__ = logging.getLogger() @unittest.s...
172
0
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, ...
33
'''simple docstring''' import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging lowercase__ = logging.get_logger(__name__) # pylint: disable=invalid-name class Up...
508
0
"""simple docstring""" import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py lowerCamelCase__ = '''src/transfor...
721
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGenerat...
51
0
"""simple docstring""" from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be check...
535
"""simple docstring""" 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 .....
222
0
'''simple docstring''' __lowerCamelCase : Tuple = """Input must be a string of 8 numbers plus letter""" __lowerCamelCase : Any = """TRWAGMYFPDXBNJZSQVHLCKE""" def __snake_case (__UpperCAmelCase ): """simple docstring""" if not isinstance(__UpperCAme...
418
'''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...
418
1
"""simple docstring""" import requests def _UpperCAmelCase ( lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" lowerCAmelCase__ = {"""Content-Type""": """application/json"""} lowerCAmelCase__ = requests.post(lowerCAmelCase__ , json={"""text""": message_bod...
644
"""simple docstring""" import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def lowercase ( lowerCAmelCase__ ): def wrapper(*lowerCAmelCase__ ,**lowerCAmelCase__ ): lowerCamelCase_ = timeit...
29
0
from __future__ import annotations from math import pow, sqrt def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ) -> dict[str, float]: '''simple docstring''' if (resistance, reactance, impedance).count(0 ) != 1: raise ValueEr...
675
from random import shuffle import tensorflow as tf from numpy import array def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> Optional[int]: '''simple docstring''' __UpperCAmelCase : Optional[Any] = int(lowercase_ ) assert noofclust...
675
1
import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex lowercase : Tuple = logging.getLogger(__name__) class a__ : def __init__( self ...
423
def UpperCAmelCase_ ( _UpperCAmelCase ): lowerCamelCase_: Any = current_set.copy() for row_index, row in enumerate(_UpperCAmelCase ): lowerCamelCase_: Optional[Any] = row[0] for column_index, column in enumerate(_UpperCAmelCase ): ...
423
1
import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def UpperCamelCase__ ( _A: Optional[in...
718
from __future__ import annotations import unittest from transformers import RoFormerConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask ...
571
0
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available():...
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
from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy A : str = logging.get_logger(__name__) class lowerCame...
356
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.set_ver...
356
1
import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester f...
14
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class...
14
1
from __future__ import annotations from typing import TypedDict class a__ ( lowerCAmelCase_ ): lowerCamelCase__: str lowerCamelCase__: int def _a ( __UpperCamelCase ): if not isinstance(__UpperCamelCase , __UpperCamelCase ): raise TypeError("""The parame...
478
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers.testing_utils import DUMMY_UNKNOWN_IDENT...
478
1
'''simple docstring''' import math import qiskit def UpperCamelCase__ ( lowerCAmelCase = 1 , lowerCAmelCase = 1 , lowerCAmelCase = 1 ): """simple docstring""" if ( isinstance(__a , __a ) or isinstance(__a...
207
"""simple docstring""" from typing import TYPE_CHECKING from ..utils import _LazyModule UpperCamelCase_ : Dict = { '''config''': [ '''EXTERNAL_DATA_FORMAT_SIZE_LIMIT''', '''OnnxConfig''', '''OnnxConfigWithPast''', '''OnnxSeq2SeqConfigWithPast''', ...
115
0
'''simple docstring''' import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTok...
718
'''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, B...
474
0
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = {"configuration_mmbt": ["MMBTConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAva...
201
'''simple docstring''' import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mod...
120
0
import math import tensorflow as tf from packaging import version def __a ( A__ : Any ): SCREAMING_SNAKE_CASE = tf.convert_to_tensor(A__ ) SCREAMING_SNAKE_CASE = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 ) , x.dtype ) )) ...
698
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging __A : Optional[int] = logging.get_...
698
1
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_available(check_device=False)...
64
def A__ ( snake_case_ : float , snake_case_ : float ): if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": import do...
64
1
'''simple docstring''' def lowerCamelCase__ ( _A = 1000 ): a : str = 2**power a : Optional[Any] = str(_A ) a : List[Any] = list(_A ) a : Optional[Any] = 0 for i in list_num: sum_of_num += int(_A ) return sum_of_n...
195
'''simple docstring''' class a__: def __init__( self : Dict , __snake_case : Optional[int] , __snake_case : Any , __snake_case : Tuple ): a : List[str] = name a : Dict = value a : List[str] ...
195
1
"""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__ = logging.get_logger(__na...
624
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCamelCase__ = { "configuration_resnet": ["RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "ResNetConfi...
624
1
"""simple docstring""" import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_param...
703
"""simple docstring""" 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 __snake_ca...
158
0
'''simple docstring''' def snake_case ( a_ : int ) -> int: """simple docstring""" if n == 1 or not isinstance(a_ , a_ ): return 0 elif n == 2: return 1 else: UpperCamelCase_ : Dict = [0, 1...
208
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): ...
208
1
"""simple docstring""" import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class lowerCAmelCase_ ( _lowercase ): '''simple docstring''' _lowerCamelCase: Dict = '''MCTCTFeatureExtractor''' _lowerCamelCase: Op...
22
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class lowerCAmelCase_ : '''simple docstring''' def __init__( self : Dict ) -> int: A = {} def _SCREAMING_SNAKE_...
22
1
import numpy as np a_ = [ ['''a''', '''b''', '''c''', '''d''', '''e'''], ['''f''', '''g''', '''h''', '''i''', '''k'''], ['''l''', '''m''', '''n''', '''o''', '''p'''], ['''q''', '''r''', '''s''', '''t''', '''u'''], ['''v''', '''w''', '''x''', '''y''', '''z'''], ] class lowercase__ ...
339
from __future__ import annotations def _a ( UpperCamelCase_ : list[int] , UpperCamelCase_ : int ) -> list[int]: """simple docstring""" lowerCAmelCase__ = 0 lowerCAmelCase__ = len(UpperCamelCase_ ) - 1 while i < j: if ...
339
1
def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase ): if discount_rate < 0: raise ValueError("Discount rate cannot be negative" ) if not cash_flows: raise ValueError("Cash flows list cannot be empty" ) __snake_case : int ...
701
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, StableDiffusionXLImgaImgPipeline, UNetaDCo...
203
0
import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = '''▁''' __snake_c...
1
import random from .binary_exp_mod import bin_exp_mod def _A ( __snake_case :List[Any] , __snake_case :Union[str, Any]=1000 ) -> int: """simple docstring""" if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __...
693
0
from __future__ import annotations __magic_name__ = list[list[int]] # assigning initial values to the grid __magic_name__ = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], ...
700
from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase , __lowerCAmelCase ): if len(__lowerCAmelCase ) == 0: return False snake_case__ = len(__lowerCAmelCase ) // 2 if a_list[midpoint] == item: return True if item < a...
530
0
from __future__ import annotations from functools import lru_cache from math import ceil __UpperCamelCase : List[str] = 100 __UpperCamelCase : int = set(range(3, NUM_PRIMES, 2)) primes.add(2) __UpperCamelCase : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if...
248
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( _lowercase , _lowercase , _lowercase ): SCREAMING_SNAKE_CASE : List[Any] = OmegaConf.load(_lowercase ) SCREAMING_SNAKE_...
248
1
'''simple docstring''' from typing import Dict, Optional import numpy as np import datasets A_ = "\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classe...
123
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "bigcode/gpt_bigcode-santacoder": "https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json", } class ...
123
1
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.im...
27
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet imp...
587
0
from __future__ import annotations def _UpperCAmelCase (UpperCamelCase_ : str , UpperCamelCase_ : Dict = None , UpperCamelCase_ : str = None ): if start is None: _lowerCAmelCase : Dict = 0 if end is None: _lowerCAmelCase : Op...
703
def _UpperCAmelCase (UpperCamelCase_ : str ): '''simple docstring''' _lowerCAmelCase : List[str] = [int(UpperCamelCase_ ) for i in ip_va_address.split(""".""" ) if i.isdigit()] return len(UpperCamelCase_ ) == 4 and all(0 <= int(UpperCamelCase_ )...
196
0
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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 require...
33
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_verbos...
500
0
import inspect import unittest from transformers import BitConfig 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 import BackboneTesterMixin f...
139
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( BitC...
139
1
from __future__ import annotations class __lowerCamelCase : def __init__( self: Optional[int],A_: str,A_: str ): '''simple docstring''' __UpperCamelCase, __UpperCamelCase = text, pattern __UpperCamelCase, __Up...
1
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificat...
699
0
from collections.abc import Callable def _lowerCamelCase( lowerCAmelCase__ : Callable[[float], float] , lowerCAmelCase__ : float , lowerCAmelCase__ : float ): '''simple docstring''' SCREAMING_SNAKE_CASE_ : float = a SCREAMING_SNAKE_CA...
97
import math def _lowerCamelCase( lowerCAmelCase__ : float , lowerCAmelCase__ : float ): '''simple docstring''' return math.pow(lowerCAmelCase__ , 2 ) - a def _lowerCamelCase( lowerCAmelCase__ : float ): '''simple docstring'''...
97
1