code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
from math import log from scipy.constants import Boltzmann, physical_constants lowerCAmelCase : List[Any] = 3_00 # TEMPERATURE (unit = K) def A_ ( a , a , a , ): """simple docstring""" if donor_conc <= 0: raise ValueError('Donor co...
253
"""simple docstring""" from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration lowerCamelCase_ : Any = HfArgumentParser(InitializationArguments) lowerCamelCase_ : Union[str, Any] ...
286
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json", "microsoft/markuplm-large": "https:...
43
'''simple docstring''' import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PA...
43
1
"""simple docstring""" from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, b...
74
"""simple docstring""" import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() _lowercase = logging.get_logger(__name_...
74
1
'''simple docstring''' from scipy.stats import pearsonr import datasets a : List[Any] = '\nPearson correlation coefficient and p-value for testing non-correlation.\nThe Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value...
350
'''simple docstring''' import pytest import datasets # Import fixture modules as plugins a : int = ['tests.fixtures.files', 'tests.fixtures.hub', 'tests.fixtures.fsspec'] def __magic_name__ ( __UpperCAmelCase, __UpperCAmelCase ) -> Tuple: '''simple docstring''' for it...
72
0
'''simple docstring''' 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 (...
162
'''simple docstring''' import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def _lowerCamelCase ( lowercase : Union[str, Any] , lowercase : int , lowerc...
63
0
from functools import lru_cache @lru_cache def UpperCamelCase__( UpperCamelCase__ : int )->int: if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": ...
39
from __future__ import annotations import time import numpy as np a__: Optional[Any] = [8, 5, 9, 7] a__: Dict = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] a__: List[Any] = [ [3, 2, 1, 4], [0, 2, 5, 2], ...
39
1
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 __lowerCAmelCase : Union[str, Any] =logging.get_logger(__name__) __lowerCAmelCase : List[str] ...
9
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _lowercase ( A__ , unittest.TestCase ): '''simple docstring''' SCREAMING_...
9
1
'''simple docstring''' import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils imp...
249
'''simple docstring''' import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def __lowerCamelCase ( A__ , A__ , A__ ) -> Optional[int]: """simple docstring""" UpperCam...
249
1
'''simple docstring''' import random class snake_case__ : @staticmethod def A ( _A : str ) -> tuple[list[int], list[int]]: UpperCAmelCase_ : Dict = [ord(_A ) for i in text] UpperCAmelCase_ : List[str] = [] UpperCAmelCase_ : ...
304
'''simple docstring''' import functools def __UpperCAmelCase ( A : str , A : str ) -> int: UpperCAmelCase_ : Optional[Any] = len(A ) UpperCAmelCase_ : List[str] = len(A ) @functools.cache def min_distance(A : int , A : ...
304
1
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SegformerConfig, SegformerForImageClassification, SegformerForSe...
362
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def __snake_case ( SCREAMING_SNAKE_CASE__ : Tuple , SCREAMING_SNAKE_CASE__ : List[str]=7 ) -> Tuple: '''simple do...
202
0
import unittest from transformers import BertGenerationConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMi...
303
def a__ ( snake_case = 1_000_000 ): """simple docstring""" __SCREAMING_SNAKE_CASE : Union[str, Any] = 1 __SCREAMING_SNAKE_CASE : Optional[Any] = 1 __SCREAMING_SNAKE_CASE : Optional[int] = {1: 1} for inputa in range(2 , snake_case ): __SCREAMING_SNAKE...
303
1
"""simple docstring""" import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING ...
362
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, Im...
150
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : int = logging.get_logger(__name__) ...
33
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import Back...
11
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : List[str] = { """configuration_megatron_bert""": ["""MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MegatronBertConfig"""], } try: if not is_torch_av...
200
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...
200
1
from __future__ import annotations import time lowercase : Optional[int] = list[tuple[int, int]] lowercase : List[Any] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], ...
20
"""simple docstring""" def __lowerCAmelCase ( lowercase : List[str] , lowercase : Union[str, Any] , lowercase : List[str] , lowercase : Tuple , lowercase : List[Any] , lowercase : int ) -> List[Any]: """simple docstring""" ...
203
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_...
177
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase = { 'configuration_roberta': ['ROBERTA_PRETRAINED_CON...
177
1
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class __snake_case ( lowerCamelCase__ ): def __init__( self ,...
348
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp ...
245
0
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( Cente...
369
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.util...
129
0
import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig _a = logging.get_logger(__name__) class __lowerCamelCase : """simple docstring"""...
39
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 __lowerCamelCase ( snake_case__): ...
39
1
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @dataclass class ...
355
import requests from bsa import BeautifulSoup def lowerCAmelCase__ ( a__ = "https://www.worldometers.info/coronavirus" ) ->dict: '''simple docstring''' _UpperCamelCase = BeautifulSoup(requests.get(a__ ).text , "html.parser" ) _UpperCamelCase = soup.findAll(...
63
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a_ = { 'configuration_blip': [ 'BLIP_PRETRAINED_CONFIG_ARCHIVE_...
249
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main...
249
1
import argparse import struct import unittest class _UpperCamelCase : '''simple docstring''' def __init__( self : Any , snake_case_ : Union[str, Any] ): UpperCamelCase_: Tuple = data # Initialize hash values UpperCamelCase_: str = [ 0X6a09...
357
import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image from ...image_utils...
223
0
'''simple docstring''' from __future__ import annotations from statistics import mean def UpperCAmelCase_ ( __lowercase : list[int] , __lowercase : list[int] , __lowercase : int ) -> list[int]: '''simple docstring''' _UpperCA...
22
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from tran...
202
0
"""simple docstring""" from __future__ import annotations import numpy as np def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' return np.maximum(0 , lowerCAmelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
248
"""simple docstring""" def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(lowerCAmelCase ) ) if txt[a].isalpha() ] if __name__ == "__main__": _...
248
1
from typing import Any class __lowerCAmelCase : def __init__( self : List[Any] , snake_case__ : Any ): """simple docstring""" _UpperCAmelCase = data _UpperCAmelCase = None class __lowerCAmelCas...
133
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def __SCREAMING_SNAKE_CASE ( snake_case_ , snake_case_ , snake_case_ , snake_case_=1024 ): '''simple docstring''' _UpperCAmelCase , _UpperCAmelCase ...
133
1
'''simple docstring''' from __future__ import annotations from typing import Any def __lowerCAmelCase ( UpperCamelCase__ ) -> None: create_state_space_tree(UpperCamelCase__ , [] , 0 ) def __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamel...
369
'''simple docstring''' 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 __UpperCAmelCase =logging.get_logger(__name__) __UpperCAmelCase ="▁" __Upp...
237
0
import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class A ( UpperCamelCase_ ): def __init__( self : List[Any] , lowercase_ : str , lowercase_ : str=No...
199
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class A ( nn.Module ): UpperCamelCase__ : int UpperCamelCase__ : int UpperCamelCase__ : fl...
199
1
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class a (_lowerCAmelCase ): ...
356
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSchedul...
134
0
import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __lowerCAmelCase : Optional[Any] = g...
156
"""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 @re...
171
0
import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin __...
273
def lowerCAmelCase_ ( __a , __a ) -> Tuple: """simple docstring""" assert x is not None assert y is not None lowerCamelCase__: Any =len(__a ) lowerCamelCase__: int =len(__a ) # declaring the array for storing the dp values lowerCamelCase__: L...
273
1
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __SCREAMING_SNAKE_CASE (unittest.TestCase ): """simple docstring""" def UpperCamelCase__ ( self : str ): _a = [ "...
63
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase_ : List[str] = { 'microsoft/trocr-base-handwritten': ( 'https://huggingface.co/m...
63
1
from random import randint from tempfile import TemporaryFile import numpy as np def __lowerCamelCase ( lowerCamelCase__ : List[Any] , lowerCamelCase__ : List[str] , lowerCamelCase__ : str ): '''simple docstring''' lowerCamelCase = 0...
66
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __lowercase ( pl.LightningModule ): """simple docstring""" def __init__( self , A ) -> Any: ...
66
1
'''simple docstring''' from string import ascii_uppercase __A : Tuple = {str(ord(c) - 55): c for c in ascii_uppercase} def UpperCamelCase_ ( A__ : int , A__ : int ): '''simple docstring''' if isinstance(A__ ...
120
'''simple docstring''' 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 cookiecu...
120
1
"""simple docstring""" def __UpperCamelCase (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> float: if mass < 0: raise ValueError('The mass of a body cannot be negative' ) return 0.5 * mass * abs(snake_case__ ) * abs(snake_case__ ) if __name__ == "__main...
365
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class SCREAMING_SNAKE_CASE (UpperCAmelCase ): def __init__( self : List[str] , a : Call...
269
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging A_ :str = logging.get_logger(__name__) A_ :Tuple = { '''microsoft/git-base''': '''https://huggingface.co/microsoft/git-base/r...
71
def SCREAMING_SNAKE_CASE__ ( __a , __a ): 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...
327
0
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATU...
319
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer else: snake_case ...
319
1
'''simple docstring''' import doctest from collections import deque import numpy as np class lowercase : """simple docstring""" def __init__( self ): '''simple docstring''' UpperCamelCase__ :int = [2, 1, 2, -1] UpperCamelCase__ :Tuple = [1, 2, 3, 4] ...
97
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def a ( __a ) -> int: '''simple docstring''' for param in module.parameters(): UpperCamelCase__ :Dict = False def a ( ) -> Union[str, Any]: ...
97
1
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_DOCSTRING, BertEmbedd...
358
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging UpperCAmelCase__ = logging.get...
26
0
import numpy as np from transformers import Pipeline def __lowerCamelCase ( snake_case__ ) -> Union[str, Any]: """simple docstring""" _SCREAMING_SNAKE_CASE = np.max(snake_case__ ,axis=-1 ,keepdims=snake_case__ ) _SCREAM...
306
def __lowerCamelCase ( snake_case__ ) -> list: """simple docstring""" def merge(snake_case__ ,snake_case__ ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[...
306
1
import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO, ) UpperCAmelCase_ = ...
366
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient UpperCAmelCase_ = WebClient(token=os.environ['CI_SLACK_BOT_TOKEN']) def lowerCAmelCase_ ( ...
247
0
import warnings from ..trainer import Trainer from ..utils import logging __lowerCamelCase : List[Any] = logging.get_logger(__name__) class __snake_case ( lowerCamelCase_ ): def __init__( self : Tuple , _lowercase : Optional[int]=None , *...
219
def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : int , __UpperCamelCase : int ) -> str: """simple docstring""" if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) SCREAMING_SNAKE_CASE__ = str(bin...
219
1
def lowerCAmelCase_ ( _lowercase : str , _lowercase : int) -> list: """simple docstring""" a__ : Optional[Any] = word.split() def justify(_lowercase : list , _lowercase : int , _low...
266
import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet import VOCAB_F...
266
1
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class SCREAMING_SNAKE_CASE__ ( lowerCamelCase_ ): __SC...
193
'''simple docstring''' from __future__ import annotations from collections import Counter from random import random class lowerCAmelCase__ : def __init__( self ): """simple docstring""" lowercase_ : int = ...
93
0
import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device lowercase__ : List[Any] = False class a__ ( unittest.TestCase ): pass @slow...
364
import math import sys def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> int: if number != int(__UpperCamelCase): raise ValueError("the value of input must be a natural number") if number < 0: raise ValueError("the value of input must not be a negative number") ...
180
0
'''simple docstring''' from __future__ import annotations def __snake_case ( UpperCAmelCase_ : int ): lowerCamelCase_ = 2 lowerCamelCase_ = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(UpperCAmelCase_ ) if n > 1: fac...
55
'''simple docstring''' from __future__ import annotations def __snake_case ( UpperCAmelCase_ : int ): lowerCamelCase_ = 2 lowerCamelCase_ = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(UpperCAmelCase_ ) if n > 1: fac...
55
1
from __future__ import annotations _snake_case = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _snake_case = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def A ( _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : Union[str, Any...
300
_snake_case = 8.3144598 def A ( _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' if temperature < 0: raise Exception("Temperature cannot be less than 0 K" ) if molar_mass <= 0: raise Exception("Molar mass cannot be less than ...
300
1
"""simple docstring""" def _A (__a ) -> list: """simple docstring""" if len(__a ) < 2: return collection def circle_sort_util(__a , __a , __a ) -> bool: SCREAMING_SNAKE_CASE_ : Tuple = False if low == hig...
91
"""simple docstring""" import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot f...
269
0
'''simple docstring''' def SCREAMING_SNAKE_CASE__( _UpperCamelCase : str , _UpperCamelCase : list[str] ) -> str: '''simple docstring''' UpperCamelCase__ = "" for word_or_phrase in separated: if not isinstance(_UpperCamelCase , ...
31
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowercase: int = logging.get_logger(__name__) __lo...
31
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = {} class lowercase_ ( lowercase ): '''simple docstring''' __snake_case = ...
0
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def a_ ( _lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase ,_...
208
0
import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast _snake_case : Tuple = datasets.utils.logging.get_logger(__name__) @dataclass class a (datasets.BuilderCon...
134
from __future__ import annotations from functools import lru_cache from math import ceil _snake_case : Tuple = 100 _snake_case : int = set(range(3, NUM_PRIMES, 2)) primes.add(2) _snake_case : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: cont...
134
1
"""simple docstring""" # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is tr...
96
def lowerCAmelCase_ ( snake_case_,snake_case_ ): while b: _A , _A : List[str] = b, a % b return a def lowerCAmelCase_ ( snake_case_,snake_case_ ): return a if b == 0 else euclidean_gcd_recursive(snake_case_,a % b ) def ...
26
0
import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transpose, ) if is_flax_availa...
360
import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def A_ ( A__ , A__ , A__ ) -> Any: # Construct model if gpta_config_file == "":...
225
0
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/li...
321
'''simple docstring''' import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem SCREAMING_SNAKE_CASE__ = importlib.util.find_spec('s3fs') is not None ...
321
1
from __future__ import annotations import bisect def _snake_case( SCREAMING_SNAKE_CASE__ : list[int] , SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int = 0 , SCREAMING_SNAKE_CASE__ : int = -1 ) -> int: '''simp...
369
import numpy as np from transformers import Pipeline def _snake_case( SCREAMING_SNAKE_CASE__ : int ) -> int: '''simple docstring''' A__ = np.max(SCREAMING_SNAKE_CASE__ , axis=-1 , keepdims=SCREAMING_SNAKE_CASE__ ) A__...
282
0
"""simple docstring""" from __future__ import annotations from typing import Any def _SCREAMING_SNAKE_CASE ( _lowercase : list ) ->int: '''simple docstring''' if not postfix_notation: return 0 a : List[str] = {"+", "-", ...
105
"""simple docstring""" import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transforme...
136
0
from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastapi.routing import...
371
"""simple docstring""" from argparse import ArgumentParser from .env import EnvironmentCommand def _SCREAMING_SNAKE_CASE ( ) -> List[Any]: A__ = ArgumentParser("Diffusers CLI tool" , usage="diffusers-cli <command> [<args>]" ) A__ = parser.add_subparsers(help="diff...
230
0
"""simple docstring""" def _snake_case ( lowercase__ : str ) -> str: '''simple docstring''' if not all(char in """01""" for char in bin_string ): raise ValueError("""Non-binary value was passed to the function""" ) if not bin_string: raise Valu...
84
"""simple docstring""" from PIL import Image def _snake_case ( lowercase__ : Image , lowercase__ : float ) -> Image: '''simple docstring''' def brightness(lowercase__ : int ) -> float: return 1_2_8 + level + (c - 1_2_8) if n...
84
1
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_...
300
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def A ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : Dict = ("dense.weight", "...
300
1
import datasets from .evaluate import evaluate _snake_case = "\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={arXiv preprint arXiv:2103.06268},\n ye...
36
# 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 ...
342
0
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 = logging.get_logger(__...
358
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=__magic_name__ ) class __lowerCAmelCase ( __magic_name__ ): """simple docstring""" ...
348
0
'''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 .formatting import TensorForma...
31
'''simple docstring''' import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transform...
31
1
from __future__ import annotations def A__ ( __lowerCamelCase ): SCREAMING_SNAKE_CASE_ = len(__lowerCamelCase ) # We need to create solution object to save path. SCREAMING_SNAKE_CASE_ = [[0 for _ in range(__lowerCamelCase )] for _ in range(__lowerCamelCase )] SCREAMING_SNAKE_...
351
__UpperCAmelCase = "\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" __UpperCAmelCase = [{"type": "code", "content": INSTALL_CONTENT}] __UpperCAmelCase = { ...
257
0
'''simple docstring''' a : int = 8.3_144_598 def __magic_name__ ( __UpperCAmelCase, __UpperCAmelCase ) -> float: '''simple docstring''' if temperature < 0: raise Exception('''Temperature cannot be less than 0 K''' ) if molar_mass <= 0: raise Excep...
56
import random def A ( a_ ,a_ ,a_ = False ) -> dict: __UpperCamelCase : dict ={i: [] for i in range(a_ )} # if probability is greater or equal than 1, then generate a complete graph if probability >= 1: ...
71
0
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __A = logging.get_logger(__name__) __A = {'''vocab_file''': '''sentencepiece.model''...
369
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { '''google/efficie...
64
0
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 ModelTesterMixin, ids_tensor, ...
295
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : Optional[int] = logging.get_logger(__name__) _snake_case : Optional[int] = { 'google/vivit-b-16x2-kinetics400': ( 'https://huggingface.co/google/vi...
292
0
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transf...
358
'''simple docstring''' import numpy as np from transformers import Pipeline def _lowerCAmelCase ( lowercase ) -> List[str]: __lowerCAmelCase = np.max(lowercase , axis=-1 , keepdims=lowercase ) __lowerCAmelCase = np.exp(outputs - maxes ) ...
46
0
"""simple docstring""" from __future__ import annotations def lowercase__ ( _UpperCAmelCase = 4 ) -> list[list[int]]: '''simple docstring''' lowercase : Optional[Any] = abs(_UpperCAmelCase ) or 4 return [[1 + x + y * row_size for x in ra...
255
"""simple docstring""" 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 ( AutoencoderKL, DDIMInverseScheduler, DDIMSchedule...
255
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 transform...
76
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
76
1
import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def UpperCamelCase ( snake_case__ : ndarray ) -> float: return np.dot(snake_case__ , snake_case__ ) class lowerCAmelCase_ : def __init__( self, *, SC...
119
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def UpperCamelCase ( snake_case__ : str ) -> Optional[int]: monkeypatch.setattr('datasets.utils.deprecation_utils._emitted_deprecation_warnings' , set() ) @pytest.fixture def UpperCamelCase ...
119
1
'''simple docstring''' from timeit import timeit A__ : Union[str, Any] = { """MALAYALAM""": True, """String""": False, """rotor""": True, """level""": True, """A""": True, """BB""": True, """ABC""": False, """amanaplanacanalpanama""": True, # "a man a plan a canal pa...
365
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers...
0
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a : int = { 'configuration_maskformer': ['MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MaskFormerConfig'], '...
105
"""simple docstring""" 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 ...
167
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=__lowercase ) class lowerCAmelCase__ ( __lowercase ): # `task` is not a ClassVar since we want it to be part of the `...
339
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils import ...
339
1
"""simple docstring""" import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def _snake_case ( lowercase__ , lowercase__ ...
96
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from...
348
0
from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...t...
231
from __future__ import annotations from typing import Any def SCREAMING_SNAKE_CASE ( lowercase_ ) -> None: """simple docstring""" create_state_space_tree(lowercase_ , [] , 0 ) def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ...
231
1
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=a__ ) class _snake_case ( a__ ): # `task` is not a ClassVar since we want it to be part of...
135
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common...
135
1
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 __lowerCamelCase ( lowerCamelCase__=None , lowerCamelCase__=None ): ...
364
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def __lowerCamelCase ( lowerCamelCase__ ): """simple docstring""" lowercase__ : Optional[Any] = ...
121
0
import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ : List[Any] = logging.get_logger(__name__) UpperCAmelCase_ : Any = {'''vocab_file''': '''vocab.json'''} UpperCAmelCase_ : ...
38
"""simple docstring""" from math import factorial A_ = {str(d): factorial(d) for d in range(10)} def UpperCAmelCase__ (snake_case__ : int ): """simple docstring""" return sum(DIGIT_FACTORIAL[d] for d in str(snake_case__ ) ) def UpperCAmelCas...
64
0
"""simple docstring""" import argparse 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_dummies.py _lowercase : List[Any] = 'src/diffusers' # Matches is_xxx_available() _lowercase : ...
86
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :float , snake_case_ :float , snake_case_ :float ): if days_between_payments <= 0: raise ValueError('''days_between_payments must be > 0''' ) if daily_interest_rate < 0: raise Va...
86
1
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer if TYPE_CHECKING...
103
'''simple docstring''' from numpy import exp, pi, sqrt def snake_case_ ( lowerCAmelCase_ , lowerCAmelCase_ = 0.0 , lowerCAmelCase_ = 1.0 )-> int: '''simple docstring''' return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if _...
215
0
"""simple docstring""" from collections.abc import Sequence def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ = None ) -> Tuple: if nums is None or not nums: raise ValueError('Input sequence should not be empty' ) lowerCAmelCase__ : Optional[Any] = nums[0] ...
360
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> str: return "".join([hex(SCREAMING_SNAKE_CASE_ )[2:].zfill(2 ).upper() for byte in list(SCREAMING_SNAKE_CASE_ )] ) def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> bytes: # Check data validity, following RFC3...
307
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'microsoft/git-base': 'https://huggingface.co/microsoft/git-base/resolve/main/config.json', } class _UpperCamelCase (...
76
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'sayakpaul/vit-msn-base': 'https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json', # See all ViT MSN models at https://huggingface.co/models?filter=vit_msn ...
76
1
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 : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : ...
84
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) SCREAMING_SNAKE_CASE : str = logging.getLogger() def ...
84
1
"""simple docstring""" def _snake_case ( _snake_case : str , _snake_case : bool = False ): if not isinstance(_snake_case , _snake_case ): lowerCAmelCase : Optional[Any] = f'''Expected string as input, found {type(_snake_case )}''' raise Value...
60
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils im...
0
0
"""simple docstring""" import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def __UpperCAmelCase ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase...
365
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
302
0
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: lowerCAmelCase_ : Dict = None try: import msvcrt except ImportError: lowerCAmelCase_ : Union[str, Any] = None try: import fcntl ex...
63
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCAmelCase_ : Dict = logging.get_logger(__name__) lowerCAmelCase_ : Optional[int] = { 'ut/deta': 'https://huggingfa...
63
1
"""simple docstring""" import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transform...
359
"""simple docstring""" import numpy as np def a__ ( __SCREAMING_SNAKE_CASE ) -> np.array: return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
108
0
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def A_ ( ) -> List[Any]: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with pytest.rais...
52
'''simple docstring''' def _lowerCamelCase ( lowercase : int ) -> bool: _a = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
63
0
import torch from diffusers import DiffusionPipeline class _lowerCamelCase ( _SCREAMING_SNAKE_CASE ): """simple docstring""" def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE )->Tuple: '''simple docstring''' super().__init__()...
371
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 checked before tokenizers Upper...
65
0
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, rand...
305
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 A ( tf.keras.layers.Layer ): '''simple docstring''' ...
305
1
'''simple docstring''' import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoi...
92
'''simple docstring''' def UpperCamelCase_( snake_case : int , snake_case : int ): '''simple docstring''' while b: snake_case_ , snake_case_ = b, a % b return a def UpperCamelCase_( snake_case : int ,...
92
1
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) ->...
177
"""simple docstring""" from __future__ import annotations from math import pi, sqrt def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> tuple: if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: raise Value...
177
1
from math import log from scipy.constants import Boltzmann, physical_constants A_ :Optional[Any] = 300 # TEMPERATURE (unit = K) def A ( a_ ,a_ ,a_ ,) -> float: if donor_conc <= 0: raise ValueError('Donor concentration ...
365
from math import pow, sqrt def A ( *a_ ) -> bool: __UpperCamelCase : Union[str, Any] =len(a_ ) > 0 and all(value > 0.0 for value in values ) return result def A ( a_ ,a_ ) -> float | ValueError: return ( ...
245
0
"""simple docstring""" def a_ ( _lowerCAmelCase : str , _lowerCAmelCase : str ): '''simple docstring''' lowercase__ : List[str] = len(_lowerCAmelCase ) + 1 lowercase__ : Any = len(_lowerCAmelCase ) + 1 # dp is a 2d matrix where dp[i]...
77
from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) __UpperCamelCase : int = 299792458 # Symbols __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase : Optional[int] = symbols...
307
0
def UpperCamelCase (lowercase_: bytes ) -> str: return "".join([hex(lowercase_ )[2:].zfill(2 ).upper() for byte in list(lowercase_ )] ) def UpperCamelCase (lowercase_: str ) -> bytes: # Check data validity, following RFC3548 # https://www.ietf.org/rfc/rfc3548.txt if (len(lowercase_ ...
141
from typing import Any def UpperCamelCase (lowercase_: list ) -> list[Any]: if not input_list: return [] A__ : Any = [input_list.count(lowercase_ ) for value in input_list] A__ : List[Any] = max(lowercase_ ) # Gets the maximum count in the input list. # G...
141
1
'''simple docstring''' from __future__ import annotations class __a : def __init__( self : Any , __magic_name__ : int = 0 ) -> Tuple: """simple docstring""" UpperCAmelCase_ : List[Any] = key def ...
125
'''simple docstring''' import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class __a : def __init__( self : Union[str, Any] , __magic_name__ : Dict=2 , __magic_name__ : Di...
125
1
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 _lowerCAmelCase : Dict = logging.g...
358
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def __snake_case ( ) -> tuple[list[int], int]: A_ : Dict = [randint(-1000 , 1000 ) for i in range(10 )] A_ : List[str] = randint(-5000 ,...
70
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, ...
58
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_dimen...
308
0
import re def __lowercase ( __lowerCAmelCase : str ): a__ = re.compile(R'^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$' ) if match := re.search(__lowerCAmelCase , __lowerCAmelCase ): return match.string == phone return False if __na...
363
from math import ceil, sqrt def __lowercase ( __lowerCAmelCase : int = 1_0_0_0_0_0_0 ): a__ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a__ = max(ceil(sqrt(outer_width**2 ...
109
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { """uclanlp/visualbert-vqa""": """https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json""", """uclanlp/visualbert-vqa-pr...
259
import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def _A ( SCREAMING_SNAK...
259
1
import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> ...
285
import math from datetime import datetime, timedelta def _snake_case( SCREAMING_SNAKE_CASE__ ) -> datetime: lowercase : Any = year % 19 lowercase : Optional[int] = year % 4 lowercase : Any = year % 7 lowercase ...
285
1