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
"""simple docstring""" import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_co...
281
"""simple docstring""" import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common impor...
281
1
"""simple docstring""" 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 transform...
719
"""simple docstring""" 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 = { '''shi-labs/n...
401
0
from __future__ import annotations from typing import Any class lowerCamelCase_ ( _lowercase ): pass class lowerCamelCase_ : def __init__( self : Optional[int] , __A : Any ): __A : Any = data __A : Node | None = None ...
17
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils i...
573
0
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, Random...
703
"""simple docstring""" import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("""9.1.0"""): A__ : str= { """linear""": PIL.Image.Resampling.BILINEAR, """...
20
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) lowerCamelCase__ = { '''configuration_perceiver''': ['''PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Per...
122
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow lowerCamelCase__ = logging.getLogger() @unittest.skip('''Temporarily disable the doc tests.''' )...
122
1
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(""">=""", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint.def...
708
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # noqa: F401 deprecate( ...
108
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ : Tuple = {'configuration_mmbt': ['MMBTConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Opti...
98
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Ac...
15
0
'''simple docstring''' def A_( A : int = 10): if not isinstance(A , A) or n < 0: raise ValueError('Invalid input') UpperCamelCase = 10**n UpperCamelCase = 2_8433 * (pow(2 , 783_0457 , A)) + 1 return str(number % modulus) if __nam...
432
'''simple docstring''' import argparse import copy def A_( A : Optional[int]): UpperCamelCase = {} with open(A) as f: for line in f: if line.split()[0] not in dict_of_neighbours: UpperCamelCase = ...
432
1
"""simple docstring""" class lowerCAmelCase : '''simple docstring''' def __init__( self :str ) -> Optional[int]: """simple docstring""" UpperCamelCase__ = {} def lowerCamelCase__ ( sel...
516
"""simple docstring""" import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": A : int = argparse.ArgumentParser( description=( 'Extraction some layers of the full RobertaForMaskedLM or GPT2LMHead...
516
1
'''simple docstring''' def __A ( UpperCAmelCase ,UpperCAmelCase ) -> list[int]: '''simple docstring''' _UpperCamelCase : str = int(UpperCAmelCase ) # Initialize Result _UpperCamelCase : Optional[int] = [] ...
204
'''simple docstring''' import requests from bsa import BeautifulSoup def __A ( UpperCAmelCase ,UpperCAmelCase ) -> str: '''simple docstring''' _UpperCamelCase : Dict = BeautifulSoup(requests.get(UpperCAmelCase ,params=UpperCAmelCase ...
204
1
"""simple docstring""" import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class __a ( _...
554
"""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, apply_forward_hook from .modeling_utils import ModelMixin from .vae im...
554
1
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
def _UpperCAmelCase ( UpperCAmelCase : str ): """simple docstring""" __lowerCamelCase : List[Any] = hex_num.strip() if not hex_num: raise ValueError("""No value was passed to the function""" ) __lowerCamelCas...
458
1
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu _lowerCamelCase = get_tests_...
114
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { '''xlm-mlm-en-2048''': '''https://huggingfa...
154
0
import argparse import logging import pickle from collections import Counter logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO ) __A : Optional[Any] = logging.getLogger(__name__) if __name__ == "__main__": __A : int...
334
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __A : str = { "configuration_gpt_neo": ["GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoConfig", "GPTNeoOnnxConfig"], } try: if not is_torch_available(): rais...
334
1
"""simple docstring""" from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils import...
93
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": _lowerCAmelCase: int = argparse.ArgumentParser() parser.add_argument( '--checkpoint_path', default=None, type=str, required=True, help='Path...
20
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_...
701
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() exce...
678
0
"""simple docstring""" from __future__ import annotations from typing import Any class UpperCamelCase__ : """simple docstring""" def __init__( self , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = 0 ) -> N...
104
"""simple docstring""" def _lowerCamelCase ( UpperCAmelCase_ : int ) -> int: """simple docstring""" if not isinstance(UpperCAmelCase_, UpperCAmelCase_ ): raise ValueError("Input must be an integer" ) if input_num <= 0: raise Value...
104
1
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class UpperCAmelCase__ ( tf.keras.optimizers.schedules.LearningRateSchedule...
704
import inspect import unittest class UpperCAmelCase__ ( unittest.TestCase ): """simple docstring""" def _UpperCAmelCase ( self: Union[str, Any] ) -> Dict: '''simple docstring''' try: import diffusers # noqa: F401 except ImportError: assert False ...
286
0
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class __SCREAMING_SNAKE_CASE ( __a , unitte...
619
'''simple docstring''' import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def A_ ( SCREAMING...
451
0
import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class UpperCAmelCase ( tf.keras.layers.Layer ): d...
346
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_uti...
346
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 applica...
439
import re from filelock import FileLock try: import nltk a_ : Optional[Any] = True except (ImportError, ModuleNotFoundError): a_ : Union[str, Any] = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True) def ...
439
1
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": __lowerCAmelCase : int = pd.read_csv('sample_data.csv', header=None) __lowerCAme...
705
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_for...
76
0
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class lowercase_ : """simple docstring""" def __init__( self : Tuple, UpperCamelCase__ : list[tuple[float, float]] ) -> Any: _A = list_of_poi...
107
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __magic_name__ : Tuple = logging.get_logger(__name__) __magic_name__ : Optional[Any] = ...
497
0
import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_utils import OnnxRuntimeMod...
713
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def SCREAMING_SNAKE_CASE ( snake_case_ : dict )...
25
0
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def lowerCAmelCase ( UpperCamelCase__ : Optional[Any] , UpperCamelCase__ : Optional[Any] , UpperCamelCase__ : ...
202
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowerCAmelCase : List[str] = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: i...
202
1
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set_verb...
701
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("Googling.....") lowerCAmelCase__ = "https://www.google.com/search?q=" + " ".join(sys.argv[1:]) lowerCAmelCase__ = requests.get(url, header...
594
0
'''simple docstring''' import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import...
396
'''simple docstring''' import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.mo...
396
1
"""simple docstring""" import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedC...
707
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def __magic_name__ ( _lowerCamelCase : int , _lowerCamelCase : Optional[Any]=False ): __a : Dict = Omeg...
63
0
import torch from ..models.speechta import SpeechTaForTextToSpeech, SpeechTaHifiGan, SpeechTaProcessor from ..utils import is_datasets_available from .base import PipelineTool if is_datasets_available(): from datasets import load_dataset class A_ ( lowerCAmelCase__ ): '''simp...
303
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : str = logging.get_logger(__name__) lowercase__ : List[Any] = { '''bigcode/gpt_bigcode-santacoder''': '''https://huggingface.co/bigcode/gpt_big...
123
0
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": _snake_case = argparse.ArgumentParser() parser.add_argument( '''--checkpoint_path''', default=None, type=str, required=True, help='''Pa...
231
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers...
231
1
"""simple docstring""" from ... import PretrainedConfig lowerCAmelCase: str ={ "sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json", } class lowerCamelCase__ ( __UpperCamelCase ): __UpperCAmelCase = NEZHA_PRETRAIN...
607
"""simple docstring""" import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def __snake_case ( __A ) -> Any: def wrapper(*__A ,**__A ): lowercase : Tuple ...
607
1
"""simple docstring""" import cmath import math def lowercase_ ( _lowercase : float , _lowercase : float , _lowercase : float , _lowercase : float ): '''simple docstring''' UpperCAmelCase : Opt...
719
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class snake_case__ ( lowerCAmelCase_ ): ...
292
0
"""simple docstring""" 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 lowercase_ = logging.get_logger(__n...
470
"""simple docstring""" def A_ ( lowercase ) -> None: """simple docstring""" UpperCAmelCase_ : Union[str, Any] = generate_pascal_triangle(lowercase ) for row_idx in range(lowercase ): # Print left spaces for _ in range(num_r...
470
1
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/license...
710
def _lowercase ( SCREAMING_SNAKE_CASE_ : str ): """simple docstring""" return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(SCREAMING_SNAKE_CASE_ ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__("doctest").t...
181
0
import heapq def lowerCAmelCase_ (lowerCAmelCase__: Union[str, Any] ): """simple docstring""" UpperCAmelCase_: str = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be fill...
556
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
518
0
'''simple docstring''' import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( _UpperCAmelCase : Optional[Any] ,_UpperCAmelCase : Tuple ,_UpperCAmelCase : List[str] ) -> Union[str...
718
'''simple docstring''' def A ( _UpperCAmelCase : int = 1_0 ,_UpperCAmelCase : int = 1_0_0_0 ,_UpperCAmelCase : bool = True ) -> int: '''simple docstring''' assert ( isinstance(_UpperCAmelCase ,_UpperCAmelCase ) and isinstance(_Upp...
123
0
# Algorithm for the pigeonhole sorting def UpperCamelCase_( _A :List[Any] )-> int: UpperCamelCase__ = min(_A ) # min() finds the minimum value UpperCamelCase__ = max(_A ) # max() finds the maximum value UpperCamelCase__ = max_val - min_val + 1 # size is ...
551
import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, require_torch_multi_gpu, ) loggin...
551
1
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py __A : O...
595
"""simple docstring""" import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from t...
595
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """facebook/data2vec-text...
5
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, re...
595
0
'''simple docstring''' import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, ...
680
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a : Any = 6_378_137.0 a : List[Any] = 6_356_752.314_245 a : Dict = 6_378_137 def __UpperCAmelCase ( _UpperCAmelCase : float...
680
1
import requests def a ( snake_case__: str , snake_case__: str ): '''simple docstring''' lowercase_ = {'''Content-Type''': '''application/json'''} lowercase_ = requests.post(snake_case__ , json={'''text''': message_body} , headers=snake_case__ ) if ...
97
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_bar...
97
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Any = logging.get_logger(__name__) _lowerCamelCase : Any = { '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/s...
157
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class lowerCamelCase (__lowerCamelCase ): """simple docstring""" UpperCAmelCase_ = ["image_processor", "tokenizer"] UpperCA...
157
1
"""simple docstring""" import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationSt...
93
def UpperCamelCase ( snake_case__ : float ,snake_case__ : int ): '''simple docstring''' if digit_amount > 0: return round(number - int(snake_case__ ) ,snake_case__ ) return number - int(snake_case__ ) if __name__ == "__main__": ...
455
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCamelCase :int = logging.get_logger(__name__) __lowerCamelCase ...
42
"""simple docstring""" import os def snake_case ( ) -> Optional[Any]: with open(os.path.dirname(UpperCamelCase__ ) + """/grid.txt""" ) as f: lowerCamelCase : int = [] # noqa: E741 for _ in range(20 ): l.append([int(UpperCame...
42
1
"""simple docstring""" def lowerCAmelCase_( ) -> list[list[int]]: return [list(range(10_00 - i , -10_00 - i , -1 ) ) for i in range(10_00 )] __SCREAMING_SNAKE_CASE : Union[str, Any] = generate_large_matrix() __SCREAMING_SNAKE_CASE : Union[str, Any] = ...
661
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastap...
661
1
"""simple docstring""" import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.mo...
442
"""simple docstring""" import os import numpy import onnx def lowerCAmelCase_ ( UpperCamelCase__ : Optional[int] , UpperCamelCase__ : List[str] ): """simple docstring""" __lowercase = a.name __lowercase = b.name __lowercase = """...
442
1
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow _lowercase = False class lowerCamelCase__ ( unittest.TestCase ): def ...
306
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.uti...
306
1
"""simple docstring""" from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time SCREAMING_SNAKE_CASE_ = Lock() def lowercase__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , ...
713
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) class _UpperCAmelCase ( SCREAMING_SNAKE_CASE_ ): __SCREAMING_SNAKE_CASE : Union[str, Any] ...
183
0
"""simple docstring""" import torch from diffusers import DiffusionPipeline class _a ( _lowercase ): def __init__( self : Optional[int] , SCREAMING_SNAKE_CASE__ : Optional[Any] , SCREAMING_SNAKE_CASE__ : Dict ): super().__ini...
510
import math class lowerCamelCase_ : def __init__( self : Union[str, Any] , __A : List[str]=0 ): # a graph with Node 0,1,...,N-1 __A : List[str] = n __A : List[str] = [ [math.inf for j in range(0 , __A )] for i in ran...
17
0
__UpperCamelCase : Dict = [0, 2, 4, 6, 8] __UpperCamelCase : Optional[Any] = [1, 3, 5, 7, 9] def _UpperCAmelCase ( UpperCAmelCase : int , UpperCAmelCase : int , UpperCAmelCase : list[int] , UpperCAmelCase : int ...
705
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _UpperCamelCase ( A ): '''simple docstring''' a_ : List[Any] = ["image_processor", "tokenizer"] a_ : Tuple = "AutoIm...
458
0
'''simple docstring''' def lowercase_ ( __A : int ) -> int: """simple docstring""" assert ( isinstance(__A , __A ) and number_of_steps > 0 ), F'number_of_steps needs to be positive integer, your input {number_of_steps}' if number_of_steps == 1: r...
94
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HASH from huggingfac...
20
0
def _lowercase ( lowercase__ , lowercase__ ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) __lowerCAmelCase : Tuple = str(bin(lowercase__ ) )[2:] # remove the leading "0b" __lowerCAmelCase : List[Any] = ...
583
from __future__ import annotations def _lowercase ( lowercase__ ): if len(lowercase__ ) == 0: return array __lowerCAmelCase, __lowerCAmelCase : List[str] = min(lowercase__ ), max(lowercase__ ) # Compute the variables __lowerCAmelCase : ...
583
1
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel UpperCamelCase__ = { 'gwf-440k': { ...
322
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE from data...
322
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ =logging.get_logger(__name__) lowerCAmelCase__ ={ "google/realm-cc-news-pretrained-embedder": ( "https://huggingface.co/google/realm-cc-news-pretrained-em...
720
"""simple docstring""" from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _a ( UpperCAmelCase__ = "isbn/0140328726" ) -> dict: __SCREAMING_SNAKE_CASE = olid.strip().strip('''/''' ) # Remove leading/trailing w...
690
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Union[str, Any] = logging.get_logger(__name__) __UpperCamelCase : List[str] = { 'RWKV/rwkv-4-169m-pile': 'https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json', ...
248
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( _lowercase , _lowercase , _lowercase ): SCREAMING_SNAKE_CASE : List[Any] = OmegaConf.load(_lowercase ) SCREAMING_SNAKE_...
248
1
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 A_ ( _lowerCAmelCase : int ): """si...
721
'''simple docstring''' import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_t...
11
0
'''simple docstring''' 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_devi...
539
"""simple docstring""" import os # Precomputes a list of the 100 first triangular numbers _lowercase = [int(0.5 * n * (n + 1)) for n in range(1, 1_01)] def _snake_case ( ): A = os.path.dirname(os.path.realpath(snake_case__ ) ) A = os.path.join(snake_case__ , 'words.txt' ) ...
91
0
from ....configuration_utils import PretrainedConfig from ....utils import logging __UpperCAmelCase : Any = logging.get_logger(__name__) __UpperCAmelCase : Optional[int] = { "CarlCochet/trajectory-transformer-halfcheetah-medium-v2": ( "https://huggingface.co/CarlCo...
705
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKING...
155
0
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class __A ...
21
'''simple docstring''' import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor lowerCAmelCase_ : Optional[int] = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docstring""" ...
692
0
'''simple docstring''' import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class SCREAMING_SNAKE_CASE__ : """simple docstring""" ...
714
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Union[str, Any] = logging.get_logger(__name__) lowerCAmelCase__ : int = { "google/pix2struct-textcaps-base": ( ...
329
0
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # #...
7
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list , snake_case_ :int ): # Checks if the entire collection has been sorted if len(snake_case_ ) <= 1 or n <= 1: return insert_next(snake_case_ , n - 1 ) rec...
49
0
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGEN...
413
def lowerCamelCase_ ( A : int = 1_00 ): """simple docstring""" lowerCAmelCase_ = (n * (n + 1) // 2) ** 2 lowerCAmelCase_ = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(f'''{solution() = }''')
413
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A = { 'configuration_roformer': ['ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoFormerConf...
484
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) # TODO Update this __A = { 'facebook/esm-1b': 'https://huggingface.co/facebook/esm-1b/resolve/main/conf...
484
1
"""simple docstring""" import fcntl import os import socket import torch import torch.distributed as dist def __magic_name__ ( *__snake_case : int ) -> int: with open(__snake_case , "r" ) as fh: fcntl.flock(__snake_case , fcntl.LOCK...
708
"""simple docstring""" import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer,...
518
0
'''simple docstring''' from PIL import Image def __lowerCamelCase ( A__ , A__ ) -> int: """simple docstring""" UpperCamelCase = (259 * (level + 255)) / (255 * (259 - level)) def contrast(A__ ) -> int: ret...
430
def _lowercase( __a : list[int] ): a__ =len(__a ) for i in range(__a ): for j in range(i + 1 , __a ): if numbers[j] < numbers[i]: a__ , a__ =numbers[j], numbers[i] return numbers ...
20
0
'''simple docstring''' import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def _lowerCamelCase ( __A : Optional[Any] ...
704
def _lowerCamelCase ( __A : int ) -> bool: if not isinstance(__A , __A ): _UpperCAmelCase : Tuple = f'''Input value of [number={number}] must be an integer''' raise TypeError(__A ) if number < 0: return False _UpperCAme...
186
0
def __lowerCAmelCase ( UpperCAmelCase__ : Any ) -> Union[str, Any]: lowerCamelCase_ = 1 lowerCamelCase_ = 2 while i * i <= n: lowerCamelCase_ = 0 while n % i == 0: n //= i ...
272
import numpy as np def UpperCAmelCase_ ( snake_case__ , snake_case__ , snake_case__ = 1E-12 , snake_case__ = 100 , ) -> tuple[float, np.ndarray]: """simple docstring""" assert np.shape(snake_case__ )[0] == np.shape(snake_case__ )[1] # Ensure proper...
193
0
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class lowercase_ : """simple docstring""" SCREAMING_SNAKE_CASE : Optional[int] ...
706
'''simple docstring''' from argparse import ArgumentParser from . import BaseTransformersCLICommand def _A ( A__ ): """simple docstring""" return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) class lowercase_ (lowerCa...
624
0
"""simple docstring""" def _snake_case ( ): for n in range(1 , 100_0000 ): yield n * (n + 1) // 2 def _snake_case ( snake_case__ : List[Any] ): A = 1 A = 2 while i * i <= n: A = 0 while n % i == 0: n //= i multiplicity += 1 divisors_count *= multiplicity ...
91
def UpperCamelCase__ ( lowerCAmelCase__ ): if not isinstance(lowerCAmelCase__ ,lowerCAmelCase__ ): lowercase = f"""Input value of [number={number}] must be an integer""" raise TypeError(lowerCAmelCase__ ) if number < 1: lowercase = f"""Input va...
428
0
"""simple docstring""" import datasets from .evaluate import evaluate A = '\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNLP},\n year...
109
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTest...
109
1
'''simple docstring''' def a__ ( UpperCamelCase_ : int ): assert column_title.isupper() UpperCAmelCase__ :Union[str, Any] = 0 UpperCAmelCase__ :Optional[Any] = len(__UpperCamelCase ) - 1 UpperCAmelCase__ :Any = 0 while index >= 0: ...
467
'''simple docstring''' import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A_ = logging.get_logger(__name__) A_ = {"vocab_file": "vocab.json", "merges...
42
0
# Function to print upper half of diamond (pyramid) def _UpperCAmelCase ( UpperCAmelCase : Optional[int] ): """simple docstring""" for i in range(0 , UpperCAmelCase ): for _ in range(0 , n - i - 1 ): # printing spaces ...
458
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Any = { 'configuration_timesformer': ['TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimesformerConfig'], } try: if not is_torch_available...
458
1
'''simple docstring''' def __SCREAMING_SNAKE_CASE ( _UpperCamelCase = 50 ): """simple docstring""" lowercase_ : int = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_...
620
'''simple docstring''' import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( 'The `inpainting.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionInpaintPipeline` instead.' )
620
1
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_common import Ima...
443
from argparse import ArgumentParser from .env import EnvironmentCommand def SCREAMING_SNAKE_CASE_ ( ) -> str: """simple docstring""" a_ : str = ArgumentParser('Diffusers CLI tool' , usage='diffusers-cli <command> [<args>]' ) a_ ...
443
1
import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass # Copied from diffusers.schedul...
537
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py _SCREAMING_SNAKE_CASE = """\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, title = {BLEU: a Method for Automatic...
537
1
'''simple docstring''' import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def UpperCAmelCase_ ( *_A , _A = None , _A=True , _A=2 ): '''simple docstring''' from .. import __version__ SCREAMING_SNAKE_CASE__ ...
707
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling_roberta_series import ( ...
472
0
"""simple docstring""" import qiskit def _UpperCamelCase ( UpperCamelCase , UpperCamelCase ) -> Tuple: """simple docstring""" __UpperCAmelCase : Union[str, Any] = qiskit.Aer.get_backend("aer_simulator" ) # Create a Quantum Circuit ...
77
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin ...
578
0
"""simple docstring""" def _lowerCamelCase ( __a ): if not grid or not grid[0]: raise TypeError('''The grid does not contain the appropriate information''' ) for cell_n in range(1, len(grid[0] ) ): grid[0][cell_n] += grid[0][cell_n - 1] SCREAMING_SNAKE_CASE_ = gri...
716
"""simple docstring""" from __future__ import annotations import typing from collections import Counter def _lowerCamelCase ( __a ): SCREAMING_SNAKE_CASE_ = Counter() for base in range(1, max_perimeter + 1 ): for perpendicular in range(__a, max_perimeter + 1 ): S...
628
0
'''simple docstring''' from __future__ import annotations from collections import deque class SCREAMING_SNAKE_CASE__ : def __init__( self , A_ )-> List[str]: '''simple docstring''' UpperCamelCase = [] ...
3
'''simple docstring''' from __future__ import annotations def A_ ( __SCREAMING_SNAKE_CASE : list , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int ) -> list: __SCREAMING_SNAKE_CASE : Optio...
158
0
'''simple docstring''' import unittest from transformers import DonutProcessor __lowerCAmelCase : str = "naver-clova-ix/donut-base" class A ( unittest.TestCase ): def snake_case__ ( self : Tuple ) -> List[Any]: ...
654
'''simple docstring''' import requests from bsa import BeautifulSoup def lowerCAmelCase ( UpperCamelCase__ : str = "AAPL" ): """simple docstring""" __UpperCAmelCase = f"""https://in.finance.yahoo.com/quote/{symbol}?s={symbol}""" __UpperCAmelCase = Beautif...
654
1
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case = logging.get_logger(__name__) snake_case = { """google/realm-cc-news-pretrained-embedder""": ( """https://huggingface.co/google/realm-cc-news-pretrained-embedder/reso...
67
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case = { """configuration_nllb_moe""": [ """NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NllbMoeConfig""", ] } try: if not ...
67
1
"""simple docstring""" import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torc...
538
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _A = {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']} try: if not is_torch_available(): ...
538
1
from math import factorial def _UpperCAmelCase ( UpperCAmelCase : int , UpperCAmelCase : int , UpperCAmelCase : float ): """simple docstring""" if successes > trials: raise ValueError("""successes must be lower or equal t...
519
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def _UpperCAmelCase ( ): """simple docstring""" __lowerCamelCase : Any = { """repo_name""": ["""test_rep...
519
1
from math import isqrt def snake_case_ ( __lowercase ): return all(number % divisor != 0 for divisor in range(2 , isqrt(_lowerCamelCase ) + 1 ) ) def snake_case_ ( __lowercase = 1_0**6 ): UpperCAmelCase_ : Dict = 0 UpperCAme...
716
import argparse import hashlib # hashlib is only used inside the Test class import struct class lowerCAmelCase__: '''simple docstring''' def __init__( self : List[str] , __snake_case : Union[str, Any] ): '''simple docstring''' ...
641
0
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record __lowercase = """\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems}, author={Wang, Alex and Pru...
203
import random class _lowercase : @staticmethod def UpperCamelCase ( lowerCamelCase__ : str ) -> tuple[list[int], list[int]]: """simple docstring""" A_ = [ord(lowerCamelCase__ ) for i in text] A_ = [] A_ ...
203
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __a : Optional[int] = { """configuration_poolformer""": [ """POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PoolFormerConfig""", ...
522
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def UpperCAmelCase ( lowercase ): """simple docstring""" __lowercase = [ '''encoder.version''', '''decoder.version''', '...
522
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __magic_name__ : Optional[Any] = { "configuration_table_transformer": [ "TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TableTransfo...
672
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mode...
205
0
'''simple docstring''' from __future__ import annotations from typing import TypedDict class SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase = 42 __UpperCamelCase = 42 def lowerCAmelCase_ ( __...
703
'''simple docstring''' from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings ...
692
0
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path lowercase_ : Optional[Any] = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) lowercase_ : Optional[Any]...
572
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, ...
590
0
import copy import random from transformers import CLIPTokenizer class lowerCAmelCase_ ( _UpperCAmelCase ): def __init__( self ,*snake_case__ ,**snake_case__ ): super().__init__(*A_ ,**A_ ) SCREAMING_SNAKE_CASE_ : Dict = {} def s...
705
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('dataset_size' , [None, 4_00 * 2**20, 6_00 * 2**20] ) @pytest.mark.parametrize('input_in_memory_max_size' , ['default', 0, 1_00 * 2**20, 9_00 * 2**20] ) def __...
685
0
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_ = { "configuration_autoformer": [ "AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "Autoforme...
517
'''simple docstring''' import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline SCREAMING_SNAKE_CASE_ = version.parse(ver...
517
1
import re def __UpperCAmelCase ( __A ) -> List[Any]: '''simple docstring''' return [char.split() for char in re.split(R"[^ a-z A-Z 0-9 \s]" , str_ )] def __UpperCAmelCase ( __A ) -> List[Any]: '''simple ...
705
import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments A = logging.getLogger(__name__) @dataclass class lowercase__ ( __SCREAMING_SNAKE_CASE ): A__= field( ...
277
0
"""simple docstring""" from pathlib import Path import fire def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->List[Any]: """simple docstring""" lowerCAmelCase__ :Any = Path(_SCREAMING_SNAKE_CASE ) lowerCAmelCase__ :List[str...
93
__lowerCamelCase : Optional[Any] = { """A""": """.-""", """B""": """-...""", """C""": """-.-.""", """D""": """-..""", """E""": """.""", """F""": """..-.""", """G""": """--.""", """H""": """....""", """I""": """..""", """J""": """.---""", """K""": """-.-""", """L""": """.-..""", """M""": ""...
385
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_uti...
374
"""simple docstring""" def lowerCamelCase_ ( ) ->str: """simple docstring""" for n in range(1 , 1_00_00_00 ): yield n * (n + 1) // 2 def lowerCamelCase_ ( UpperCAmelCase_ ) ->Union[str, Any]: """simple docstring...
374
1
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import List import timm import torch import torch.nn as nn from huggingface_hub import hf_hub_download from torch import Tensor from transformers import AutoImageProcessor, ResNet...
393
import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor from diffusers....
393
1
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCA...
367
from math import pow, sqrt def lowerCAmelCase_ ( *lowerCamelCase ): __magic_name__ : Tuple =len(lowerCamelCase ) > 0 and all(value > 0.0 for value in values ) return result def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase ): return ( ro...
367
1
"""simple docstring""" from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar UpperCamelCase__ = TypeVar('KEY') UpperCamelCase__ = TypeVar('VAL') @dataclass(frozen=_UpperCAmelCase , slots=_UpperCAmelCase ) class ...
110
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "google/canine-s": "https://huggingface.co/google/canine-s/resolve/main/config.json", # See all CANINE models at https://huggingface.co/...
586
0
A_ : int = tuple[float, float, float] A_ : Optional[int] = tuple[float, float, float] def UpperCamelCase (lowercase_: Dict , lowercase_: Optional[int] ) -> Vectorad: A__ : List[Any] = end_pointa[0] - end_pointa[0] A__ : Optional[int] ...
719
import itertools import random import unittest import numpy as np from transformers import ASTFeatureExtractor from transformers.testing_utils import require_torch, require_torchaudio from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeatu...
64
0
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def _snake_case (__lowercase , __lowercase , __lowercase): # Initialise PyTorch model Upp...
23
"""simple docstring""" from typing import Any class a : def __init__( self , UpperCamelCase_ ): UpperCAmelCase__ : Optional[Any] = data UpperCAmelCase__ : List[str] = None def __repr__( self ): retur...
110
0
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models.big_bird.mod...
706
import re def a_ (_lowerCAmelCase : str )-> list: return [char.split() for char in re.split(R"""[^ a-z A-Z 0-9 \s]""" , str_ )] def a_ (_lowerCAmelCase : str )-> str: snake_case: Tuple = split_input(str_ ) return "".join( ...
164
0