code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf _lowerCAmelCase = logging...
37
import math def A ( _lowercase ): return math.sqrt(_lowercase ) * math.sqrt(_lowercase ) == num def A ( _lowercase ): SCREAMING_SNAKE_CASE : Dict = 0 SCREAMING_SNAKE_CASE : Tuple = n while left <= right: ...
182
0
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> List[str]: '''simple docstring''' if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(_lowercase , _lowercase ): raise TypeError("""Inp...
359
"""simple docstring""" import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators ...
313
0
'''simple docstring''' def __lowerCamelCase ( A__ = 10**9 ) -> int: """simple docstring""" UpperCamelCase = 1 UpperCamelCase = 2 UpperCamelCase = 0 UpperCamelCase = 0 UpperCamelCase = 0 while perimeter <= max_perimeter: ...
28
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : Tuple = {"configuration_ibert": ["IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "IBertConfig", "IBertOnnxConfig"]} try: if not is...
28
1
'''simple docstring''' import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_co...
350
'''simple docstring''' from __future__ import annotations def _snake_case ( A , A ) -> float: lowerCAmelCase__ = sorted(numsa + numsa ) lowerCAmelCase__ , lowerCAmelCase__ = divmod(len(A ) , 2 ) if mod == 1: ...
228
0
"""simple docstring""" def _snake_case ( lowercase__ , lowercase__ ): _lowerCamelCase : int = 0 _lowerCamelCase : List[str] = len(lowercase__ ) - 1 while left <= right: # avoid divided by 0 during interpolation if sor...
96
def UpperCAmelCase_ ( _A = 1_00_00_00 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = set(range(3 , _A , 2 ) ) primes.add(2 ) for p in range(3 , _A , 2 ): if p not in primes: continue primes.diff...
314
0
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available()...
287
'''simple docstring''' import random class __lowerCAmelCase : """simple docstring""" @staticmethod def snake_case__ ( lowerCAmelCase__ : str ) -> tuple[list[int], list[int]]: '''simple docstring''' _UpperCamelCase ...
287
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase = { '''configuration_bridgetower''': [ '''BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BridgeTowerConfig''', ...
87
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_numpy, s...
212
0
"""simple docstring""" from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def lowercase ( _snake_case : Optional[int] ) ->Any: """simple docstring""" return ConvertCommand( args.model_type , args...
359
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE : Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Optional[int] = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert...
24
0
'''simple docstring''' import heapq as hq import math from collections.abc import Iterator class __UpperCamelCase : def __init__( self, lowerCAmelCase ): """simple docstring""" lowerCamelCase_ =str(id_ ) lowerCamelCase_ ...
75
import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def UpperCAmelCase_( a__ ): """simple docstring""" if ( (cp >= 0x4_E00 and cp <= 0x9_FFF) or (cp >= 0x3_400 and cp <= 0x4_DBF) # or (cp >= 0x20_000 ...
313
0
'''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 from accelerate ...
199
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _snake_case = '▁' _snake_case = {'vocab_file': 'spiece.model'} _snake_...
199
1
"""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 AutoProcessor, BertTok...
17
def __A ( __lowerCamelCase ) -> int: a = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def __A ( __lowerCamelCase = 100 ) -> int: a = 1 a = 2 for i in range(2 , max_n + 1 ...
228
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig __snake_case = { '''google/tapas-base-finetuned-sqa''': ( '''https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json''' ), '''google/tapas-base-finetuned-wtq''': ( '''https://h...
153
"""simple docstring""" import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __snake_case = logging.get_logger(__name__) class __lowerCamelCase ( a__ ): '''simple docstring''' def __init__( self , *__UpperCAmelC...
153
1
from manim import * class A__ ( __SCREAMING_SNAKE_CASE): def UpperCamelCase__ ( self ): lowerCamelCase : Tuple = Rectangle(height=0.5 , width=0.5 ) lowerCamelCase : Union[str, Any] = Rectangle(height=0.46 , width=0.46 ).se...
287
def _a ( lowerCamelCase ): return " ".join( """""".join(word[::-1] ) if len(lowerCamelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wollef sroirraw"""))
287
1
"""simple docstring""" import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def _snake_case ( UpperCAmelCase_ : Optional[int] , UpperCAmelCase_ : List[Any] , UpperCAmelCase_ : Optional[Any] ): ...
370
"""simple docstring""" import argparse SCREAMING_SNAKE_CASE_ : Any = 'docs/source/_static/js/custom.js' def _snake_case ( UpperCAmelCase_ : List[Any] ): with open(UpperCAmelCase_ , encoding="""utf-8""" , newline="""\n""" ) as f: ...
69
0
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: __snake_case = None try: import msvcrt except ImportError: __snake_case = None try: import fcntl except ImportError: __snake_case = Non...
97
from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def lowerCamelCase__ ( ) -> Any: import os as original_os from os import path as original_path from os import rename as original_rename from os.path import dir...
24
0
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) __lowerCamelCase : Any = { "...
286
from datetime import datetime import matplotlib.pyplot as plt import torch def SCREAMING_SNAKE_CASE ( snake_case_ : int ): for param in module.parameters(): snake_case__ : Tuple = False def SCREAMING_SNAKE_CASE ( ): snake_case__ : Any = "...
286
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, ViltForMaskedLM, ViltFo...
199
# using dfs for finding eulerian path traversal def a_ ( SCREAMING_SNAKE_CASE__ : Any , SCREAMING_SNAKE_CASE__ : List[str] , SCREAMING_SNAKE_CASE__ : List[str] , SCREAMING_SNAKE_CASE__ : Optional[int]=None ): '''simple docstring''' _low...
199
1
'''simple docstring''' import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging lowerCamelCase__ = logging.get_logger(__name__) def __lowerCAmelCase (__lowerCAmelCase ): ...
360
'''simple docstring''' def __lowerCAmelCase (__lowerCAmelCase ): if number < 0: raise ValueError("number must not be negative" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
322
0
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def a__ ( ): """simple docstring""" print("Making key files..." ) make_key_files("rsa" , 1_024 ) p...
153
"""simple docstring""" def a__ ( _SCREAMING_SNAKE_CASE = 4_000_000 ): """simple docstring""" UpperCamelCase = [] UpperCamelCase , UpperCamelCase = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(_SCREAMING_SNAKE_CASE ) UpperCamelCase , Upper...
153
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase : List[str] ={ '''configuration_bloom''': ['''BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BloomConfig''', '''Bloom...
351
'''simple docstring''' from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_...
147
0
'''simple docstring''' from __future__ import annotations import math def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : int ) -> list[int]: if num <= 0: _a : List[Any] =F"{num}: Invalid input, please enter a positive integer." raise ...
276
"""simple docstring""" import sys from collections import defaultdict class UpperCamelCase : def __init__( self) -> Optional[int]: snake_case_ = [] def a_ ( self, lowerCAmelCase__) -> Any: return self.node_pos...
69
0
'''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 require_vision from ...
366
'''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, get_resize_output_image_size, normalize, rescale, resize, to_channel...
275
0
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger lowerCamelCase_ : Dict = get_logger(__name__) lowerCamelCase_ : List[str] = r'\n Args:\n ...
286
"""simple docstring""" import qiskit def UpperCAmelCase__ ( _UpperCAmelCase , _UpperCAmelCase ): """simple docstring""" A_ : Tuple = qiskit.Aer.get_backend('aer_simulator' ) A_ : str = qiskit.QuantumCircuit(4 , 2 ) # enc...
286
1
import os import zipfile import pytest from datasets.utils.extract import ( BzipaExtractor, Extractor, GzipExtractor, LzaExtractor, SevenZipExtractor, TarExtractor, XzExtractor, ZipExtractor, ZstdExtractor, ) from .utils import require_lza, require_pyazr, require_zstandard ...
118
import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers c...
118
1
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def SCREAMING_SNAKE_CASE_ ( __A : Union[s...
32
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class A_ ( snake_case__ ): ...
322
0
import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, ...
39
# 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 # # Unl...
39
1
"""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/ma...
64
import os # Precomputes a list of the 100 first triangular numbers a : Optional[Any] = [int(0.5 * n * (n + 1)) for n in range(1, 101)] def lowerCAmelCase_ (): """simple docstring""" UpperCAmelCase_: Any = os.path.dirname(os.path.real...
147
0
"""simple docstring""" import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": lowerCAmelCase__ = argparse.ArgumentParser( description=( '''Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for...
364
"""simple docstring""" from itertools import permutations def snake_case_ ( A_ : tuple ): '''simple docstring''' if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: ...
175
0
'''simple docstring''' from __future__ import annotations lowerCamelCase__ = tuple[int, int, int] lowerCamelCase__ = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase lowerCamelCase__ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # ----------------...
234
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class __lowercase (unittest.TestCase ): def UpperCamelCase__ ( self ) ->None: '''simple docstring''' __lowerCAmelCase : ...
275
0
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 import...
365
class _A : # Public class to implement a graph def __init__( self : List[Any] , _A : int , _A : int , _A : list[list[bool]] ) -> None: """simple docstring""" lowercase : Tuple = row...
116
0
def a__ ( __UpperCamelCase ): SCREAMING_SNAKE_CASE_ = len(__UpperCamelCase ) for i in range(1 , __UpperCamelCase ): SCREAMING_SNAKE_CASE_ = collection[i] SCREAMING_SNAKE_CASE_ = 0 SCREAMING_SNAKE_CASE_ = i - 1 ...
118
from functools import lru_cache @lru_cache def a__ ( __UpperCamelCase ): 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__": import doctest doctest.testmod()
118
1
from __future__ import annotations import math def __UpperCamelCase ( lowerCAmelCase__ : list , lowerCAmelCase__ : list ): if len(lowerCAmelCase__ ) != 2 or len(a[0] ) != 2 or len(lowerCAmelCase__ ) != 2 or len(b[0] ) != 2: raise Exception('''Matrices are not 2x2''' ...
90
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
90
1
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler,...
39
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_backbon...
39
1
'''simple docstring''' import math class _lowercase : def lowerCamelCase_ ( self: Dict , UpperCamelCase__: list[list[float]] , UpperCamelCase__: list[int] ): lowerCamelCase__ : int = 0.0 ...
129
'''simple docstring''' from torch import nn def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> Dict: if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": ...
129
1
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor lowerCAmelCase__ :Optional[int] = logging.get_logger(__name__) class __a ( snake_case_ ): def __init__( self , *_SCREAMING_SNAKE_CASE , **_SCREAMING_SNAKE_CASE )...
329
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def __lowercase ( ): UpperCamelCase_ : Optional[Any] = HfArgumentParser(lowerCamelCase ) UpperCamelCase_ : Tuple = parser.parse_args_into_dataclasses()[0] UpperCamelCase_ : ...
175
0
import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def lowerCamelCase_ ( _a : Dict , _a : Optional[int] , _a : List[Any]=1024 , _a : int=1024 , _a : Dict...
355
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { '''shi-labs/dinat-mini-in1k-224''': '''http...
59
0
import baseaa def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : List[Any] ) -> bytes: return baseaa.baaencode(string.encode('utf-8' ) ) def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : Optional[int] ) -> str: return baseaa.baadeco...
325
from __future__ import annotations from math import ceil, floor, sqrt def __UpperCamelCase ( _lowerCAmelCase = 200_0000 ) -> int: """simple docstring""" A : list[int] = [0] A : int for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): ...
116
0
"""simple docstring""" import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassific...
155
"""simple docstring""" from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class _UpperCAmelCase ( lowerCAmelCase__): def __init__( self : ...
155
1
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...
90
from ..utils import DummyObject, requires_backends class __lowerCAmelCase ( metaclass=__magic_name__ ): """simple docstring""" snake_case_ = ['''onnx'''] def __init__( self , *lowerCamelCase__ , **lowerCamelCase__ ) ...
90
1
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowerCamelCase__ ( UpperCamelCase__ : Optional[int] , UpperCamelCase__ : List[Any]=False ) -> Tuple: '''simple docstring''' _snake_c...
295
from cva import destroyAllWindows, imread, imshow, waitKey def lowerCamelCase__ ( UpperCamelCase__ : Dict ) -> Optional[Any]: '''simple docstring''' _snake_case , _snake_case = img.shape[0], img.shape[1] # converting each pixel's colo...
295
1
from collections import deque class lowerCamelCase__ : '''simple docstring''' def __init__(self ,__lowerCamelCase ,__lowerCamelCase ,__lowerCamelCase ) -> None: """simple docstring""" lowerCAmelCase__ : Union[str, Any] = process_name # proces...
129
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class lowerCamelCase__ ( lowerCamelCase__): '''simple docstring'''...
129
1
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won...
57
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def __SCREAMING_SNAKE_CASE ( lowercase__ , lowercase__=False ): """simple docstring""" A = OmegaConf.load(lowercase__ ) if...
57
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_a...
92
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCAmelCase ( A_ ): ...
59
0
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import H...
344
import functools def A ( __UpperCAmelCase , __UpperCAmelCase ) -> int: '''simple docstring''' UpperCAmelCase_ = len(__UpperCAmelCase ) UpperCAmelCase_ = len(__UpperCAmelCase ) @functools.cache def min_distance(_...
344
1
"""simple docstring""" import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, ...
155
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig a = logging.get_logger(__name__) a = { 'Intel/dpt-large': 'https://huggingface.co/Intel/dpt-large/resolve/main/config.json...
155
1
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( __A ) -> list: return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(__A ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("doctest").testmod()
351
'''simple docstring''' from ...processing_utils import ProcessorMixin class __UpperCAmelCase ( _lowerCamelCase ): __lowercase = """SpeechT5FeatureExtractor""" __lowercase = """SpeechT5Tokenizer""" def __init__( self , lowerCAmelCase_ , lowerCAmelC...
160
0
from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder lowerCAmelCase = datasets.utils.logging.get_logger(__name__) class A ( folder_based_builder.FolderBasedBuilderConfig ): UpperCamelCase_ ...
295
from __future__ import annotations def _lowerCamelCase( lowercase__ , lowercase__ ) -> Any: '''simple docstring''' if len(lowercase__ ) <= 1 or n <= 1: return insert_next(lowercase__ , n - 1 ) rec_insertion_sort(lowercase__ , n - 1 ) def _lowerCamelCase( lo...
295
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { '''facebook/s2t-small-librispeech-asr''': ( '''https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json''' ), #...
350
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A = { '''configuration_instructblip''': [ '''INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InstructBlipConfig'...
188
0
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_util...
57
"""simple docstring""" A : int = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingf...
57
1
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def lowerCAmelCase( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ )-> Union[str, Any]: """simple docstring""" U...
369
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_availab...
60
0
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalyt...
344
'''simple docstring''' def UpperCAmelCase ( a_ , a_ ) -> Optional[int]: """simple docstring""" print("""\nThe shortest path matrix using Floyd Warshall algorithm\n""" ) for i in range(a_ ): for j in range(a_ ): if dis...
344
1
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case_ : Union[str, Any] = logging.get_logg...
371
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) snake_case_ : List[Any] = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiT...
7
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import tor...
225
"""simple docstring""" from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_tor...
160
0
class _lowerCamelCase: # Public class to implement a graph def __init__( self, lowerCamelCase, lowerCamelCase, lowerCamelCase) -> None: """simple docstring""" _lowercase : Any = row _lowercase : str = col _lowercase : ...
84
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _lowerCamelCase( _a ): lowercase_ : ...
84
1
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor a : int = logging.getLogger(__name__) a : List[Any] = ...
147
import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline 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_GUI...
188
0
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { 'microsoft/unispeech-large-1500h-cv': ( 'https://huggingface.co/micr...
356
"""simple docstring""" # Copyright 2022 The HuggingFace Team and The OpenBMB 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.a...
181
0
import unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, p...
308
"""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, AutoModelForMultipleChoice...
60
0
from __future__ import annotations def __a ( lowerCAmelCase_ : int ,lowerCAmelCase_ : int ) -> list[list[int]]: '''simple docstring''' UpperCAmelCase_= [] create_all_state(1 ,lowerCAmelCase_ ,lowerCAmelCase_ ,[] ,lowerCAmelCase_...
362
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __A = { '''configuration_clip''': [ '''CLIP_PRETRAINED_CO...
277
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/licenses/LICENSE-2.0 ...
66
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json", } class A ( _UpperCAmelCase ): ...
7
0
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pi...
351
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def lowerCamelCase_ ( _a ): """simple docstring""" def wrapper(*_a , **_a ): lowerCAmelCase__ : ...
211
0
"""simple docstring""" from typing import List from .keymap import KEYMAP, get_character def _snake_case ( lowercase__ : str ) -> Optional[Any]: '''simple docstring''' def decorator(lowercase__ : Any ): lowerCAmelCase_ :Optional[Any] ...
84
"""simple docstring""" from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function __UpperCAmelCase = 1.054571817e-34 # unit of ℏ : J * s __UpperCAmelCase = 3e8 # unit of c : m * s^-1 ...
84
1
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _snake_case : Any = [ # tf -> hf ('/', '.'), ('layer_', 'layers.'), ('kernel', 'weight'), ('b...
207
class _UpperCAmelCase : """simple docstring""" def __init__( self : Union[str, Any] , lowerCAmelCase_ : List[str] , lowerCAmelCase_ : int , lowerCAmelCase_ : Dict ) -> List[str]: __lowerCAmelCase = name __lowerCAmelCase = value ...
207
1
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu lowerCAmelCase__ = get_tests_dir(...
68
'''simple docstring''' 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 UpperCamelCase__ = logging.get_logger(__name__) ...
181
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch...
370
import qiskit def lowerCAmelCase_ ( __UpperCAmelCase: int , __UpperCAmelCase: int ) -> qiskit.result.counts.Counts: UpperCamelCase__ : Optional[Any] = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on ...
247
0
import datasets UpperCAmelCase__ = "\\n@InProceedings{conneau2018xnli,\n author = \"Conneau, Alexis\n and Rinott, Ruty\n and Lample, Guillaume\n and Williams, Adina\n and Bowman, Samuel R.\n and Schwenk, Holger\n ...
339
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo a_ :Any = "\\n@misc{wu2016googles,\n title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author={Yonghui Wu and Mi...
277
0
def lowerCAmelCase_ ( __a , __a ) -> Union[str, Any]: """simple docstring""" lowerCamelCase__: List[Any] =[0 for i in range(r + 1 )] # nc0 = 1 lowerCamelCase__: List[str] =1 for i in range(1 , n + 1 ): # to compute current row from previous ...
273
from __future__ import annotations from typing import Any class _SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__(self : Tuple , UpperCAmelCase_ : int , UpperCAmelCase_ : int , UpperCAmelCase_ : float = 0) ->None: '''simple docstr...
273
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = { "configuration_lxmert": ["LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Lxmert...
211
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging ...
211
1
'''simple docstring''' import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import s...
355
'''simple docstring''' import requests from bsa import BeautifulSoup def a_ ( lowerCamelCase : str = "AAPL" ): lowerCAmelCase = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' lowerCAmelCase = BeautifulSoup(requests.get(lowerCamelCase ...
55
0
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, require_...
207
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 DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging ...
207
1
'''simple docstring''' from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDim...
4
'''simple docstring''' import heapq def snake_case__ ( lowerCamelCase__ : dict ) -> set[int]: A_ : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be fi...
4
1
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging _snake_case = logging.get_logger(__name__) def A ( _lowerCamelCase=None , _lowerCamelCase=None ): '''simple docstrin...
36
"""simple docstring""" import os import numpy import onnx def _SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> Dict: A__ = a.name A__ = b.name A__ = "" A__ = "" A__ = a == b A__ = name_a A__ = name_b re...
247
0
from typing import Any class lowercase : def __init__( self , snake_case ): snake_case_ = data snake_case_ = None def __repr__( self ): return F'''Node({self.data})''' class lowercase : def __init__( self...
200
def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ = 1 snake_case_ = 2 while i * i <= n: snake_case_ = 0 while n % i == 0: n //= i multip...
200
1
def __SCREAMING_SNAKE_CASE ( UpperCamelCase__ ) -> list: '''simple docstring''' if len(UpperCamelCase__ ) < 2: return collection def circle_sort_util(UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> bool: UpperCAmelCase = False if low ==...
273
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSpec from ...tokeniz...
273
1
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils import Fr...
361
from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...test_p...
63
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { """google/mobilenet_v1_1...
177
'''simple docstring''' a_ : Any = """0.21.0""" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_load...
55
0
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class a__ ( UpperCamelCase__ ): a : Optional[int] = (UnCLIPScheduler,) def lowerCAmelCase_ ( self , **A ) -> str: '''simple docstring''' ...
354
# Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar lowercase__ : str = TypeVar("T") class a__ ( Generic[T] ): def __init__( self ...
180
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimensi...
4
'''simple docstring''' from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer __snake_case =logging...
4
1
"""simple docstring""" import pprint import requests SCREAMING_SNAKE_CASE : Optional[Any] = '''https://zenquotes.io/api''' def __UpperCAmelCase ( ) -> list: """simple docstring""" return requests.get(API_ENDPOINT_URL + """/today""" ).json() def __Up...
317
"""simple docstring""" def __UpperCAmelCase ( snake_case_ : int = 1000000 ) -> int: """simple docstring""" _lowerCAmelCase = limit + 1 _lowerCAmelCase = [0] * limit for first_term in range(1 , snake_case_ ): for n in range(sn...
317
1
'''simple docstring''' import math def snake_case_ ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" return math.sqrt(SCREAMING_SNAKE_CASE__ ) * math.sqrt(SCREAMING_SNAKE_CASE__ ) == num def snake_case_ ( SCREAMING_SNAKE_CASE__ ): """simple ...
200
'''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_ : Tuple...
200
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_nump...
353
'''simple docstring''' import warnings 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.utils import co...
135
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 tokenizers...
227
'''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
0
'''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 ...
322
'''simple docstring''' import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version lowerCamelCase__ = version.parse(importlib_metadata.version('nltk')) if NLTK_VERSION >= version.Version('3.6.4'): from nltk ...
322
1
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black __SCREAMING_SNAKE_CASE :Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) impor...
22
import torch from torch import nn class a ( nn.Module ): """simple docstring""" def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=1 , lowerCAmelCase_=False ) -> Any: ...
180
0
"""simple docstring""" def lowerCAmelCase_( lowercase_ : int ) -> int: if not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ): raise TypeError('''only integers accepted as input''' ) else: _lowerCamelCase = str(abs(UpperCAmelCase__ ...
371
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __SCREAMING_SNAKE_CASE : List[str] = { '''configuration_vision_encoder_decoder''': ['''Vis...
73
0
import pprint import requests a__ = """https://zenquotes.io/api""" def lowercase ( ) -> list: return requests.get(API_ENDPOINT_URL + """/today""" ).json() def lowercase ( ) -> list: return requests.get(API_ENDPOINT_URL + """/random""" ).json() ...
317
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor a__ = logging.get_logger(__name__) class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' def __init__( self : List[Any] , ...
317
1
"""simple docstring""" 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 ...
234
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperC...
234
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, re...
111
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { '''camembert-base''': '''https://huggingface.co/camembert-...
135
0
import operator as op A : int = 'scaler.pt' A : List[str] = 'pytorch_model' A : List[str] = 'random_states' A : List[str] = 'optimizer' A : Dict = 'scheduler' A : Optional[Any] = 'pytorch_model.bin' A ...
33
import os import numpy import onnx def __lowerCAmelCase ( a__ , a__ ) -> List[str]: __a = a.name __a = b.name __a = '''''' __a = '''''' __a = a == b __a = name_a __a =...
33
1
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 from accelerate import Acce...
322
from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_xpu, r...
322
1
'''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_lxmert': ['LXMERT_PRETRAINED_CONFIG_ARCHIVE_M...
364
'''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 transformers.utils im...
236
0
from typing import Any class _SCREAMING_SNAKE_CASE : def __init__( self , lowercase ) -> Optional[Any]: lowerCamelCase_ = data lowerCamelCase_ = None class _SCREAMING_SNAKE_CASE : def __init__( self ) -> List[Any]: lowerCamelCas...
19
from math import isclose, sqrt def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ) -> tuple[float, float, float]: __lowerCamelCase : Tuple = point_y / 4 / point_x __lowerCamelCase : Tuple = 2 * normal_gradient / (1...
73
0
"""simple docstring""" import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_...
1
"""simple docstring""" import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class _SCREAMING_SNAKE_CASE : def __init__( self , __A ) -> Union[...
1
1
'''simple docstring''' from __future__ import annotations def __lowerCAmelCase (__lowerCAmelCase , __lowerCAmelCase ): if len(__lowerCAmelCase ) == 0: return False _UpperCAmelCase : List[str] = len(__lowerCAmelCase ) // 2 if a_l...
234
'''simple docstring''' import math def __lowerCAmelCase (__lowerCAmelCase ): return math.sqrt(__lowerCAmelCase ) * math.sqrt(__lowerCAmelCase ) == num def __lowerCAmelCase (__lowerCAmelCase ): _UpperCAmelCase : int = ...
234
1
def lowerCamelCase__ ( a__ : str , a__ : str ) -> int: if len(a__ ) != len(a__ ): raise ValueError("""String lengths must match!""" ) UpperCamelCase_ = 0 for chara, chara in zip(a__ , a__ ): if c...
261
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { '''kakaobrain/align-base''': '''https://huggingface.co/kakaobrain/align-ba...
261
1
"""simple docstring""" import pytest import datasets # Import fixture modules as plugins __A : Dict = ['''tests.fixtures.files''', '''tests.fixtures.hub''', '''tests.fixtures.fsspec'''] def lowercase ( __snake_case : List[Any] , __snake_case : Dic...
33
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Dict = logging.get_logger(__name__) __A : Union[str, Any] = { '''facebook/vit-mae-base''': '''https://huggingface.co/facebook/vit-mae-base/resolve/ma...
33
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch ...
66
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 Upper...
66
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase : Any = { "configuration_x_clip": [ "XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "XCLIPConfig", "XCLIPTextConfig", ...
2
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accel...
236
0
def lowerCAmelCase__ ( _a : int , _a : int , _a : list[list[int]] ): def update_area_of_max_square(_a : int , _a : int ) -> int: # BASE CASE if row >= rows or col >= cols: return 0 snake_case_ : str = update_...
354
import copy 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 from ..auto import CONFIG_MAPPING lowercase : List[Any] = logging.ge...
36
0
'''simple docstring''' import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_com...
1
'''simple docstring''' import os from math import logaa def lowerCAmelCase_ ( snake_case_ : str = "base_exp.txt" ) -> int: '''simple docstring''' UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 for i, line in enumerate(open(os.path.join(os.path...
1
1
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("dataset_size" , [None, 4_0_0 * 2**2_0, 6_0_0 * 2**2_0] ) @pytest.mark.parametrize("input_in_memory_max_size" , ["default", 0, 1_0_0 * 2**2_0, 9_0_0 * 2**2_0] ) def ...
366
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch...
124
0