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
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bir...
12
from __future__ import annotations def lowerCamelCase__ ( A__ : list[int | float] , A__ : int , A__ : int ): '''simple docstring''' if len(A__ ) == 0: raise ValueError("""find_max() arg is an empty sequence""" ) if (...
12
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_available(): raise Optional...
297
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class __lowerCamel...
297
1
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 a =get_logger(__name__) a =r""" Args: input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`): Indices of in...
73
'''simple docstring''' import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class UpperCAmelCase_ ( unittest.TestCase ): def __Upp...
4
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_num...
370
"""simple docstring""" 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, rand...
320
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { "edbeeching/decision-transformer-gym-hopper-medium": ( "https://huggingface.co/edbeeching/decision-transf...
97
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _lowerCAmelCase : List[str] = logging.get_logger(__na...
218
0
from math import log from scipy.constants import Boltzmann, physical_constants _lowerCamelCase : int = 3_0_0 # TEMPERATURE (unit = K) def _a ( SCREAMING_SNAKE_CASE__ : float , SCREAMING_SNAKE_CASE__ : float , SCREAMING_SNAKE_CASE__ : float , ) -> ...
359
import requests from bsa import BeautifulSoup def _a ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : dict ) -> str: '''simple docstring''' SCREAMING_SNAKE_CASE__ : Any = BeautifulSoup(requests.get(SCREAMING_SNAK...
191
0
'''simple docstring''' UpperCamelCase__ = [ '''Audio''', '''Array2D''', '''Array3D''', '''Array4D''', '''Array5D''', '''ClassLabel''', '''Features''', '''Sequence''', '''Value''', '''Image''', '''Translation''', '''TranslationVariableLangua...
181
'''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 UpperCamelCase__ = logging.get_logger(__name__) def a__ ( lowerCAmelCase__ ) ...
181
1
"""simple docstring""" import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_token...
358
"""simple docstring""" def UpperCAmelCase ( a_ ): '''simple docstring''' lowerCamelCase : List[Any] = 1 for i in range(1, num + 1 ): fact *= i return fact def UpperCAmelCase ( a_ ): '''simple docstring''' lowerCamelCa...
205
0
def UpperCAmelCase ( lowercase , lowercase ): """simple docstring""" return number | (1 << position) def UpperCAmelCase ( lowercase , lowercase ): """simple docstring""" return number & ~(1 << position) def UpperCAmelC...
210
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : str = logging.get_logger(__name__) __a : Optional[int] = { """google/vivit-b-16x2-kinetics400""": ( """https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json""" ), ...
210
1
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCamelCase_ ( )-> tuple[list[int], int]: _snake_case : int = [randint(-10_00 , 10_00 ) for i in range(10 )] _snake_case : Uni...
370
def lowerCamelCase_ ( lowerCAmelCase: int , lowerCAmelCase: int )-> int: while a != 0: _snake_case , _snake_case : Optional[Any] = b % a, a return b def lowerCamelCase_ ( lowerCAmelCase: int , lowerCAmelCase: int )-> i...
260
0
'''simple docstring''' import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_...
349
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 _A = logging.get_logger(__name__) _A = '''▁''' _A = {'''vocab_file''': ''...
122
0
"""simple docstring""" import argparse import os import subprocess from packaging.version import Version, parse from accelerate.commands.config.config_args import default_config_file, load_config_from_file a : Tuple = '''Run commands across TPU VMs for initial setup befo...
350
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : int ) ->bool: '''simple docstring''' return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
79
0
"""simple docstring""" from math import pi def UpperCAmelCase__ (snake_case__ : int , snake_case__ : int ): """simple docstring""" return 2 * pi * radius * (angle / 3_60) if __name__ == "__main__": print(arc_length(90, 10))
64
'''simple docstring''' import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data...
297
0
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 lowerCamelCase_ ( _UpperCamelCase ) -> Tuple: ...
279
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( ...
279
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : int =logging.get_logger(__name__) _UpperCAmelCase : List[Any] ={ """BridgeTower/bridgetower-base""": """https://huggingface.co/BridgeTower/bridgetower-...
262
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 TokenizerTesterMi...
262
1
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .datac...
146
from functools import lru_cache def UpperCamelCase ( __magic_name__ : int ) -> set: """simple docstring""" lowercase__ = 2 lowercase__ = set() while i * i <= n: if n % i: i += 1 else: n //= i factors....
146
1
'''simple docstring''' def _lowerCamelCase ( lowercase : float , lowercase : int ) -> float: if digit_amount > 0: return round(number - int(lowercase ) , lowercase ) return number - int(lowercase ) if __name__ == "__main__": ...
63
'''simple docstring''' from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils ...
276
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, get_resize_output_image_size, normalize, rescale, resize, to_channe...
106
'''simple docstring''' import os import unittest from transformers import MobileBertTokenizer, MobileBertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transf...
106
1
"""simple docstring""" import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging _a = '\\n\n' _a = '\nPerplexity (PPL) is one of the most common metrics for evaluating...
17
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class __lowerCAmelCase ( lowerCamelCase__ ): # to overwrite at feature extractactor specifi...
82
0
"""simple docstring""" from ....utils import logging lowerCAmelCase_ = logging.get_logger(__name__) class __A ( _UpperCAmelCase ): '''simple docstring''' def __init__( self : Tuple ,_snake_case : List[Any] ,_sn...
352
"""simple docstring""" import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @...
302
0
"""simple docstring""" def a_ ( _lowerCAmelCase : int ): '''simple docstring''' lowercase__ : list[list[int]] = [[0 for _ in range(_lowerCAmelCase )] for _ in range(m + 1 )] for i in range(m + 1 ): lowercase__ : List[Any] = 1 ...
77
"""simple docstring""" from __future__ import annotations import math from collections.abc import Callable def a_ ( _lowerCAmelCase : Callable[[int | float], int | float] , _lowerCAmelCase : int | float , _lowerCAmelCase : int | float , _lowerCAmelCase : int = 100 , ): ''...
77
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = { 'configuration_pix2struct': [ 'PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Pix2StructConfig', ...
370
'''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 a_ = get_logger(__name__) a_ = R'\n Args:\n input_ids (`jnp.ndarray` of shape `(batch_size, s...
222
0
'''simple docstring''' import os def A__ ( UpperCAmelCase_ = "matrix.txt" ): with open(os.path.join(os.path.dirname(UpperCAmelCase_ ) , UpperCAmelCase_ ) ) as in_file: _UpperCamelCase : str = in_file.read() _UpperCamelCase : List[str] ...
83
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py __A : str = 'src/transformers' # This is to make sure the transformers...
154
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, ...
33
import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import version from .. import __versi...
33
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A__ : str = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ...
185
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) def ...
225
0
import math from numpy import inf from scipy.integrate import quad def A__ ( lowerCamelCase ) -> float: if num <= 0: raise ValueError("""math domain error""" ) return quad(SCREAMING_SNAKE_CASE_ , 0 , SCREAMING_SNAKE_CASE_ , args=(SCREAMING_S...
366
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mvp import MvpTokenizer lowerCamelCa...
223
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....
100
"""simple docstring""" from __future__ import annotations from fractions import Fraction def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def _lowerCAmelCase ( UpperC...
100
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class lowerCAmelC...
149
"""simple docstring""" import os def lowerCAmelCase__ ( _UpperCamelCase : str = "matrix.txt" ) -> int: """simple docstring""" with open(os.path.join(os.path.dirname(_UpperCamelCase ) , _UpperCamelCase ) ) as in_file: snake_ca...
149
1
"""simple docstring""" import math import sys def a__ ( SCREAMING_SNAKE_CASE : int ): '''simple docstring''' if number != int(SCREAMING_SNAKE_CASE ): raise ValueError("the value of input must be a natural number" ) if number < 0: raise ValueError("the value of i...
108
"""simple docstring""" import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, prec...
108
1
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def __lowercase ( _SCREAMING_SNAKE_CASE ) -> Union[str, Any]: '''simple docstring''' SCREAMING_SNAKE_CASE = FileLock(str(tmpdir / """foo.lock""" ...
193
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_ge...
193
1
def snake_case ( snake_case__ :List[Any]) -> bool: return sum(i for i in range(1 , number // 2 + 1) if number % i == 0) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') _SCREAMING_SNAKE_CASE = int(input(...
180
'''simple docstring''' import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager im...
80
0
'''simple docstring''' import argparse from collections import defaultdict def UpperCAmelCase ( a_ , a_ , a_ , a_ , a_ ) -> Dict: """simple docstring""" A_ : Optional[Any] = F"{file}_{class_name}_{test_...
350
'''simple docstring''' def UpperCAmelCase ( a_ , a_ ) -> int: """simple docstring""" A_ : int = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): A_ : Tuple = n - k # Calculate...
164
0
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 : Optional[int] = lo...
124
"""simple docstring""" import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy...
77
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, ...
256
from math import factorial def UpperCAmelCase ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ): if successes > trials: raise ValueError("successes must be lower or equal to trials" ) if trials < 0 or successes < 0: raise ValueError("the function is...
256
1
import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenization_transfo_xl import CORPUS_...
169
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer lowerCamelCase__ : Union[str, Any] = logging.get_logger(__na...
225
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
118
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Dict =logging.get_logger(__name__) lowerCAmelCase__ : Optional[int] ={ '''asapp/sew-tiny-100k''': '''https://huggingface.co/asapp/sew-tiny-100k/resolve/m...
118
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer lowercase : List[str] = logging.get_logger(__name__) lowe...
20
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowercase ( __snake_case : str , __snake_case : str , __snake_case : Optional[str] = None ): if version.par...
33
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logg...
370
from __future__ import annotations from collections import deque class _SCREAMING_SNAKE_CASE : def __init__( self : Optional[Any] , __lowerCamelCase : list[str] ): UpperCamelCase :list[dict] = [] self.adlist.append( {"""value""": """""", """next_states""": [], ...
62
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers @require_torch cla...
281
import argparse import collections import json import os import re import string import sys import numpy as np snake_case : Dict = re.compile(R"\b(a|an|the)\b", re.UNICODE) snake_case : Optional[int] = None def lowerCAmelCase_ ( ) -> Union[str, Any]: '''simp...
281
1
'''simple docstring''' from manim import * class __lowerCAmelCase ( __magic_name__ ): """simple docstring""" def snake_case__ ( self : Dict ) -> Tuple: '''simple docstring''' _UpperCamelCase = Rectangle(height=0.5...
287
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def snake_case__ ( self : Tuple ) -> int: '''simple d...
287
1
def _lowerCamelCase( lowercase__ ) -> int: '''simple docstring''' if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): __lowercase= F'Input value of [number={number}] must be an integer' raise TypeError(_UpperCAmelCase ) if number < 1: __lowercase= F'Input value of [num...
295
from __future__ import annotations from collections.abc import Callable UpperCAmelCase__ = list[list[float | int]] def A ( _UpperCAmelCase : Matrix , _UpperCAmelCase : Matrix ) -> Matrix: '''simple docstring''' _UpperCAmelCase = len(_UpperCAme...
339
0
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo UpperCAmelCase_ = """\ @misc{wu2016googles, title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation}, author={Yonghui W...
295
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGeneration as Pr...
295
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) A__ : str = {'''configuration_deit''': ['''DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DeiTConfig''', '''DeiTOnnxConfig''...
103
from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from ....file_utils import Pa...
300
0
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def UpperCamelCase ( _A : Optional[int] )-> List[Any]: """simple docstring""" A__ = FileLock(str(tmpdir / "foo.lock" ) ) A__ = FileLock(str(...
198
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils import loggin...
198
1
'''simple docstring''' from queue import PriorityQueue from typing import Any import numpy as np def a__ ( a__ , a__ , a__ , a__ , a__ , a__ , a__ , a__ , a__ , ): """simple docstring""" for nxt, d in graph[v]...
267
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 _lowercase ( A__ ): '''simple docstring''' def __init__( ...
9
0
def A ( _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : Any = len(_lowerCamelCase ) _lowerCAmelCase : Optional[Any] = [] for i in range(len(_lowerCamelCase ) - pat_len + 1 ): _l...
300
import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor _snake_case = logging.get_logger(__name__) class UpperCAmelCase_ ( a): def __init__( self, *__a, **__a): '''simple docstring''' warnings....
300
1
from random import shuffle import tensorflow as tf from numpy import array def UpperCAmelCase_( a__ , a__ ): """simple docstring""" SCREAMING_SNAKE_CASE : List[Any] = int(a__ ) assert noofclusters < len(a__ ) # Find out the dimensionality...
313
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
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __SCREAMING_SNAKE_CASE ={ "configuration_conditional_detr": [ "CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP", "Conditio...
321
"""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/licenses/LICENSE-2.0 # ...
321
1
import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available snake_case__ : str = logging.getL...
117
import argparse import copy def _a ( lowerCamelCase: List[Any] ) -> List[str]: '''simple docstring''' __A = {} with open(lowerCamelCase ) as f: for line in f: if line.split()[0] not in dict_of_neig...
117
1
'''simple docstring''' from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a__ : Optional[Any] = logging.get_logger(__name__) a__ : List[str] = { 'nielsr/can...
359
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json ...
243
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import Auto...
349
'''simple docstring''' def _lowercase ( __A ,__A ): '''simple docstring''' __UpperCamelCase = len(__A ) __UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by no...
349
1
"""simple docstring""" import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": UpperCAmelCase =argparse.ArgumentParser() parser.add_argument("--dump_path", de...
77
"""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 UpperCAmelCase =logging.get_logger(__name__) UpperCAmelCase ...
77
1
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attention_paths, renew_...
122
_A = { '''meter''': '''m''', '''kilometer''': '''km''', '''megametre''': '''Mm''', '''gigametre''': '''Gm''', '''terametre''': '''Tm''', '''petametre''': '''Pm''', '''exametre''': '''Em''', '''zettametre''': '''Zm''', '''yottametre''': '''Ym''', } # Exponent of the factor(m...
122
1
"""simple docstring""" from collections import defaultdict def a__ ( __lowercase ) -> int: _A = 1 _A = True for v in tree[start]: if v not in visited: ret += dfs(lowerCamelCase_ ) if ret % 2 == 0: cuts.appe...
368
"""simple docstring""" from collections import namedtuple import requests from lxml import html # type: ignore a_ = namedtuple("covid_data", "cases deaths recovered") def a__ ( __lowercase = "https://www.worldometers.info/coronavirus/" ) -> covid_data: _...
163
0
"""simple docstring""" import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = {'''vocab_file''': '''vocab.json'''} lowerCamelCase_ = ...
268
"""simple docstring""" def snake_case ( A__ ,A__ ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) UpperCAmelCase_ : Dict = (boundary[1] - boundary[0]) / steps UpperCAmelCase_ : Optional[int] = boundary[0] UpperCAmelCase_ : s...
268
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : str = logging.get_logger(__name__) A_ : List[str] = { 'naver-clova-ix/donut-base': 'https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json', # See all Donut models at https://huggingfa...
141
import unittest from transformers import AutoTokenizer, FalconConfig, 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 Model...
141
1
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModel...
149
"""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: Tuple = logging.get_logger(__name__) _Upper...
255
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE : List[str] = { """configuration_x_clip""": [ """XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XCLIPConfig""", ...
352
"""simple docstring""" def lowerCAmelCase_( lowercase_ : List[str] ) -> Optional[Any]: _lowerCamelCase = len(lowercase_ ) while cur > 1: # Find the maximum number in arr _lowerCamelCase = arr.index(max(arr[0:cur] ) ) # Reve...
73
0
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class UpperCamelCase_ : lowercase = 42 lowercase = 42 class UpperCamelCase_ : def __init__( self , A ...
265
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_...
265
1
import argparse import os import re _UpperCAmelCase = """src/diffusers""" # Pattern that looks at the indentation in a line. _UpperCAmelCase = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. _UpperCAmelCase = re.compile(r"""^\s*\"([^\"]+)\":"...
367
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() ...
192
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class snake_case__ (_UpperCamelCase ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Union[str, Any] = ["""image_processor""", """tokenizer"""] ...
107
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase: str = logging.get_logger(__name__) _lowercase: List[str] = { "microsoft/trocr-base-handwritten": ( "https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json" ), ...
227
0
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration lowercase_ = HfArgumentParser(InitializationArguments) lowercase_ = parser.parse_args() # Load codeparrot tokenizer trained for Python code tok...
20
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ComputeEnvironment, ...
20
1
"""simple docstring""" import os def __UpperCAmelCase ( ) -> int: with open(os.path.dirname(__lowerCamelCase ) + '''/grid.txt''' ) as f: lowercase__ : Optional[int] = [] # noqa: E741 for _ in range(20 ): l.append([int(__lowerCamelCase ...
16
"""simple docstring""" def __UpperCAmelCase ( __lowerCamelCase , __lowerCamelCase ) -> List[Any]: print('''\nThe shortest path matrix using Floyd Warshall algorithm\n''' ) for i in range(__lowerCamelCase ): for j in range(__lowerCamelCase ): if d...
16
1
"""simple docstring""" import gc import unittest from transformers import CTRLConfig, 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...
309
"""simple docstring""" import re def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : str ): if len(re.findall('[ATCG]' , _UpperCAmelCase ) ) != len(_UpperCAmelCase ): raise ValueError('Invalid Strand' ) return dna.translate(dna.maketrans('ATCG' , 'TAGC' ) ) if __name__ == "__main_...
309
1
'''simple docstring''' UpperCAmelCase_ : dict[str, float] = { "joule": 1.0, "kilojoule": 1000, "megajoule": 100_0000, "gigajoule": 10_0000_0000, "wattsecond": 1.0, "watthour": 3600, "kilowatthour": 360_0000, "newtonmeter": 1.0, "calorie_nutr": 4186.8, "kilocalor...
200
'''simple docstring''' import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available fro...
200
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ = ...
246
'''simple docstring''' from __future__ import annotations def lowercase__( __UpperCamelCase: list[int] ,__UpperCamelCase: int ,__UpperCamelCase: int ,__UpperCamelCase: int ): """simple docstring""" if (direction == 1 and array[indexa] > a...
246
1
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 fro...
6
"""simple docstring""" import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class __A (unittest.TestCase): '''simple docstring''' def ...
347
0
import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import classes from unilm.wavlm.WavLM i...
185
from __future__ import annotations from PIL import Image # Define glider example lowerCAmelCase__ :str = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0...
185
1
'''simple docstring''' from __future__ import annotations import pandas as pd def a_ ( lowerCamelCase : List[str] , lowerCamelCase : Optional[int] , lowerCamelCase : Optional[int] ): lowerCAmelCase = [0] * no_of_processes lowerCAmelCase = [0] * no_of_...
4
def lowerCamelCase__ ( ): '''simple docstring''' snake_case_ = [] snake_case_ = 1 while len(_A ) < 1E6: constant.append(str(_A ) ) i += 1 snake_case_ = "".join(_A ) return ( int(constant[0] ...
187
0
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class _snake_case ( _snak...
281
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...ut...
281
1
'''simple docstring''' import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP _lowercase : Optional[int] ...
93
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase : List[str] = logging.get_logger(__name__) UpperCAmelCase : Union[str, Any] = { "EleutherAI/gpt-neox-20b": "https://huggingface.co/EleutherAI/gpt-neox-20b...
136
0
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, Vilt...
369
def lowerCAmelCase_ ( _snake_case : int ) -> bool: '''simple docstring''' if not isinstance(_snake_case , _snake_case ): __magic_name__ : Union[str, Any] = F'''Input value of [number={number}] must be an integer''' raise TypeError(_snake_case ) ...
41
0
import numpy as np from transformers import Pipeline def __A ( __lowerCAmelCase )-> Any: """simple docstring""" _UpperCAmelCase = np.max(SCREAMING_SNAKE_CASE__ , axis=-1 , keepdims=SCREAMING_SNAKE_CASE__ ) _UpperCAmelCase = np.exp...
39
'''simple docstring''' import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration snake_case_ : Union[str, Any] = 50_00_00 snake_case_ ,snake_case_ : Optional[int] = os.path.split(__file__) snake_case_ : O...
125
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { 'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json', } class low...
363
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_tor...
29
0
from math import ceil def A__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__) -> List[str]: __snake_case: Optional[int] = list(range(0 , SCREAMING_SNAKE_CASE__)) __snake_case: Union[str, Any] = [item for sublist in list(device_map.values()) f...
111
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 __UpperCAmelCase : Any = "src/diffusers" # Matches is_xxx_available() __UpperCAmelCase : List[str] ...
111
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : str = {'configuration_focalnet': ['FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FocalNetConfig']} try: if not is_torch_available...
368
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer a : Optional[Any] = logging.get_logger(__na...
82
0
'''simple docstring''' from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
258
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configura...
258
1
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
368
"""simple docstring""" from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if ...
53
0
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=UpperCAmelCase__ ) class a ( UpperCAmelCase__ ): """simple docstri...
335
"""simple docstring""" import torch from diffusers import DiffusionPipeline class _UpperCAmelCase ( UpperCAmelCase__ ): '''simple docstring''' def __init__( self , snake_case_ , snake_case_ ): """simple docstring""" super().__init__() se...
286
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_se...
365
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer lowerCamelCase = logging.get_logger(__name__) lowerCamelCase ...
211
0
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vision_availabl...
43
def lowerCAmelCase__( lowercase : int = 100_0000 ) -> int: __snake_case : List[Any] = limit + 1 __snake_case : List[str] = [0] * limit for first_term in range(1 , lowercase ): for n in range(lowercase , lowercase , lowercase ): __sn...
326
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 : List[Any] = { ...
99
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import ...
99
1
from ...processing_utils import ProcessorMixin class A ( lowercase_ ): """simple docstring""" lowerCamelCase = 'SpeechT5FeatureExtractor' lowerCamelCase = 'SpeechT5Tokenizer' def __init__( self : List[Any],lowercase_ : ...
7
'''simple docstring''' __snake_case : Tuple = '\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' __snake_case : List[str] = [{'type': 'code', 'content'...
134
0
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() __lowerCAmelCase : List[str] =logging.get_logger(__name__) def UpperCamelCase ( _lo...
123
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase : Any ={ "configuration_swinv2": ["SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Swinv2Config"], } try: if not is_torch_available(): ...
123
1
from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class __a ( _UpperCAmelCase ): def __lt__( self , _SCREAMING_SNAKE_CASE ) -> Dict: """simple docstring""" return ...
329
def _lowercase ( ) -> Optional[int]: '''simple docstring''' SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ = 1 while len(UpperCamelCase_ ) < 1e6: constant.append(str(UpperCamelCase_ ) ) i += 1 SCREAMING_SNAKE_CASE__ ...
176
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor a = logging.get_logger(__name__) class lowercase_ ( __lowerCAmelCase ): '''simple docstring''' def __init__( self : Tuple , *_Upper...
271
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _snake_case ( _snake_case : Dict ) -> Any: '''simple docstring''' if ( (cp >= 0X4e00 and cp <= 0X9fff) o...
271
1
"""simple docstring""" from __future__ import annotations def lowercase ( _snake_case : int | str ) ->bool: """simple docstring""" __snake_case : List[str] = str(_snake_case ) return n == n[::-1] def lowercase ( _snake_case : in...
102
"""simple docstring""" from __future__ import annotations def lowercase ( _snake_case : int | str ) ->bool: """simple docstring""" __snake_case : List[str] = str(_snake_case ) return n == n[::-1] def lowercase ( _snake_case : in...
102
1
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def snake_case_ ( lowerCAmelCase_ : List[str] ): __lowercase : Dict = FileLock(str(tmpdir / """foo.lock""" ) ) __lowercase : Dict = FileLock(str(tmpdir / "...
306
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_co...
306
1
'''simple docstring''' from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def snake_case_ ( _lowerCAmelCase : Optional[Any] , _lowerCAmelCase : Union[str, Any] ...
23
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) def __lowercase ( _SCREAMING_SNAKE_CASE=None , ...
296
0
import math def lowerCamelCase__ ( a ) -> list[int]: _A: Dict = [] _A: int = 2 _A: Any = int(math.sqrt(a ) ) # Size of every segment _A: int = [True] * (end + 1) _A: Any = [] while start <= end: if temp[start] is True: ...
355
from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class UpperCAmelCase ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' def __lt__( self : Dict , lowerCAmelCase_ :...
301
0
import numpy class A_ : def __init__( self : Any , UpperCAmelCase : numpy.ndarray , UpperCAmelCase : numpy.ndarray ) -> str: __lowerCAmelCase: Tuple = input_array # Random initial weights are assigned where first argument is the ...
322
'''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...
41
0
'''simple docstring''' import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def lowerCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ ): ...
311
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class A ( __snake_cas...
311
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase : int = { '''configuration_bert''':...
280
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...uti...
280
1
"""simple docstring""" import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home lowerCAmelCase__ = HUGGINGFACE_HUB_CACHE lowerCAmelCase__ = '''config.json''' lowerCAmelCase__ = '''diffusion_pytorch_model.bin''' lowerCAmelCase__ = ...
133
"""simple docstring""" import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: ...
133
1
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 SCREAMING_SNAKE_CASE_:List[Any] = """▁""" SCREAMING_SNAKE_CASE_:int = {"""vo...
116
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from ...
116
1
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, smar...
330
import re def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> str: """simple docstring""" if len(re.findall('''[ATCG]''', snake_case_ ) ) != len(snake_case_ ): raise ValueError('''Invalid Strand''' ) return dna.translate(dna.maketrans('''AT...
330
1
"""simple docstring""" import requests from bsa import BeautifulSoup def _A ( lowercase = "AAPL" ): """simple docstring""" a =f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' a =BeautifulSoup(requests.get(lowercase ).text , '''htm...
81
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _a ( __a ): __a : int = ["""image_processor""", """tokenizer"""] __a : Union[str, Any] = """ChineseCLIPImage...
34
0
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class lowerCamelCase_ : '''simple docstring''' a__ : List[str] a__ ...
105
from __future__ import annotations def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , ): '''simple docstring''' if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('''You cannot supply more or less than 2 valu...
105
1
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase = 0 ) -> list: '''simple docstring''' lowerCAmelCase : int = length or len(_UpperCAmelCase ) lowerCAmelCase : Optional[int] = False for i in range(length - 1 ): if list_data[i] > list_...
138
from datetime import datetime as dt import os from github import Github __A : Dict = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''feature request''', '''new model''', '''wip''', ] def SCREAMING_SNAKE_CASE__ ( ) -> int...
138
1
"""simple docstring""" import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_t...
317
"""simple docstring""" from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def __UpperCAmelCase ( snake_case_ : Union[str, Any] ) -> Dict: """simple docstring""" return getitem, k def __UpperCAm...
317
1