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 typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSchedul...
551
import argparse from collections import defaultdict import yaml _lowercase: List[Any] = '''docs/source/en/_toctree.yml''' def _lowerCamelCase ( snake_case ): _lowerCAmelCase = defaultdict(snake_case ) _lowerCAmelCase = [] _lowerCAmelCase = ...
192
0
def SCREAMING_SNAKE_CASE ( snake_case__ = 10 , snake_case__ = 22 ) -> int: __UpperCAmelCase =range(1 , snake_case__ ) __UpperCAmelCase =range(1 , snake_case__ ) return sum( 1 for power in powers for base in bases if len(str(base**power ...
142
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version UpperCamelCase_ = { '<': operator.lt, '<=': operator.le, '==': operator.eq, '!=': operator.ne, '>=': operator.ge, '>': operator.gt, } def SCREAMING_SNAKE_C...
142
1
"""simple docstring""" a = { 0: '''0''', 1: '''1''', 2: '''2''', 3: '''3''', 4: '''4''', 5: '''5''', 6: '''6''', 7: '''7''', 8: '''8''', 9: '''9''', 10: '''a''', 11: '''b''', 12: '''c''', 13: '''d''', 14: '''e''', 15: '''f''', } ...
7
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .model...
469
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Any = logging.get_logger(__name__) UpperCAmelCase_ : Optional[int] = { "microsoft/swinv2-tiny-patch4-window8-256": ( "https://huggingface.co/microsoft/swinv2-ti...
703
import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets UpperCAmelCase_ : int = datasets.logging.get_logger(__name__) UpperCAmelCase_ : Dict = '\\n@InProceedi...
443
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer _SCREAMING_SNAKE_CASE = logging.get_lo...
163
"""simple docstring""" from __future__ import annotations def __UpperCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , ) -> tuple[str, float]: """simple docstring""" if (stress, tangential_force, area).count(0 ) != 1: ...
163
1
def a__ ( lowerCAmelCase__ ) -> bool: UpperCAmelCase__ : str = [int(lowerCAmelCase__ ) for i in ip_va_address.split('''.''' ) if i.isdigit()] return len(lowerCAmelCase__ ) == 4 and all(0 <= int(lowerCAmelCase__ ) <= 2_54 for octet in octets ) if __name__ == "...
709
'''simple docstring''' from __future__ import annotations UpperCamelCase__ = 8.9_88e9 # units = N * m^s * C^-2 def a__ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ) -> dict[str, float]: UpperCAmelCase_...
312
0
'''simple docstring''' import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) ...
369
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { "CarlCochet/trajectory-transformer-halfcheetah-medium-v2": ( "htt...
369
1
import numpy as np class _snake_case : '''simple docstring''' def __init__( self: Tuple ) -> Optional[int]: UpperCAmelCase_ : List[str] = (0, 0) UpperCAmelCase_ : int = None UpperCAmelCase_ : Tuple =...
322
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration UpperCamelCase_ = 50000 UpperCamelCase_ = 5000 UpperCamelCase_ ,UpperCamelCase_ = os.path.split(__file__) UpperCamelCase_ = os.path.join(RESULTS_BAS...
322
1
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCAmelCase__ ) class _UpperCamelCase ( UpperCAmelCase__ ): '''simple docstring''...
474
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmT...
42
0
from torch import nn def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: Optional[Any] ): '''simple docstring''' if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(F'Unsupported ac...
701
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_cuda from...
601
0
'''simple docstring''' SCREAMING_SNAKE_CASE__ = { "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie...
301
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class...
301
1
'''simple docstring''' 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/%...
706
'''simple docstring''' import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap _lowercase : Any ="Usage of script: script_name <size_of_canvas:int>" _lowercase : Optional[Any] =[0] * 100 + [1] * 10 random.shuffle(cho...
574
0
'''simple docstring''' import math import qiskit def A_( A : int = 1 , A : int = 1 , A : int = 1): if ( isinstance(A , A) or isinstance(A , A) or isinstance(A , A) ): raise TypeError(...
3
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __snake_case = {'''configuration_unispeech''': ['''UNISPEECH_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''UniSpeech...
1
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase_ : str = { "configuration_roberta_prelayernorm": [ "ROBERTA_PRELAYERNORM...
720
UpperCAmelCase_ : int = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66, 44, 22, 0, ] ...
367
0
'''simple docstring''' import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class lowercase_ (lowerCamelCa...
41
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _A ( ): """simple docstring""" import os as original_os from os import path as original_path from os import rename as original_rename from os.path import di...
41
1
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path SCREAMING_SNAKE_CASE = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) SCREAMING_SNAKE_CASE = [ord(letter) for letter in s...
703
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () SCREAMING_SNAKE_CASE = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function ...
186
0
"""simple docstring""" from __future__ import annotations def _lowerCAmelCase ( lowerCAmelCase , lowerCAmelCase ): '''simple docstring''' UpperCAmelCase = [] create_all_state(1 , UpperCamelCase_ , UpperCamelCase_ , []...
673
"""simple docstring""" import json import os import torch from diffusers import UNetaDModel os.makedirs("hub/hopper-medium-v2/unet/hor32", exist_ok=True) os.makedirs("hub/hopper-medium-v2/unet/hor128", exist_ok=True) os.makedirs("hub/hopper-medium-v2/value_function", exist_ok=True) def _lowerCAmelCase ...
155
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
219
# Copyright 2022 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 requi...
219
1
from functools import reduce _a = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098711...
481
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 Sequence...
198
0
from math import log from scipy.constants import Boltzmann, physical_constants a__ : Union[str, Any] = 3_0_0 # TEMPERATURE (unit = K) def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , ): '''simple docstring''' if donor_conc <...
700
"""simple docstring""" from math import asin, atan, cos, radians, sin, sqrt, tan a__ : List[str] = 6_37_81_37.0 a__ : Tuple = 6_35_67_52.31_42_45 a__ : str = 6_3_7_8_1_3_7 def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ ,...
553
0
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE: Optional[int] , SCREAMING_SNAKE_CASE: Optional[int] ): """simple docstring""" while a != 0: _lowerCAmelCase = b % a, a return b def __...
580
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.tes...
453
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor,...
200
"""simple docstring""" __a : List[Any] = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) __a : Union[str,...
200
1
'''simple docstring''' import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attenti...
525
'''simple docstring''' def __A ( a_ : list[list[float]] ): lowerCAmelCase : list[list[float]] = [] for data in source_data: for i, el in enumerate(a_ ): if len(a_ ) < i + 1: data_lists.append([] ) data_lists[i].append(float(a_ ...
525
1
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __snake_case = (720, 1280) # Height, Width __snake_case = (0.4, 0.6) # if height or width lower than this scale, drop it. __snake_case ...
701
"""simple docstring""" import heapq def _lowerCamelCase ( lowerCamelCase__ : dict ): lowercase__ : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq ...
128
0
'''simple docstring''' # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKI...
116
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer lowercase : Tuple = {"""vocab_file""": ""...
116
1
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: Dict , SCREAMING_SNAKE_CASE_: List[str] ) -> str: '''simple docstring''' A__ = "" for i in table: res += inp[i - 1] return res def lowerCAmelCase__ ( SCREA...
710
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor lowerCAmelCase__ = logging.get_logger(__name__) class a__ ( snake_case ): """simple docstring""" def __init__( self , *lowercase , **lowercase ) -> ...
626
0
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, EfficientForm...
198
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node lowercase = 4 lowercase = 3 class UpperCamelCase_ ( snake_case_ ): '''sim...
198
1
"""simple docstring""" from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docs...
714
"""simple docstring""" from math import isqrt def a__ ( lowerCAmelCase : int ): '''simple docstring''' UpperCAmelCase__ : Tuple = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j...
660
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, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_for...
12
'''simple docstring''' from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _UpperCamelCase : int = logging.get_logger(__name__) def __UpperCAmelCase ( A : Union[tf.Tensor, np.ndarray] ) -> List[int]: if isinst...
541
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureExtractionM...
316
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class a__ ( A__ , unittest.TestCase ): A = Bi...
316
1
"""simple docstring""" _lowerCAmelCase : int = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _lowerCAmelCase : Optional[int] = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _lowerCAmelCase : Optional[Any] = { 0: "Sunday", 1: "Monday", 2: "Tuesday", 3: "Wednesday", 4: ...
289
"""simple docstring""" import os import sys a_ = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Au...
76
0
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency snake_case__ : List[Any] = { """E""": 1_2.7_0, """T""": 9.0_6, """A""": 8.1_7, """O""": 7.5_1, """I""": 6.9_7, """N""": 6.7_5, """S""": 6.3_3, """H""": 6.0_9, """R""": 5.9_9, "...
655
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.tes...
655
1
import argparse import collections import json from pathlib import Path import requests import torch import yaml from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTImageProcessor, MobileViTVaConfig, MobileViTVaForImageClassification, ...
101
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __A : List[str] = { "configuration_roberta": ...
602
0
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.u...
1
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class __magic_name__ : def __init__( self : Optional[int] ) -> Optional[Any]: UpperCAmelCase = "" UpperCAmelCase = "" UpperCAmelCase = [] UpperCAmel...
1
1
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunDiscreteScheduler from .....
184
# 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 r...
266
0
import math def A ( snake_case__ : list , snake_case__ : int = 0 , snake_case__ : int = 0 ) -> int: '''simple docstring''' __snake_case = end or len(snake_case_ ) for i in range(snake_case_ , snake_case_ ): __sn...
703
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 UpperCAmelCase__ : Any = logging.getLogger() @unittest.skip...
676
0
import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_pytes...
655
_snake_case = """ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/""" def _A ( __magic_name__ ): # Make sure the supplied data is a bytes-like object if not isinstance(__magic_name__ , __magic_name__ ): lowercase__ = f'''a bytes-like object is re...
655
1
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ = logging.get_logger(__name__) snake_case__ = { 'MIT/ast-finetuned-audioset-10-10-0.4593': ( 'https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/config.json' ), } ...
714
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case__ = { 'configuration_whisper': ['WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Whis...
638
0
import math def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE ): lowercase = [True] * n lowercase = False lowercase = False lowercase = True for i in range(3 , int(n**0.5 + 1 ) , 2 ): lowercase = i * 2 while index < n: l...
84
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor from ....
84
1
from __future__ import annotations from collections.abc import Callable def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ = 1_0_0 , ): lowerCamelCase_ = x_start lowerCamelCase_ = fnc(lowerCamelCase__ ...
700
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A =logging.get_logger(__name__) __A ={ '''google/vit-base-patch16-224''': '''https://huggin...
313
0
import numpy as np def _lowerCamelCase ( lowerCamelCase_: np.ndarray ): '''simple docstring''' return 1 / (1 + np.exp(-vector )) def _lowerCamelCase ( lowerCamelCase_: np.ndarray ): '''simple docstring''' ...
256
from statistics import mean import numpy as np def _lowerCamelCase ( lowerCamelCase_: list , lowerCamelCase_: list , lowerCamelCase_: list , lowerCamelCase_: int ): '''simple docstring''' A : Tuple = 0 # Number of proc...
256
1
'''simple docstring''' import re from filelock import FileLock try: import nltk _lowerCAmelCase = True except (ImportError, ModuleNotFoundError): _lowerCAmelCase = False if NLTK_AVAILABLE: with FileLock('''.lock''') as lock: nltk.download('''punkt''', quiet=True) def _SCREAMING_SNAK...
160
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gp...
160
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.set_verbosity_info() UpperCam...
590
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor UpperCamelCase = logging.get_logger(__name__) class _lowerCamelCase ( UpperCamelCase ): """simple docstring""" def __init__( self , *_SCRE...
590
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_perceiver import PerceiverImageProcessor _lowerCamelCase = logging.get_logger(__name__) class __a ( _snake_case ): def __init__( self : Dict , *lowercase__ : Any , **lowercas...
572
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer _lowerCamelCase = logging.get_logger(_...
572
1
import unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepa...
377
class __lowercase : def __init__( self : Optional[int] ) -> int: """simple docstring""" UpperCAmelCase = {} def _lowercase ( self : str ) -> None: ...
377
1
def _a ( __SCREAMING_SNAKE_CASE : list[int] , __SCREAMING_SNAKE_CASE : int ): """simple docstring""" _lowerCAmelCase = len(__SCREAMING_SNAKE_CASE ) _lowerCAmelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr va...
585
import math from numpy import inf from scipy.integrate import quad def _a ( __SCREAMING_SNAKE_CASE : float ): """simple docstring""" if num <= 0: raise ValueError('math domain error' ) return quad(__SCREAMING_SNAKE_CASE , 0 , __SCREAMING_SNAKE_CASE , ...
585
1
import re def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" return [char.split() for char in re.split(R'''[^ a-z A-Z 0-9 \s]''' , str_ )] def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ = split_input(str_ ) return "".jo...
43
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) snake_case__ : Union[str, Any] = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig', ], 'feature_extrac...
408
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 # ...
709
'''simple docstring''' import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from tr...
384
0
"""simple docstring""" import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_a...
19
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ =logging.get_logger(__name__) UpperCamelCase__ ={ 'kakaobrain/align-base': 'https://huggingface.co/k...
249
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Optional[Any] = logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-b-16x2-kine...
708
import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state import GradientState, Pa...
453
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...
502
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if i...
550
0
import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand lowerCamelCase__ = ( """4S 3H 2C 7S 5H""", """9D 8H 2C 6S 7H""", """2D 6D 9D TH 7D""", """TC 8C 2S JH 6C""", """JH 8S TH AH QH""", """TS KS 5S 9S AC""", """KD 6S 9D ...
713
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class SCREAMING_S...
547
0
def __lowerCamelCase ( lowerCamelCase__ : int ): '''simple docstring''' lowerCamelCase = generate_pascal_triangle(lowerCamelCase__ ) for row_idx in range(lowerCamelCase__ ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): ...
457
# Lint as: python3 import itertools import os import re UpperCAmelCase : Any = re.compile(r"([A-Z]+)([A-Z][a-z])") UpperCAmelCase : Optional[Any] = re.compile(r"([a-z\d])([A-Z])") UpperCAmelCase : Optional[Any] = re.compile(r"(?<!_)_(?!_)") UpperCAmelCase : Any = re.compile...
457
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowercase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: ...
150
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE_ ( metaclass=_lowercase): '''simple docstring''' __magic_name__ : List[str] = ['''torch'''] def __init__( self , *lowerCamelCase__ , **...
150
1
import math def __A ( _A , _A = 0 , _A = 0 ): """simple docstring""" __a = end or len(_A ) for i in range(_A , _A ): __a = i __a = array[i] while temp_index != start and temp_index_value < array[temp_index - 1]: __a ...
197
import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisionConfig, ) def __l...
0
0
'''simple docstring''' from typing import List from .keymap import KEYMAP, get_character def __lowerCAmelCase ( lowerCamelCase : str ): '''simple docstring''' def decorator(lowerCamelCase : List[Any] ): __lowerCAmelCase = getattr(lowerCamelCase , ...
719
'''simple docstring''' from argparse import ArgumentParser from . import BaseTransformersCLICommand def __lowerCAmelCase ( lowerCamelCase : List[str] ): '''simple docstring''' return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_co...
39
0
"""simple docstring""" import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common impo...
552
"""simple docstring""" def UpperCAmelCase ( _lowercase : int = 1_0_0_0 ) -> int: """simple docstring""" lowerCAmelCase_ , lowerCAmelCase_ = 1, 1 lowerCAmelCase_ = [] for i in range(1 , n + 1 ): lowerCAmelCase_ = ...
552
1
"""simple docstring""" def lowerCamelCase_( _lowerCamelCase ) -> Tuple: '''simple docstring''' _lowerCamelCase : Tuple = len(_lowerCamelCase ) for i in range(length - 1 ): _lowerCamelCase : str = i for k in range(i + 1 ...
386
"""simple docstring""" def lowerCamelCase_( _lowerCamelCase = 10 , _lowerCamelCase = 22 ) -> int: '''simple docstring''' _lowerCamelCase : Tuple = range(1 , _lowerCamelCase ) _lowerCamelCase : Tuple = range(1 , _lowerCamelCase )...
386
1
import csv import tweepy # Twitter API credentials _SCREAMING_SNAKE_CASE = """""" _SCREAMING_SNAKE_CASE = """""" _SCREAMING_SNAKE_CASE = """""" _SCREAMING_SNAKE_CASE = """""" def lowercase( UpperCamelCase_ ) -> None: '''simple docstring''' # authorize twitter, initi...
537
import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( MaxLengthCriteria, MaxNewT...
537
1
import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding from ...utils import...
707
# 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 files ~60KB. As compared to t...
152
0
"""simple docstring""" from __future__ import annotations def lowercase__ ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ) -> tuple[int, int]: '''simple docstring''' if b == 0: return (1, 0) ((a__) , (a__)) : List[Any] = extended_euclid(lowerCA...
642
"""simple docstring""" import functools def lowercase__ ( lowerCAmelCase__ : str , lowerCAmelCase__ : str ) -> int: '''simple docstring''' a__ : Any = len(lowerCAmelCase__ ) a__ : Optional[int] = len(lowerCAmelCase__ ) @functools.cache d...
642
1
import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch im...
718
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffus...
411
0
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformer...
568
from itertools import permutations def lowerCAmelCase__ ( _a : tuple ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False snake_case_ : List[str] = [7, 11, 13, 17] for i, te...
568
1
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union 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 if is_torch_available(): import...
178
'''simple docstring''' import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_con...
178
1
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin __magic_name__ : Tuple = """ Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a c...
102
'''simple docstring''' import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel a_ ...
296
0
import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase :Union[str, Any] = AutoCo...
452
import qiskit def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase :Dict = qiskit.Aer.get_backend('''aer_simulator''' ) __UpperCamelCase :Tuple = qiskit.QuantumCircuit(4 , 2 ) # encode in...
452
1
'''simple docstring''' import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py A : List[Any] = """src/transformers""...
349
'''simple docstring''' import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization ...
349
1
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __UpperCAmelCase ( snake_case__ ): """simple docstring""" _snake_case : List[Any] = ['image_processor', 'tokenizer'] _snake_...
228
"""simple docstring""" from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, s...
228
1
'''simple docstring''' import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_a...
430
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class UpperCamelCase__ : a__ : torch.Tensor # [batch_size x 3] a__ : torch.Tensor # [batch_size x 3] a__ : torch.Tensor # [batch_size x 3] a__ : torch.Tensor # [batch_size x 3]...
344
0
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_...
484
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ : int = {'configuration_van': ['VAN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VanConfig']} try: if not is_torch_available(): raise Op...
484
1
def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase = 0 ) -> list: """simple docstring""" snake_case_ : Dict = length or len(_UpperCamelCase ) snake_case_ : Any = False for i in range(length - 1 ): if l...
60
'''simple docstring''' import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME,...
508
0
"""simple docstring""" def lowerCAmelCase (__UpperCamelCase : str , __UpperCamelCase : int ): """simple docstring""" __UpperCamelCase =[[] for _ in range(__UpperCamelCase )] __UpperCamelCase =key - 1 if key <= 0: raise Valu...
296
"""simple docstring""" class _lowercase : """simple docstring""" def __init__( self : Tuple , UpperCamelCase__ : Any ) -> int: '''simple docstring''' __UpperCamelCase =arr.split(''',''' ) ...
296
1
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class lowercase_ ( __snake_case ): _lowerCamelCase = [...
670
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor __SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) class lowercase_ ( __snake_case ): def __init__( self , *lowercase_ , **lowercase_ ):...
670
1
from PIL import Image def SCREAMING_SNAKE_CASE( UpperCamelCase ,UpperCamelCase ) -> int: def brightness(UpperCamelCase ) -> float: return 1_2_8 + level + (c - 1_2_8) if not -255.0 <= level <= 255.0: raise ValueError('level must be between -255.0 (black) and 255.0 ...
720
'''simple docstring''' from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ...
471
0
'''simple docstring''' import argparse _lowercase = """docs/source/_static/js/custom.js""" def A (__lowerCamelCase :List[Any] ): with open(__lowerCamelCase , encoding="""utf-8""" , newline="""\n""" ) as f: _lowerCAmelCase = f.readlines() ...
5
'''simple docstring''' import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def ...
390
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResampling...
709
from __future__ import annotations from collections.abc import Callable def a__ ( a , a , a , a = 1_0_0 , ) -> float: A_ : Any = x_start A_ : int = fnc(a ) A_ : int = 0.0 for _ ...
236
0
import os # Precomputes a list of the 100 first triangular numbers _UpperCamelCase : int =[int(0.5 * n * (n + 1)) for n in range(1, 101)] def a__ () -> Tuple: _A : Union[str, Any] = os.path.dirname(os.path.realpath(__A ) ) _A : Optional[int] = os.pat...
206
'''simple docstring''' from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 __lowerCAmelCase = { # 1536-...
466
0
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_...
615
"""simple docstring""" import string from math import logaa def _lowercase ( __snake_case ,__snake_case ) -> int: __lowerCAmelCase : int = document.translate( str.maketrans("" ,"" ,string.punctuation ) ).replace("\n" ,"" ) ...
615
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) class lowerCamelCase_ ( __a ): lowerCAmelCase__ = 'timm_backbone' def __init__( self :...
75
import math def UpperCAmelCase ( UpperCAmelCase )-> int: '''simple docstring''' if not isinstance(UpperCAmelCase ,UpperCAmelCase ): SCREAMING_SNAKE_CASE_ = f'''Input value of [number={number}] must be an integer''' raise TypeError(UpperCA...
393
0
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ = { "configuration_trajectory_transformer": [ "TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "Trajecto...
65
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip insta...
65
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available A__ : List[str] = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], """tokenization_mvp""":...
233
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowercase : Union[str, Any] = {"""configuration_swin""": ["""SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwinConfig""", """SwinOnnxConfig""...
210
0
from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase : List[Any] = logging.get_logger(__name__) lowercase : Optional[Any] = { """huggingface/autoformer-tourism-monthly""": """https://huggingface.co/h...
703
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer import Prio...
584
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow, tor...
201
import json import os import torch from diffusers import UNetaDModel os.makedirs('hub/hopper-medium-v2/unet/hor32', exist_ok=True) os.makedirs('hub/hopper-medium-v2/unet/hor128', exist_ok=True) os.makedirs('hub/hopper-medium-v2/value_function', exist_ok=True) def a ( a ) ->List[Any]: '''simpl...
201
1
# 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.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet import ...
714
def _snake_case ( __snake_case , __snake_case , __snake_case , __snake_case ): # Return True if there is node that has not iterated. _UpperCamelCase = [False] * len(__snake_case ) _UpperCamelCase = [] queue.append(__snake_case ) _UpperCamelCase = ...
71
0
def a_ ( lowerCAmelCase_ : Union[str, Any], lowerCAmelCase_ : List[str] ): __lowerCAmelCase = '' for i in table: res += inp[i - 1] return res def a_ ( lowerCAmelCase_ : Union[str, Any] ): return data[1:] + data[0] def a_ ...
53
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { """configuration_git""": ["""GIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GitConfig""", """GitVisionConfig"""], """processing_git""": ["""GitProc...
451
0
'''simple docstring''' import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_ut...
720
'''simple docstring''' 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 lowercase ...
159
0
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_av...
405
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration lowercase = HfArgumentParser(InitializationArguments) lowercase = parser.parse_args() # Load codeparrot tokenizer trained for Python...
240
0
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCAmelCase_ ( unittest.TestCase ): ...
567
def _a ( __lowercase , __lowercase = 0 ) -> list: """simple docstring""" __UpperCamelCase = length or len(__lowercase ) __UpperCamelCase = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]: ...
567
1
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase=False ): __magic_name__ : Optional[int] =OmegaConf.load(lowerCamelCase ) if display: ...
21
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImag...
388
0
"""simple docstring""" def lowercase ( UpperCamelCase : int ): """simple docstring""" if upper_limit < 0: raise ValueError("Limit for the Catalan sequence must be ≥ 0" ) A__ : int =[0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 A__ : List...
595
"""simple docstring""" import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers.utils...
595
1
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __snake_case ( ) -> Any: """simple docstring""" A = ArgumentParser( descrip...
690
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase_ : Dict = { 'configuration_graphormer': ['GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Graphormer...
442
0
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig from transformers.testing_utils import ( require_torch, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test...
714
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGE...
81
0
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class _A : def __init__( self : int , _A : Collection[float] | None = None ) -> None: """simple docst...
217
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) a_ = logging.getLogger(__...
25
0
"""simple docstring""" import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, Euler...
28
"""simple docstring""" import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class lowercase( __a ): '''simple docstring''' lowercase__ = (IPNDMScheduler,) lowercase__ ...
28
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase = { """configuration_megatron_bert""": ["""MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MegatronBertConfig"""], } try: if not is_t...
5
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "google/fnet-large"...
532
0
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets __SCREAMING_SNAKE_CASE = """\ @inproceedings{popovic-2015-chrf, title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\", author = \"Popovi{\'c}, Maja\", booktitl...
17
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __SCREAMING_SNAKE_CASE = { """configuration_altclip""": [ """ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """AltCLIPConfig""", ...
17
1
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: float , UpperCamelCase__: list[float] ): if discount_rate < 0: raise ValueError("""Discount rate cannot be negative""" ) if not cash_flows: raise ValueError("""Cash flows list cannot be empty""" ) SCREAMING_SNAKE_CA...
6
'''simple docstring''' import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def UpperCAmelCase ( lowerCamelCase_ :List[Any] , lo...
334
0
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
21
"""simple docstring""" from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, ...
21
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType _lowerCamelCase = logging...
6
snake_case_ : List[Any] = "Alexander Joslin" import operator as op from .stack import Stack def __a ( __UpperCAmelCase : str ) -> int: """simple docstring""" lowerCamelCase_ : List[str] = {"*": op.mul, "/": op.truediv, "+": op.add, "-": ...
488
0
'''simple docstring''' import colorsys from PIL import Image # type: ignore def __snake_case ( _UpperCAmelCase : float, _UpperCAmelCase : float, _UpperCAmelCase : int): UpperCamelCase = x UpperCamelCase = y for step in range(_Up...
350
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case_ : Dict = logging.get_logger(__name__) snake_case_ : Union[str, Any] = { 'facebook/encodec_24khz': '...
350
1