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 inspect import unittest class __lowerCAmelCase ( unittest.TestCase ): def lowerCamelCase__ ( self :Tuple ): '''simple docstring''' try: import diffusers # noqa: F401 except ImportError: as...
228
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_...
228
1
from __future__ import annotations from math import pow, sqrt def lowerCAmelCase_ ( _snake_case : float , _snake_case : float , _snake_case : float ) -> dict[str, float]: '''simple docstring''' if (resistance, reactance, impedance).c...
356
import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf_weights_in_mobilenet_va, ) ...
41
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """weiweishi/roc-bert-base-zh""": """https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json""", } class a_ ...
58
'''simple docstring''' import os lowerCAmelCase__ = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def _A ( A__ ): """simple docstring""" __lowercase = 0 __lowercase = 0 while index < len(A__ ) - 1: __...
104
0
"""simple docstring""" from __future__ import annotations from fractions import Fraction def SCREAMING_SNAKE_CASE_ ( snake_case : int , snake_case : int )-> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) ...
80
"""simple docstring""" import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor A_ : Union[str, Any] =logging.get_logger(__name__) class __a ( lowerCAmelCase__ ): def __init__( self , *a__ , **a__ ): ...
80
1
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record UpperCAmelCase_ : int = '''\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems}, author={Wa...
38
def lowerCAmelCase_ ( __UpperCAmelCase: float , __UpperCAmelCase: int ) -> float: if digit_amount > 0: return round(number - int(__UpperCAmelCase ) , __UpperCAmelCase ) return number - int(__UpperCAmelCase ) if __name__ == "__main__": print...
201
0
import unittest from transformers import BertGenerationTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin a__ : List[Any] = '''▁'...
352
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_available f...
19
0
from statistics import mean, stdev def lowercase ( SCREAMING_SNAKE_CASE__ : list , SCREAMING_SNAKE_CASE__ : int = 3 ) -> list: _snake_case : Any = min(SCREAMING_SNAKE_CASE__ ) _snake_case : List[Any] = max(SCREAMING_SNAKE_CASE__ ) # normalize data...
317
import torch from torch import nn class snake_case ( nn.Module ): '''simple docstring''' def __init__( self : int , lowerCAmelCase : Tuple , lowerCAmelCase : int , lowerCAmelCase : Any , lowerCAmelCase : T...
317
1
'''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 def a__ ( a__ ...
331
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase : List[Any] = logging.get_logger(__name__) # TODO: upload to AWS UpperCAmelCase : Optional[int] = { 'yjernite/retribert-base-uncased': ( 'https...
331
1
'''simple docstring''' import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('ignore', category=UserWarning, module='torch.optim.lr_scheduler') class lowerCAmelCase_ : '''simple docstring''' def __init__( self : Any , _UpperCAmelCase ...
346
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, ...
164
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __snake_case = {"""configuration_xlnet""": ["""XLNET_PRET...
112
"""simple docstring""" from __future__ import annotations import numpy as np def __lowerCAmelCase ( lowercase : list[float] ) -> Any: """simple docstring""" return np.maximum(0 , lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5])...
112
1
"""simple docstring""" import re from filelock import FileLock try: import nltk UpperCAmelCase__ : Optional[Any] = True except (ImportError, ModuleNotFoundError): UpperCAmelCase__ : Union[str, Any] = False if NLTK_AVAILABLE: with FileL...
25
"""simple docstring""" import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, ...
25
1
def __lowercase ( _UpperCamelCase, _UpperCamelCase ) ->list[int]: """simple docstring""" lowercase : Dict = int(_UpperCamelCase ) # Initialize Result lowercase : Union[str, Any] = [] # Traverse through all denomi...
173
from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { '''google/pegasus-large''': '''https://huggingface.co/google/pegasus-large/resolve/main/config.json''', # See all PEGASUS models at https://huggingface.co/models?filter=p...
173
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_SNAKE_CASE_: Optional[Any] =logging.get_logger(__name__) SCREAMING_SNAKE_CASE_: List[Any]...
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
'''simple docstring''' from __future__ import annotations import math def __A ( lowerCAmelCase_ ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all ...
170
'''simple docstring''' import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_...
170
1
def SCREAMING_SNAKE_CASE_ ( __magic_name__ : int = 50 ) -> int: """simple docstring""" UpperCamelCase :Any = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start in range(...
38
'''simple docstring''' import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class a__( enum.En...
272
0
'''simple docstring''' import math def snake_case_ ( lowerCAmelCase_ )-> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1,...
349
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance A_ : List[Any] = 637_8137.0 A_ : Dict = 635_6752.31_4245 A_ : int = 6_3_7_8_1_3_7 def snake_case_ ( lowerCAmelCase_ ,...
349
1
"""simple docstring""" def _A ( ): """simple docstring""" for n in range(1 , 1_00_00_00 ): yield n * (n + 1) // 2 def _A ( lowercase ): """simple docstring""" a =1 a =2 while i * i <= n: ...
81
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json""", }...
166
0
'''simple docstring''' import os def _lowerCamelCase ( lowerCamelCase_ : int ): """simple docstring""" UpperCAmelCase_ : List[str] = len(grid[0] ) UpperCAmelCase_ : List[str] = len(__lowerCamelCase ) UpperCAme...
360
'''simple docstring''' import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common impor...
274
0
'''simple docstring''' 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...
271
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def UpperCAmelCase_ (__a : List[Any] ): """simple docstring""" if ( (cp >= 0x4E_00 and cp <= 0x9F_FF) or (cp >= 0x34_00 and cp <= ...
271
1
'''simple docstring''' from typing import Union import fire import torch from tqdm import tqdm def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase = "cpu" , UpperCamelCase = None ): """simple docstring""" lowerCAmelCase__ : str = torch.load(Uppe...
357
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCAmelCase_( metaclass=SCREAMING_SNAKE_CASE_ ): '''simple docstring''' __lowercase : int = ['''sentencepiece'''] def __init__( self ,*__UpperCAmelCase ,**__UpperCAmelCase ...
184
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, logging, ) logging.set_v...
248
import requests from bsa import BeautifulSoup def UpperCAmelCase_ ( __snake_case = "https://www.worldometers.info/coronavirus" ) -> dict: """simple docstring""" _lowercase =BeautifulSoup(requests.get(__snake_case ).text , '''html.parser''' ) _lowerc...
5
0
"""simple docstring""" import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) lowerCamelCase_ = ...
370
"""simple docstring""" def snake_case ( A__ = 10_00 ): UpperCAmelCase_ : Optional[Any] = 2**power UpperCAmelCase_ : Optional[int] = str(A__ ) UpperCAmelCase_ : Tuple = list(A__ ) UpperCAmelCase_ : Any = 0 ...
253
0
'''simple docstring''' import cmath import math def UpperCamelCase_ ( A__ : float , A__ : float , A__ : float , A__ : float ): '''simple docstring''' lowerCAmelCase_ : List[Any] = math.radians(A...
120
'''simple docstring''' from math import ceil def UpperCamelCase_ ( A__ : int = 10_01 ): '''simple docstring''' lowerCAmelCase_ : List[Any] = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): lowerCAmelCase_ : ...
120
1
'''simple docstring''' import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_comm...
37
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps ...
37
1
from __future__ import annotations from collections.abc import MutableSequence class __lowerCAmelCase : def __init__( self , _snake_case , _snake_case ): """simple docstring""" if len(_snake_case ) != degree + 1: raise ValueError( ...
82
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> int: if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(lowerCAmelCase__ , lowerCAmelCase__ ): raise TypeError('''Input value must be a \'int\' type''' ...
181
0
"""simple docstring""" from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def lowercase ( _SCREAMING_SNAKE_CASE : bool = True , *_SCREAMING_SNAKE_CASE : List[Any] , ...
355
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def lowercase ( _SCREAMING_SNAKE_CASE : int ): '''simple docstring''' _UpperCAmelCase = int(number**0.5 ) return n...
326
0
'''simple docstring''' def UpperCamelCase_ ( A__ : int = 10_00 ): '''simple docstring''' return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
120
"""simple docstring""" import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class _UpperCAmelCase( lowerCamelCase ): ...
194
0
'''simple docstring''' import os def UpperCamelCase_ ( ): '''simple docstring''' with open(os.path.dirname(_UpperCAmelCase ) + """/p022_names.txt""" ) as file: lowerCAmelCase_ : Optional[Any] = str(file.readlines()[0] ) lowerCAmel...
350
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __snake_case ( unittest.TestCase): """simple docstring""" def __lowercase ( self : Tuple ) -> Dict: ...
89
0
from typing import TYPE_CHECKING from ..utils import _LazyModule lowerCAmelCase__ : Dict ={ '''config''': [ '''EXTERNAL_DATA_FORMAT_SIZE_LIMIT''', '''OnnxConfig''', '''OnnxConfigWithPast''', '''OnnxSeq2SeqConfigWithPast''', '''PatchingSpec''', ], ...
257
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { """microsoft/git-base""": """https://huggingface.co/microsoft/gi...
323
0
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 ...tes...
357
def __lowerCamelCase ( UpperCAmelCase_ : int = 100 ): """simple docstring""" a :List[Any] = 0 a :List[Any] = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_int...
281
0
def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' if edge <= 0 or not isinstance(lowerCAmelCase__ , lowerCAmelCase__ ): raise ValueError('''Length must be a positive.''' ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def UpperCame...
101
'''simple docstring''' import colorsys from PIL import Image # type: ignore def _A ( A__ , A__ , A__ ): """simple docstring""" __lowercase = x __lowercase = y for step in range(A__ ): # noqa: B007 __lowercase = a * a - b * b + x __lo...
104
0
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def a_ ( lowerCAmelCase_ : Dict[str, torch.Tensor] ): __lowerCAmelCase = [] __lowerCAmelCase = [] __lowerCAm...
207
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 _snake_case : Union[str, Any] = False try: _snake_case ...
207
1
'''simple docstring''' import os import sys import unittest A =os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_...
34
'''simple docstring''' from collections.abc import Sequence def lowercase_ ( lowerCAmelCase__ : Sequence[float] , lowerCAmelCase__ : float ): """simple docstring""" return sum(c * (x**i) for i, c in enumerate(lowerCAmelCase__ ) ) def ...
254
0
"""simple docstring""" import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow UpperCamelCase : Union[str, Any] = False class __lowerCAmelCase ( unittest.TestCase ...
263
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase : str = logging.get_logger(__name__) UpperCamelCase : Dict = { "microsoft/wavlm-base": "https://huggingface.co/microsoft/wavlm-b...
263
1
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_comm...
12
def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : int , _lowerCamelCase : int) -> float: '''simple docstring''' return base * power(_lowerCamelCase , (exponent - 1)) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of e...
232
0
from __future__ import annotations from collections.abc import MutableSequence class __lowerCamelCase : """simple docstring""" def __init__( self : Dict , SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : MutableSequence[fl...
367
import argparse from collections import defaultdict def _A ( lowerCAmelCase_ : Dict , lowerCAmelCase_ : str , lowerCAmelCase_ : Dict , lowerCAmelCase_ : Dict , lowerCAmelCase_ : int ): """simple docstring""" l...
221
0
import argparse import os import re lowerCAmelCase__ = """src/diffusers""" # Pattern that looks at the indentation in a line. lowerCAmelCase__ = re.compile(R"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. lowerCAmelCase__ = re.compile(R"""^\s*\"([^\...
68
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from...
55
0
"""simple docstring""" import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer fr...
365
from maths.prime_factors import prime_factors def A (__A : int ) -> int: """simple docstring""" if not isinstance(__A , __A ): UpperCAmelCase_ = F"""Input value of [number={number}] must be an integer""" ...
7
0
from __future__ import annotations def UpperCamelCase ( __lowercase : list[int] ,__lowercase : int ): '''simple docstring''' A_ : list[list[int]] = [] A_ : list[int] = [] A_ : int = 0 A_ : Any = sum(__lower...
140
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 _U...
140
1
from maths.prime_factors import prime_factors def UpperCAmelCase_ ( __UpperCAmelCase : str ) -> int: if not isinstance(a_ , a_ ): SCREAMING_SNAKE_CASE_ = f"Input value of [number={number}] must be an integer" raise TypeError(a...
364
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar lowerCamelCase__ : Dict = TypeVar('T') def UpperCAmelCase_ ( __UpperCAmelCase : int ) -> int: return (position - 1) // 2 def UpperCAmelCase_ ( __UpperC...
210
0
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ ): return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
100
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin __magic_name__ = get_t...
100
1
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class __magic_name__ ( _UpperCamelCase ): @staticmethod @abstractmethod def __lowercase ( _UpperCAmelCase : ArgumentParser ): raise NotImplemente...
107
'''simple docstring''' import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets from datasets import load...
107
1
'''simple docstring''' import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def U...
151
'''simple docstring''' from __future__ import annotations def UpperCamelCase( UpperCAmelCase_ , UpperCAmelCase_ ): if partitions <= 0: raise ValueError('partitions must be a positive number!' ) if partitions > number_of_bytes: raise ValueError('partitions can not > number_of_b...
151
1
# Copyright (c) 2021-, NVIDIA CORPORATION. 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...
371
def SCREAMING_SNAKE_CASE ( lowercase_ ) -> str: """simple docstring""" return " ".join( ''''''.join(word[::-1] ) if len(lowercase_ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reve...
231
0
import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class A__ ( TensorFormatter[Mapping, '...
99
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def __UpperCAmelCas...
249
0
"""simple docstring""" 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 __UpperCamelCase ...
309
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when...
309
1
def lowerCamelCase__ ( A__ : str , A__ : str ): '''simple docstring''' assert x is not None assert y is not None __lowerCamelCase = len(A__ ) __lowerCamelCase = len(A__ ) # declaring the array for storing the d...
12
from __future__ import annotations def lowerCamelCase__ ( A__ : list[int] , A__ : list[int] , A__ : list[int] , A__ : list[list[str]] , A__ : int , ): '''simple docstring''' __lowerCamelCase = len(A__ ...
12
1
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def lowerCAmelCase__...
94
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration __snake_case : Dict =HfArgumentParser(InitializationArguments) __snake_case : Tuple =parser.parse_args() # Load codeparrot tokenizer trained for Pyth...
94
1
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional import Interpo...
6
from itertools import permutations def snake_case_ ( lowerCAmelCase_ : tuple ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False __lowercase : ...
233
0
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _snake_case ( _snake_case ): SCREAMING_SNAKE_C...
366
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 from ..image_utils impo...
281
0
'''simple docstring''' _lowerCAmelCase = '''0.18.2''' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version...
37
"""simple docstring""" def _snake_case ( UpperCamelCase : list ): if not isinstance(UpperCamelCase , UpperCamelCase ): raise ValueError("""Input series is not valid, valid series - [2, 4, 6]""" ) if len(UpperCamelCase ) == 0: raise ValueError("""Input list must be ...
109
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig class __UpperCAmelCase ( A__ ): '''simple docstring''' __lowerCAmelCase = '''bert-generation''' def __init__(self : Any , _lowerCAmelCase : Tuple=5_0358 , _lowerCAmelCase : Tuple=1024...
353
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _lowerCamelCase : Dict = logging.get_logger(__name__) _lowerCamelCase : Any = { 'google/umt5-small'...
337
0
"""simple docstring""" def _lowercase ( __snake_case ) -> int: __lowerCAmelCase : List[str] = len(__snake_case ) __lowerCAmelCase : Dict = sum(__snake_case ) __lowerCAmelCase : List[Any] = [[False for x...
269
"""simple docstring""" from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def _lowercase ( __snake_case = "laptop" ) -> DataFrame: __lowerCAmelCase : str = F"""https://www.amazon.in/laptop/s...
269
1
from __future__ import annotations import numpy as np def lowerCamelCase__ ( A__ : list[float] ): '''simple docstring''' return np.maximum(0 , A__ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
354
import requests from bsa import BeautifulSoup def lowerCamelCase__ ( A__ : str = "https://www.worldometers.info/coronavirus" ): '''simple docstring''' __lowerCamelCase = BeautifulSoup(requests.get(A__ ).text , """html.parser""" ) __lowerCamelCase ...
29
0
'''simple docstring''' from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class lowerCAmelCase__ ( lowerCamelCase_ ): ...
93
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging....
143
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCAmelCase = {"configuration_glpn": ["GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP", "GLPNConfig"]} try: if not is_vision_available():...
98
'''simple docstring''' import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class _SCREAMING_SNAKE_CASE : def __init__( self : Optional[Any] , ...
98
1
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __A ( SCREAMING_SNAKE_CASE_ ): _UpperCamelCase : Optional[Any] = ["image_processor", "tokenizer"] _UpperCamelCase : List[Any...
44
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandin...
44
1
'''simple docstring''' import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers...
322
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar lowerCamelCase__ = TypeVar('T') class lowerCAmelCase__ ( Generic[T] ): def __init__( self : Union[str, Any]...
322
1
"""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/licens...
260
"""simple docstring""" def lowercase ( _SCREAMING_SNAKE_CASE : list[list[int]] , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : set ): '''simple docstring''' _UpperCAmelCase , _UpperCAm...
260
1
'''simple docstring''' from typing import Union import fire import torch from tqdm import tqdm def _lowerCAmelCase ( lowercase , lowercase = "cpu" , lowercase = None ) -> None: __lowerCAmelCase = torch.load(lowercase , map_location=lowercase ) for k...
46
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : List[Any] = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} ...
46
1
import math def a_ ( SCREAMING_SNAKE_CASE__ : int = 100 ): '''simple docstring''' _lowerCamelCase : Optional[Any] =sum(i * i for i in range(1 , n + 1 ) ) _lowerCamelCase : Tuple =int(math.pow(sum(range(1 , n + 1 ) ) , 2 ...
199
from sklearn.metrics import mean_squared_error import datasets lowerCamelCase = '\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n and Thirion, B. and Grisel, O. and Blondel, M. and Pr...
199
1
"""simple docstring""" from math import pi, sqrt def lowercase ( _SCREAMING_SNAKE_CASE : float ): '''simple docstring''' if num <= 0: raise ValueError('''math domain error''' ) if num > 171.5: raise OverflowError('''math range erro...
326
"""simple docstring""" class _a : """simple docstring""" def __init__( self : Tuple , __UpperCamelCase : list[int] )->None: _UpperCAmelCase = len(__UpperCamelCase ) _UpperCAmelCase = [0] * len_array ...
326
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { 'microsoft/git-base': 'https://huggingface.co/microsof...
288
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ ...
288
1
"""simple docstring""" import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def _A ( _a : Optional[Any] ): """simple docstring""" A = args.pr...
77
"""simple docstring""" def _A ( _a : str , _a : str ): """simple docstring""" A = len(_a ) + 1 A = len(_a ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of ...
77
1
def lowerCamelCase__ ( _a): assert ( isinstance(lowerCAmelCase_ , lowerCAmelCase_) and number_of_steps > 0 ), f"number_of_steps needs to be positive integer, your input {number_of_steps}" if number_of_steps == 1: return 1 SCREAMING_SNAKE_CASE : str = 1, 1 for _ in rang...
76
from typing import Union import fire import torch from tqdm import tqdm def lowerCAmelCase ( lowerCAmelCase_ , lowerCAmelCase_ = "cpu" , lowerCAmelCase_ = None )-> None: lowerCAmelCase_ : str = torch.load(lowerCAmelCase_ , map_location=low...
262
0
'''simple docstring''' import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer a_ = logging.getLogger(__name__) def _a( ): SCREAMING_SNAKE_CASE__ : str =argparse.ArgumentParser( ...
371
'''simple docstring''' import math def _a( UpperCamelCase__ : int ): '''simple docstring''' return math.sqrt(UpperCamelCase__ ) * math.sqrt(UpperCamelCase__ ) == num def _a( UpperCamelCase__ : int ): ...
222
0
from __future__ import annotations import collections import pprint from pathlib import Path def __magic_name__ ( A : str ): '''simple docstring''' return "".join(sorted(A ) ) def __magic_name__ ( A : str ): '''simple docstring''' return ...
107
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowerCAmelCase : List[str] = { 'configuration_resnet': ['RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ResNetConfig', '...
107
1
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): import ...
350
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer _A = logging.get_logger(__name__) _A = {'''vocab_fil...
261
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A: Union[str, Any] = { "configuration_blenderbot": [ "BLENDE...
109
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device ...
316
0
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class snake_case__ : """simple docstring""" lowerCamelCase = 42 lowerCamelCase = 42 c...
354
'''simple docstring''' import requests lowercase__ = "" # <-- Put your OpenWeatherMap appid here! lowercase__ = "https://api.openweathermap.org/data/2.5/" def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ = "Chicago" , SCREAMING_SNAKE_CASE__ = APPID ) -> dict: '''sim...
83
0
from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import stable_softmax if is_...
52
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_spe...
75
0
def lowerCAmelCase__ ( _a : Union[str, Any] , _a : List[str] , _a : Union[str, Any] ): if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(_a , n - 1 , _a ) * a) % mod else: snake_case_ : Any = binary_expo...
36
def lowerCAmelCase__ ( _a : dict ): snake_case_ : List[Any] = set() # edges = list of graph's edges snake_case_ : int = get_edges(_a ) # While there are still elements in edges list, take an arbitrary edge # (from_node, to_node) and add his extre...
36
1
import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets __lowerCamelCase : Any = datasets.logging.get_logger(__name__) __lowerCamelCase : Any = '''\ @InProceedings{moosavi2...
219
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger _a = get_logger(__name__) class __lowerCamelCase ( enum.Enum): """simple docstring""" UpperCamelCase__ = ...
39
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCAmelCase = { '''configuration_x_clip''': [ '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XCLIPConfig''', '''XCLIPTextC...
107
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def __lowerCamelCase ( lowerCAmelCase_ ) -> str: return "".join(sorted(lowerCAmelCase_ ) ) def __lowerCamelCase ( lowerCAmelCase_ ) -> list[str]: ...
107
1
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embedd...
28
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfi...
28
1
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transform...
4
'''simple docstring''' import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_comm...
4
1
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def __snake_case ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): # Initialise PyTorch model ...
49
from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): import torch from ..mode...
49
1
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class A (_UpperCAmelCase ): '''simple docstring''' __lowerCamelCase : Tuple = ['image_processor', 'tokenizer'] __lowerCamelCase : Union[str, Any] = ...
355
import unittest import numpy as np def __lowerCamelCase ( __a :np.ndarray , __a :np.ndarray , __a :np.ndarray , __a :np.ndarray | None = None , ) -> np.ndarray: """simple docstring""" A__ = np.s...
276
0
'''simple docstring''' from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class _A ( __SCREAMING_SNAKE_CASE ): ...
254
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _lowerCAmelCase ( unittest.TestCase ,lowercase ): """simple docstring""" def _lowercase ( self : List[Any] ): __lowercase = ...
17
0
'''simple docstring''' import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class UpperCAmelCase_ ( unittest.TestCase ): '''simple docstring''' def _lowercase ( self ): ...
364
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCAmelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docs...
229
0
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor a : Optional[int] = logging.get_logger(__name__) class a ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" def __init__( self : Dict ...
114
"""simple docstring""" import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from...
179
0
'''simple docstring''' from math import factorial _A : Optional[Any] ={str(d): factorial(d) for d in range(10)} def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> Any: return sum(DIGIT_FACTORIAL[d] for d in str(A_ ) ) def SCREAM...
358
'''simple docstring''' 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_uti...
129
0
'''simple docstring''' from __future__ import annotations from typing import Any class _a : '''simple docstring''' def __init__( self, A = 6 ): '''simple docstring''' SCREAMING_S...
251
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, ...
251
1
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase ( UpperCamelCase__ ): @staticmethod @abstractmethod def UpperCAmelCase_ ( lowercase_ :ArgumentParser )-> Dict: raise NotImplementedError() ...
365
'''simple docstring''' from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def UpperCamelCase ( _lowerCamelCase : bool = True , *_lowerCamelCase : Optional[int] , **_lowerCamelCase : Optional[Any] )...
123
0
from math import pi, sqrt def A__ ( __lowerCamelCase ): if num <= 0: raise ValueError('''math domain error''' ) if num > 1_71.5: raise OverflowError('''math range error''' ) elif num - int(__lowerCamelCase ) not in (0, 0.5): raise NotImplementedError('''num must be an int...
299
import math def A__ ( __lowerCamelCase ): SCREAMING_SNAKE_CASE_ = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(__lowerCamelCase ) def A__ ( __lowerCamelCase = 1 / 1_23_45 ): SCREAMING_SNAKE_CASE_ = 0 SCREAMING_SNAKE_CASE_ ...
299
1
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 lowercase_ ( __lowercase ): UpperCame...
278
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_utils import is...
278
1
'''simple docstring''' import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_...
346
'''simple docstring''' from math import factorial def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : int = 20 ): '''simple docstring''' UpperCAmelCase__ = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... UpperCAmelCase__ = n // 2...
346
1
'''simple docstring''' import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class lowerCamelCase_ : lowerCAmelCase__ = None def lowercase_ ( self : Tuple ): '''simp...
360
'''simple docstring''' 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 Mode...
299
0
'''simple docstring''' 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 a__ ( UpperCAmelCase__ )...
67
"""simple docstring""" from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar __A = TypeVar("""KEY""") __A = TypeVar("""VAL""") @dataclass(frozen=a , slots=a ) class _lowerCAmelCase ( Generic[...
293
0
'''simple docstring''' _lowercase : Union[str, 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_di...
264
'''simple docstring''' import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor _lowercase : Any = logging.get_logger(__name__) class lowerCAmelCase__ ( lowerCamelCase_ ): def __init__( s...
264
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'bert-base-un...
108
'''simple docstring''' import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging lowercase__ : Any = logging.get_logger(__name__) class __lowerCAmelCase : """simple docstring""" _snake_case : ...
324
0
'''simple docstring''' def SCREAMING_SNAKE_CASE__( _UpperCamelCase : str ) -> bool: '''simple docstring''' return credit_card_number.startswith(("34", "35", "37", "4", "5", "6") ) def SCREAMING_SNAKE_CASE__( _UpperCamelCase : str ) ...
31
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput cl...
31
1
'''simple docstring''' import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism()...
139
'''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, ...
139
1
import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging lowercase : Any ...
36
import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py lowercase : Optional[Any] = '''src/diffusers''' # Matches is_xxx_available() lowercase : Any ...
36
1
__lowerCamelCase : dict[tuple[int, int, int], int] = {} def _snake_case ( lowerCAmelCase : int , lowerCAmelCase : int , lowerCAmelCase : int ): """simple docstring""" if late == 3 or absent == 2: return 0 # if we have no days left, and have not failed...
18
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowerCamelCase : Dict = {'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMAEConfig''']} try...
18
1
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class __magic_name__ : """simple docstring""" __UpperCamelCase = 42 __UpperCamelCase = None __UpperCamelCase = None ...
70
from random import randint from tempfile import TemporaryFile import numpy as np def __snake_case ( _lowerCAmelCase : Optional[int] , _lowerCAmelCase : str , _lowerCAmelCase : Optional[int] ) -> Dict: A_ : Optional[Any] = 0 if start < end: A_ : Tuple = ...
70
1
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): import os...
329
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class __a ( UpperCAmelCase ): def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> Any: """...
329
1
import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants _UpperCAmelCase : Dict = Mapping[str, np.ndarray] _UpperCAmelCase : Union[str, Any] = Mapping[str, Any] # ...
200
def __lowerCamelCase ( UpperCamelCase__ , UpperCamelCase__ ): '''simple docstring''' return int((input_a, input_a).count(0 ) != 0 ) def __lowerCamelCase ( ): '''simple docstring''' assert nand_gate(0 , 0 ) == ...
200
1
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = R""" Args: input_ids (`torch.LongTensor` of shape...
92
'''simple docstring''' from collections import defaultdict def __magic_name__ ( __UpperCAmelCase ) -> int: '''simple docstring''' snake_case_ = 1 snake_case_ = True for v in tree[start]: if v not in visited: ret += dfs(__UpperCAmelCa...
56
0
import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import DEFAULTS, task_specific_para...
360
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { "s-JoL/Open-Llama-V1": "https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json", } class a_ ( _snake_case ): ...
344
0