code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : List[Any] = logging.get_logger(__name__) _lowerCamelCase : List[Any] = { "microsoft/swinv2-tiny-patch4-window8-256": ( "https://huggingface.co/microsoft/swinv2-tiny-patch4-window8...
429
from collections import deque from .hash_table import HashTable class __snake_case (_a ): def __init__( self : int , *_UpperCAmelCase : str , **_UpperCAmelCase : Union[str, Any] ) -> Tuple: '''simple docstring''' super().__init__(*_UpperCAmelCas...
429
1
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class SCREAMING_SNAKE_CASE_ ( unittest.TestCase ): """simple docstring""" def __lowercase ( self :int ): _...
703
"""simple docstring""" from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging _UpperCamelCase = logging.get_logger(__name__...
363
0
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# lowerCamelCase__ : Dict = [ # (stable-diffusion, HF Diffusers) ('time_embed.0.weight', 'time_embedding.linear...
31
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDep...
391
0
'''simple docstring''' import operator def __UpperCAmelCase ( a_: list, a_: bool = False, a_: list | None = None ): _UpperCAmelCase : Tuple = operator.lt if reverse else operator.gt _UpperCAmelCase : Any = solution or [] if not arr: ...
714
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a = { 'configuration_timesformer': ['TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimesformerConfig'], } try: if not is_torch_available(): ...
257
0
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(F...
257
import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_commo...
192
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a_ = {} try: if not is_sentencepiece_available(): raise OptionalDepe...
705
"""simple docstring""" import copy import random from transformers import CLIPTokenizer class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , **UpperCamelCase_ ) -> Optional[Any]: super().__init__(*UpperCamelCase_ , **UpperC...
523
0
'''simple docstring''' def _lowerCAmelCase ( __magic_name__ : int ) -> str: if number > 0: raise ValueError('''input must be a negative integer''' ) lowercase : Dict =len(bin(__magic_name__ )[3:] ) lowercase : List[Any] ...
92
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A_ ( SCREAMING_SNAKE_CASE ): _UpperCAmelCase : int = (UnCLIPScheduler,) def lowerCAmelCase ( self : Union[str, Any] ,**SCREAMI...
652
0
"""simple docstring""" import os from datetime import datetime as dt from github import Github lowercase__ :Any = [ 'good first issue', 'feature request', 'wip', ] def lowerCamelCase_ ( ) ->str: """simple docstring""" ...
704
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf lowercase_...
374
0
from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_space_opt...
2
"""simple docstring""" import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __a ( A ) -> Union[str, Any]: '''s...
337
0
'''simple docstring''' from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
570
'''simple docstring''' def __snake_case ( SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int ) -> int: """simple docstring""" if exponent == 1: return base if exponent % 2 == 0: UpperCAmelCase =...
570
1
import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ...
87
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
40
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device snake_case = False class UpperCA...
710
"""simple docstring""" def snake_case ( lowerCAmelCase_ = 1000 ) -> int: return sum(e for e in range(3 , lowerCAmelCase_ ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F"{solution() = }")
404
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ : str = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json''', ...
375
def lowerCAmelCase ( UpperCAmelCase, UpperCAmelCase ) ->list: """simple docstring""" __magic_name__ : Optional[Any] = word.split() def justify(UpperCAmelCase, UpperCAmelCase, UpperCAmelCase ) -> str: __mag...
154
0
import os import sys import unittest _snake_case : Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy...
720
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class ...
421
0
"""simple docstring""" import os import sys import unittest _lowerCAmelCase : Any = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E...
46
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { 'weiweishi/roc-bert-base-zh': 'https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json', } class Upp...
473
0
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path snake_case_ : List[Any] = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) snake_case_ : List[Any] = [ord(letter)...
708
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if ...
350
0
'''simple docstring''' import math from datetime import datetime, timedelta def __A ( a_ : int ): lowerCAmelCase : Any = year % 1_9 lowerCAmelCase : str = year % 4 lowerCAmelCase : Union[str, Any] = year % 7 lowerCAmelCase : ...
525
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resi...
348
0
"""simple docstring""" import requests from bsa import BeautifulSoup def SCREAMING_SNAKE_CASE ( snake_case = "https://www.worldometers.info/coronavirus"): __snake_case = BeautifulSoup(requests.get(_lowerCamelCase).text, '''html.parser''') __snake_case = ...
700
"""simple docstring""" def SCREAMING_SNAKE_CASE ( snake_case): __snake_case = len(snake_case) for i in range(length - 1): __snake_case = i for k in range(i + 1, snake_case): if collection[k] < collection[least]: ...
93
0
from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowercase : Optional[int] =logging.get_logger(__name__) __lowercase : Optional[Any] ={ """microsoft/xprophetnet-large-wiki100-cased""": ( """h...
54
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { """microsoft/focalnet-tiny""": """...
678
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer lowerCamelCase =logging.get_logger(__name__) lowerCamelCase ={"vocab_file": "vo...
705
from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand lowerCamelCase =logging.get_logger(__name__) # pylint: disable=invalid-name def SCREAMING_SNAKE_CASE_ ( U...
462
0
from __future__ import annotations from collections import Counter from random import random class __UpperCAmelCase : """simple docstring""" def __init__( self ): __a = {} def snake_case_ ( self , __A ): __a = {} ...
99
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common im...
319
0
def lowerCamelCase__ ( _A ): if not all(char in '01' for char in bin_string ): raise ValueError('Non-binary value was passed to the function' ) if not bin_string: raise ValueError('Empty string was passed to the function' ) a : Any = '' while len(_A ) %...
707
'''simple docstring''' class a__: def __init__( self : Dict , __snake_case : Optional[int] , __snake_case : Any , __snake_case : Tuple ): a : List[str] = name a : Dict = value a : List[str] ...
195
0
def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): return number | (1 << position) def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): return number & ~(1 << position) def UpperCAmelCase_ ( __SCREAMING_SNAK...
84
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( Au...
64
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available a = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxConfig'], } try:...
347
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING a = logging.get_logger(__name__) a = { 'SenseTime/deformable-detr': 'https://huggingface.co/sensetime/def...
347
1
"""simple docstring""" import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import ve...
482
from __future__ import annotations from random import random from typing import Generic, TypeVar __UpperCamelCase : Any = TypeVar("KT") __UpperCamelCase : List[Any] = TypeVar("VT") class __lowerCAmelCase ( Generic[KT, VT] ): def __init__( self ...
468
0
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pip...
714
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
626
0
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py _lowerCAmelCase = "\\n@INPROCEEDINGS{Papineni02bleu:a,\n author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu},\n title = {BLEU: a Method for Automatic Eval...
10
"""simple docstring""" from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class UpperCAmelCase ( yaml.SafeLoader ): def __UpperCAmelCase ( self : Tuple , __lowerCamelCase : List[str] ...
103
0
_UpperCAmelCase : List[Any] = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ _UpperCAmelCase : ...
715
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 _UpperCAmelCase : Dict = logging.get_logger(__name__) _UpperCAmel...
108
0
import math def __lowerCAmelCase ( _UpperCamelCase , _UpperCamelCase = 0 , _UpperCamelCase = 0 ) -> list: '''simple docstring''' lowerCamelCase__: Union[str, Any] = end or len(_UpperCamelCase ) for i in range(_UpperCamelCase ...
306
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import tor...
306
1
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar __snake_case : int = TypeVar("T") __snake_case : List[Any] = TypeVar("U") class A ( Generic[T, U] ): def __init__( self , ...
705
'''simple docstring''' import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unorde...
691
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler...
444
'''simple docstring''' import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets lowerCAmelCase : Optional[int] = datasets.logging.get_logger(__name__) lowerCAmelCase : List[str] = """\ @inprocee...
444
1
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): lowerCamelCase : Optional[int] = yaml.safe_load( '''\ name: "" allow_empty: false allow_empty_text: true subsections: - ...
290
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Ac...
290
1
import colorsys from PIL import Image # type: ignore def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase ,lowercase ) -> List[Any]: snake_case : Optional[int] = x snake_case : Tuple = y for step in range(lowerCAmelCase__ ): # noqa: B007 snake_...
587
import argparse import os import re _lowercase : List[str] ="""src/diffusers""" # Pattern that looks at the indentation in a line. _lowercase : str =re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in group 0. _lowercase : Dict =re.comp...
364
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
720
def SCREAMING_SNAKE_CASE__ ( lowercase ) -> list: for i in range(len(lowercase ) - 1 ,0 ,-1 ): snake_case : Any = False for j in range(lowercase ,0 ,-1 ): if unsorted[j] < unsorted[j - 1]: snake_case , snake_case : Option...
684
0
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class __a: """simple docstring""" def __init__( self ,_SCREAMING_SNAKE_CASE=2 ,_SCREAMING_SNAKE_CASE=3 ,_SCREAMING_SNAKE_CASE=64 ,_SCREAMING_SNAKE_CASE=None ...
30
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase_ : '''simple docstring''' def __init__( self : Any , _lowerCAmelCase : Optional[int]=2 , _lowerCAme...
31
0
import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging logging.set_verbosity_info...
715
import collections import os import re from pathlib import Path lowercase : int = """src/transformers""" # Matches is_xxx_available() lowercase : List[str] = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-line _import_struct = {xxx} lowercase : str = re.compil...
392
0
'''simple docstring''' from __future__ import annotations import math A_ = "2020.9.26" A_ = "xcodz-dot, cclaus, dhruvmanila" def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ) -> tuple[float, float]: if not all(isi...
42
from random import shuffle import tensorflow as tf from numpy import array def A_ ( _lowerCAmelCase , _lowerCAmelCase ) -> Optional[Any]: UpperCamelCase : List[Any] = int(_lowerCAmelCase ) assert noofclusters < len(_lowerCAmelCase ) # Find out the dimensionality Upper...
629
0
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_roberta import Robe...
212
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging...
212
1
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated __A = collections.namedtuple('''_Datasets''', ['''train...
646
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def lowerCAmelCase__(__snake_case ) -> Dict: '''simple docstring''' if "img_encoder.pos_embed" in name: lowerCamelCase__ = na...
481
0
def A_ ( lowercase_ ) ->bool: """simple docstring""" 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...") __UpperCAmelCase = int(input...
259
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = { "configuration_layoutlmv3": [ "LAYOUTLMV3_PRETRAINED_CO...
259
1
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": lowerCamelCase__ = input("""Enter image url: """).strip() print(F"""Downloading image from {url} ...""") lowerCamelCase__ = BeautifulSoup(requests.get(url).content, """html.parser...
225
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """uw-madison/mra-base-512-4""": """https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json""", } class SCREAMING_SNAKE_...
225
1
import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class A_ ( __UpperCamelCase , unittest.TestCase ): '''simple docstring''' __snake_case = DownB...
713
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @dataclass class...
230
0
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, i...
109
from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('''To use the rich extension, install rich with `pip install rich`''')
36
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _A : int = { '''configuration_nezha''': ['''NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NezhaConfig'''], } try: if...
330
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _A : List[str] = logging.get_logger(__name__) _A : Any = { '''facebook/nllb-moe-54B''': '''https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json'...
330
1
'''simple docstring''' # flake8: noqa # Lint as: python3 lowerCamelCase = [ """VerificationMode""", """Version""", """disable_progress_bar""", """enable_progress_bar""", """is_progress_bar_enabled""", """experimental""", ] from .info_utils import VerificationMode from .logg...
474
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class _UpperCamelCase ( unittest.TestCase ): ...
474
1
"""simple docstring""" from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar UpperCAmelCase = TypeVar("""T""") class UpperCAmelCase_ ( Generic[T]): def __init__( self : int , __UpperCamelCase : list[T] , __Upp...
342
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers.testing_utils impor...
342
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor _a : Union[str, Any] = logging.get_logger(__name__) class _lowercase ( __lowercase ): def __init__( self : Dict , *SCREAMING_SNAKE_...
56
def __lowerCAmelCase ( A_ : int , A_ : int ) -> int: return x if y == 0 else greatest_common_divisor(A_ , x % y ) def __lowerCAmelCase ( A_ : int , A_ : int ) -> int: return (x * y) // greatest_common_divisor(A_ , A_ ) d...
221
0
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def _UpperCAmelCase ( __lowerCamelCase : Dict ) -> int: _snake_case = [ '''encoder.version''', '''decoder.version''',...
709
"""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/LICENS...
430
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ :Optional[Any] = logging.get_logger(__name__) UpperCamelCase__ :Optional[int] = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } c...
355
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ :str = logging.get_logger(__name__) UpperCamelCase__ :Optional[int] = { """microsoft/markuplm-base""": """https://huggingface.co/microsoft/markuplm-base/resolve/main/c...
355
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __magic_name__ ={} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else:...
469
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class _A ( __UpperCamelCase , __UpperCamelCase ): @register_to_config def __init__(self ...
469
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
66
"""simple docstring""" def UpperCAmelCase_ ( __a : list ): '''simple docstring''' if len(__a ) <= 1: return lst _lowerCamelCase : str = 1 while i < len(__a ): if lst[i - 1] <= lst[i]: i += 1 else: _lowerC...
437
0
'''simple docstring''' 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 imp...
330
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _A : Union[str, Any] = logging.get_logger(__name__) _A : Union[str, Any] = { '''facebook/dpr-ctx_encoder-single-nq-base''': ( '''https://huggingface.co/...
330
1
"""simple docstring""" import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(_a ) ,...
46
from torch import nn class __lowerCAmelCase ( nn.Module ): """simple docstring""" def __init__( self : Optional[int] , _snake_case : List[Any] , _snake_case : Tuple ): super().__init__() __lower...
509
0
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( lowerCAmelCase__): _UpperCamelCase:Tuple = (DDPMScheduler,) def _snake_case ( self , **_SCREAMING_SNAKE_CASE )-> Tuple: ...
75
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": __A : int = '%20'.join(argv[1:]) if len(argv) > 1 else quote(str(input('Search: '))) print('Googling.....') __A...
75
1
'''simple docstring''' from __future__ import annotations def _A ( A__ ): """simple docstring""" for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in range(1 , len(A__ ) ): matrix[i][0] += matrix[i - 1][0] ...
41
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 _lowerCAmelCase : """simple docstring""" def __init__( self : List[Any] ...
654
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a__ : Dict = logging.get_logger(__name__) a__ : Union[str, Any] = { "...
309
"""simple docstring""" import argparse from collections import defaultdict import yaml a__ : List[str] = """docs/source/en/_toctree.yml""" def A__ ( __lowerCamelCase ): """simple docstring""" _lowerCAmelCase = defaultdict(__lowerCamelCase ) for do...
309
1
def UpperCAmelCase ( lowercase , lowercase , lowercase , lowercase ): """simple docstring""" __lowercase , __lowercase = len(UpperCamelCase__ ), len(grid[0] ) if ( min(UpperCamelCase__ , UpperCamelCase__ ) < 0 or...
534
import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class a ( __SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase_ : Tuple = 'M-CLIP' def __init__( self : Any , lowerCamelCase__ : List[Any]=1_...
332
0
import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffusers.utils.testing_utils import en...
713
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class SCREAMING_SNAKE_CASE_ (a__ ): ...
171
0
def a_ ( __magic_name__ ) -> None: """simple docstring""" snake_case : Any = generate_pascal_triangle(__magic_name__ ) for row_idx in range(__magic_name__ ): # Print left spaces for _ in range(num_rows - row_idx - 1 ...
598
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=a ) class a_ ( a ): # `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON ser...
598
1
'''simple docstring''' from collections.abc import Sequence def _lowerCamelCase ( lowerCamelCase_ : Sequence[int] | None = None ): """simple docstring""" if nums is None or not nums: raise ValueError('Input sequence should not be empty' ) UpperCAmelCa...
715
'''simple docstring''' import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_senten...
389
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Union[str, Any] = logging.get_logger(__name__) a__ : Optional[int] = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } ...
51
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils import Confi...
696
0
'''simple docstring''' # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all file...
4
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common impo...
4
1
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _snake_case ( __a ): """simple docstring""" lowerCame...
317
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common import FlaxModel...
271
0
'''simple docstring''' import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = {'vocab_file'...
721
'''simple docstring''' import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.uti...
68
0
'''simple docstring''' import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin a : int = ge...
69
from dataclasses import dataclass, field from typing import Optional @dataclass class A : _SCREAMING_SNAKE_CASE = field( default="""codeparrot/codeparrot""" ,metadata={"""help""": """Model name or path of model to be trained."""} ) _SCREAMING_SNAKE_CASE = ...
326
0
"""simple docstring""" import re from filelock import FileLock try: import nltk A_ : List[str] =True except (ImportError, ModuleNotFoundError): A_ : str =False if NLTK_AVAILABLE: with FileLock(""".lock""") as lock: nltk.download("""punkt""", quiet...
222
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : float )-> float: if edge <= 0 or not isinstance(snake_case , snake_case ): raise ValueError('Length must be a positive.' ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) def SCREA...
222
1
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def _a ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : complex , SCREAMING_SNAKE_CASE__ : str = "x" , SCREAMING_SNAKE_CASE__ : float = 10**-10 , SCREAMIN...
663
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ : Optional[Any] = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE...
85
0
import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizerOutput from ...
37
import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
37
1
"""simple docstring""" def a__ ( lowerCAmelCase ) -> int: if divisor % 5 == 0 or divisor % 2 == 0: return 0 UpperCAmelCase__ : Optional[Any] = 1 UpperCAmelCase__ : Any = 1 while repunit: UpperCAmelCase__ : Unio...
182
"""simple docstring""" from __future__ import annotations import math class lowerCamelCase : '''simple docstring''' def __init__(self , _lowerCamelCase ): """simple docstring""" UpperCAmelCase__ : List[str] = size # approximate the overall s...
182
1
from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch('socket.socket' ) @patch('builtins.open' ) def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> str: # ===== initialization ===== _lowercase : Tuple = Mock() _low...
720
def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> bool: return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
354
0
"""simple docstring""" import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conv...
644
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters _UpperCAmelCase : Union[str, Any] = (720, 1280) # Height, Width _UpperCAmelCase : str = (0.4, 0.6) # if height or width lower than this scale, drop it. ...
683
0
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 __snake_case ( UpperCAmelCase_ ): __lowerCAmelCase...
708
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time UpperCamelCase__ : int = Lock() def _UpperCAmelCase ( _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : Union[str, Any] , _SCREAMING_SNAKE_CASE ...
620
0
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 a : List[Any] = ...
639
from __future__ import annotations class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_ ) -> None: '''simple docstring''' __lowercase = order # a_{0} ... a_{k} __lowercase = [1.0]...
639
1
"""simple docstring""" import functools def lowercase ( _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : list[int] ): '''simple docstring''' if not isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) or n...
95
"""simple docstring""" import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def low...
95
1
'''simple docstring''' 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 A__ : List[Any] = logging.get_logger(__name__) A__ : List[str] = R''' Args:...
286
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, l...
286
1
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature f...
704
'''simple docstring''' import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness _A : Union[str, Any] = '''\ @misc{chen2021evalua...
330
0
'''simple docstring''' import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class __SCREAMING_SNAKE_CASE (__A ): """simple docstring""" _a : Tuple = (DDPMParallelScheduler,) def _a ( self , ...
536
'''simple docstring''' def __UpperCamelCase ( lowercase_ : list[int] , lowercase_ : list[int] , lowercase_ : int ): """simple docstring""" return not any( neighbour == 1 and colored_vertices[i] == color for i, ne...
536
1
"""simple docstring""" import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class UpperCamelCase_ ( a_ , a_ ): @register_to_config def __init__( self , *, snake_case__ = 4 , snake_case...
378
"""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, ...
378
1
'''simple docstring''' import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def _UpperCamelCase (_lowerCamelCase : Union[dict, list, ...
24
'''simple docstring''' def _UpperCamelCase (_lowerCamelCase : int )-> int: '''simple docstring''' if divisor % 5 == 0 or divisor % 2 == 0: return 0 __snake_case = 1 __snake_case = 1 while repunit: __snake_case ...
24
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) _lowercase = { "configuration_speech_to_text": ["SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIV...
707
import numpy as np def lowerCAmelCase__ ( UpperCamelCase_ : np.array )-> np.array: return 1 / (1 + np.exp(-vector )) def lowerCAmelCase__ ( UpperCamelCase_ : np.array )-> np.array: return vector * sigmoid(1.702 * vector ) if __name__ == "__main__": import doc...
526
0
'''simple docstring''' import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffus...
90
'''simple docstring''' from __future__ import annotations from typing import TypedDict class __SCREAMING_SNAKE_CASE ( _lowerCAmelCase ): __a =42 __a =42 def __UpperCAmelCase ( SCREAMING_SNAKE_CASE__: str ) -> list[...
448
0
import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectro...
701
def a_ ( _A , _A ) -> float: """simple docstring""" if digit_amount > 0: return round(number - int(_A ) , _A ) return number - int(_A ) if __name__ == "__main__": print(decimal_isolate(1.5_3, 0)) print(decimal_isola...
372
0
import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def lowerCAmelCase_ ( *lowerCamelCase ): if not isinstance(lowerCamelCase , lowerCamelCase ): __magic_name__ : Union[str, Any] =list(low...
21
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __lowerCAmelCase ( pl.LightningModule ): def __init__( self , snake_case ) -> Dict: """simple docstr...
112
0
'''simple docstring''' import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transf...
705
def a_ ( __magic_name__ ) -> bool: """simple docstring""" if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True snake_case : int = 4 snake_case : Optio...
84
0
"""simple docstring""" import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE : int = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : Union[s...
549
"""simple docstring""" _SCREAMING_SNAKE_CASE : Optional[int] = 8.314_4598 def lowerCamelCase__ ( _lowerCamelCase : float , _lowerCamelCase : float ) -> float: if temperature < 0: raise Exception('Temperature canno...
549
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeatureEx...
458
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device fro...
458
1
"""simple docstring""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) _s...
580
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDepen...
580
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'asapp/sew-d-tiny-100k': 'https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json', # See al...
717
"""simple docstring""" 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, loggi...
48
0
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils impo...
604
def __UpperCAmelCase ( UpperCAmelCase = 50 )-> int: """simple docstring""" lowercase = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2, 5 ): for tile_start i...
604
1
'''simple docstring''' from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class UpperCamelCase_ : def _lowercase( self , A ) -> Optional[int]: raise NotImplementedError() def _l...
672
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device a : Tuple = False class UpperCamelCase_ ( unit...
672
1
from typing import List, Union import numpy as np from ..utils import add_end_docstrings, 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 import load_image if is_torch_a...
37
"""simple docstring""" from __future__ import annotations class __magic_name__ : def __init__( self , __magic_name__ ): """simple docstring""" _lowerCAmelCase = order # a_{0} ... a_{k} _lowerCAmelCase = [1.0] + [0.0] * orde...
589
0
from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def SCREAMING_SNAKE_CASE ( snake_case_ : ...
707
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ...
25
0
"""simple docstring""" import math def __A ( a_ :int) -> bool: 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 multiples of 3 are not pr...
52
"""simple docstring""" def __A ( a_ :Tuple , a_ :Union[str, Any] , a_ :int=False) -> List[str]: if isinstance(a_ , a_) and isinstance(a_ , a_): __a : List[str] = len(set_a.intersection(a_)) if alternative...
52
1
'''simple docstring''' from collections.abc import Callable import numpy as np def A__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> np.ndarray:...
715
import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets snake_case_ = ''' @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translation for Text Simplification}, auth...
262
0
def lowerCamelCase__ ( __lowerCamelCase : List[Any] , __lowerCamelCase : Union[str, Any] ): __UpperCAmelCase : Tuple = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def lowerCamelCase__ ( ...
63
'''simple docstring''' import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class _lowerCamelCase : '''simple docstring''' def __init__( self , __lowercase , __lowercase , __lowercase ): """simple docstring""" if dst_width < 0 or dst_height < 0...
365
0
from ...processing_utils import ProcessorMixin class lowercase_ ( A ): __lowerCamelCase = ["image_processor", "feature_extractor"] __lowerCamelCase = "TvltImageProcessor" __lowerCamelCase = "TvltFeatureExtractor" def __init__( self...
431
import fire from utils import calculate_rouge, save_json def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : List[Any] , UpperCAmelCase_ : Tuple , UpperCAmelCase_ : Optional[int]=None , **UpperCAmelCase_ : Any ) -> Union[str, Any]: SCREAMING_SNAKE_CASE_ :...
431
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase_ = { 'configuration_poolformer': [ 'POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PoolFormerConfig',...
603
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ = { 'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'], 'tokenization_tr...
603
1
import logging import os from .state import PartialState class SCREAMING_SNAKE_CASE__ ( logging.LoggerAdapter ): @staticmethod def SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE__ : Any ) -> int: a_ : Optional[Any] = PartialState() ...
443
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, ...
443
1
"""simple docstring""" from collections.abc import Sequence def UpperCamelCase ( SCREAMING_SNAKE_CASE_ = None ) ->int: if nums is None or not nums: raise ValueError('''Input sequence should not be empty''' ) _lowerCamelCase : str = nums[0] for i in range...
434
"""simple docstring""" import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import ...
434
1
'''simple docstring''' __snake_case: Optional[int] = [ 9_99, 8_00, 7_99, 6_00, 5_99, 5_00, 4_00, 3_99, 3_77, 3_55, 3_33, 3_11, 2_88, 2_66, 2_44, 2_22, 2_00, 1_99, 1_77, 1_55, 1_33, 1_11, 88,...
460
'''simple docstring''' import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() __snake_case: List[str] = logging.get_logger(__name_...
460
1