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
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import ( DiffusionPipeline, UnCLIP...
62
def lowerCamelCase__ ( lowercase , lowercase ): """simple docstring""" return 1 if input_a == input_a else 0 def lowerCamelCase__ ( ): """simple docstring""" assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ...
62
1
import unittest from transformers import BertGenerationConfig, 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 im...
707
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE = { '''configuration_clipseg''': [ '''CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CLIPSegConfig''',...
56
0
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.testing_utils import D...
367
'''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 # # Un...
365
0
'''simple docstring''' import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session') def __UpperCAmelCase ...
708
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipel...
6
0
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_process...
333
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from .test_pipelines_co...
333
1
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase : str = { "configuration_mctct": ["MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MCTCTConfig"], "feature_extraction_mctct": ["MCT...
91
"""simple docstring""" import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowerCamelCase__ ( unittest.TestCase ): def __a ( self : Dict ): A = [ 'safety_checker/pytorch_model.bin', '...
91
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf ...
633
"""simple docstring""" from __future__ import annotations from statistics import mean def _SCREAMING_SNAKE_CASE ( _lowercase : list[int] , _lowercase : list[int] , _lowercase : int ) ->list[int]: '''simple docstring...
633
1
from collections.abc import Iterable from typing import Any class _SCREAMING_SNAKE_CASE : def __init__( self , lowerCamelCase = None ): snake_case__ = value snake_case__ = None # Added in order to delete a node easier snake_case__ = None ...
530
def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase , __lowerCAmelCase ): return price * (1 + tax_rate) if __name__ == "__main__": print(F'''{price_plus_tax(100, 0.2_5) = }''') print(F'''{price_plus_tax(1_2_5.5_0, 0.0_5) = }''')
530
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices _snake_case = logging.get_logger(__name__) _snake_case = { 'facebook/convnextv2-tiny-1k-224': 'https://huggingface...
383
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def _a ( __lowercase ) -> List[A...
383
1
"""simple docstring""" import numpy # List of input, output pairs A_ : Tuple = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) A_ : List[Any] = (((5_15, 22, 13), 5_55), ((61, 35, 49), 1_50)) A_ : int = ...
696
"""simple docstring""" import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py A_ : Dict = "src/transformers" # This is to make sure the transformers ...
696
1
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils....
165
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class lowercase ( unittest.TestCase ): """simple docstring"...
165
1
'''simple docstring''' from __future__ import annotations def __lowerCamelCase ( __snake_case : Any, __snake_case : str, __snake_case : List[Any] ) -> Optional[int]: """simple docstring""" if days_between_payments <= 0: raise ValueError("""days_between_payments mus...
707
'''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 import Decode...
687
0
__SCREAMING_SNAKE_CASE = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) __SCREAMING_SNAKE_CASE = frozenset(...
220
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : Tuple ,lowerCAmelCase_ : Optional[int] ,lowerCAmelCase_ : Union[str, Any] ,lowerCAmelCase_ : Optional[Any]=1024 ...
220
1
from __future__ import annotations from typing import Any def _lowercase ( UpperCAmelCase_): """simple docstring""" if not postfix_notation: return 0 snake_case__ : List[str] = {"""+""", """-""", """*""", """/"""} snake_case__ : list[Any]...
127
from __future__ import annotations from typing import Any def _lowercase ( UpperCAmelCase_): """simple docstring""" if not postfix_notation: return 0 snake_case__ : List[str] = {"""+""", """-""", """*""", """/"""} snake_case__ : list[Any]...
127
1
'''simple docstring''' def _lowerCAmelCase ( __magic_name__ : int ) -> Tuple: if number < 0: raise ValueError('''number must not be negative''' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod() ...
92
import glob import os import random from string import ascii_lowercase, digits import cva a__ = """""" a__ = """""" a__ = """""" a__ = 1 # (0 is vertical, 1 is horizontal) def _UpperCAmelCase ( ): snake_case__ , snake_case__ = get_dataset(a , a ) print("""P...
654
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_retribert import RetriBertTokenizer UpperCamelCase__ : ...
385
'''simple docstring''' import numpy as np UpperCamelCase__ : Optional[int] = [ ['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'k'], ['l', 'm', 'n', 'o', 'p'], ['q', 'r', 's', 't', 'u'], ['v', 'w', 'x', 'y', 'z'], ] class _lowerCAmelCase : ...
385
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class A__ ( datasets.BeamBasedBuilder ): """simple docstring""" def _UpperCamelCase( self : List[str] ...
37
'''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 SCREA...
582
0
# 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 # # Unless required by app...
714
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 Accelerator, Dist...
55
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING A_ = logging.get_logger(__name__) A_ = { "ut/deta": "https://huggingface.co/ut/deta/resolve/main/config.json", } class l...
270
'''simple docstring''' 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 ac...
270
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/licenses/LICENSE-2.0 # ...
691
'''simple docstring''' import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, f...
691
1
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def lowerCamelCase_ ( lowerCAmelCase__ : List[str] ) -> Tuple: '''simple docstring''' if "img_encoder.pos_embed" in name: ...
106
__snake_case :Any =256 # Modulus to hash a string __snake_case :Optional[int] =1000003 def lowerCamelCase_ ( lowerCAmelCase__ : str , lowerCAmelCase__ : str ) -> bool: '''simple docstring''' A = len(lowerCAmelCase__ ) ...
106
1
"""simple docstring""" import os import pytest from attr import dataclass UpperCAmelCase : Optional[int] = 'us-east-1' # defaults region @dataclass class lowerCamelCase__ : """simple docstring""" __a = 42 __a = """arn:aws:iam::558105141721:rol...
299
"""simple docstring""" # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class lowerCamelCase__ ( A ): """simple docstring""" def __init__( self : Any , UpperCam...
299
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer __snake_case :int ={'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'} __snake_case ...
106
import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from transformers.utils import WEIG...
412
0
def snake_case_ ( ) -> int: return [ a * b * (10_00 - a - b) for a in range(1 , 9_99 ) for b in range(snake_case , 9_99 ) if (a * a + b * b == (10_00 - a - b) ** 2) ][0] if __name__ == "__main__": pri...
718
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING __lowerCAmelCase = logging.get_logger(__name__) class __a ( __UpperCamelCase ): __lowercase : Union[str, Any] ...
335
0
'''simple docstring''' from math import pi def UpperCamelCase__ ( __magic_name__ : int , __magic_name__ : int ) -> float: '''simple docstring''' return 2 * pi * radius * (angle / 3_60) if __name__ == "__main__": print(arc_length(90, 10))
38
'''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...
38
1
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch ...
641
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def snake_case_ ( ): UpperCAmelCase_ : str = HfArgumentParser(__lowercase ) UpperCAmelCase_ : Optional[Any] = parser.parse_args_into_dataclasses()[0] UpperC...
641
1
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta import RobertaTokenizer low...
511
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase : Optional[int] = logging.get_logger(__name__) lowerCAmelCase : List[Any] = { 'xlm-mlm-en-2048': 'https://hu...
511
1
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, ...
717
from __future__ import annotations def a__ ( snake_case ): """simple docstring""" __SCREAMING_SNAKE_CASE : List[str] = str(snake_case ) return n == n[::-1] def a__ ( snake_case = 1_000_000 ): """simple docstring""" __SCREAMING_SNAKE_CASE ...
131
0
"""simple docstring""" def lowerCAmelCase_( lowercase_ : str , lowercase_ : str ) -> Optional[Any]: _lowerCamelCase = len(A_ ) _lowerCamelCase = len(A_ ) _lowerCamelCase = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] _lowerC...
661
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICEN...
316
0
'''simple docstring''' from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function UpperCamelCase__ = 1.054571817e-34 # unit of ℏ : J * s UpperCamelCase__ = 3e8 # unit of c : m * s^-1 def __SCREAMING_SNAKE_...
718
'''simple docstring''' import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging UpperCamelCase__...
640
0
"""simple docstring""" import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class snake_case__ ( unittest.TestCase ): def a__ ( self ): __a = [ "safety_checker/pytorch_model.bin", "safety_checker/mod...
528
"""simple docstring""" from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration SCREAMING_SNAKE_CASE__:str = HfArgumentParser(InitializationArguments) SCREAMING_SNAKE_CASE__:List[str] = parser.parse...
528
1
'''simple docstring''' def _UpperCAmelCase ( a : int ) -> bool: """simple docstring""" return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print("Program to check whether a number is a Perfect num...
720
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __magic_name__ ( unittest.TestCase ): """simple docstring""" def lowerCamelCase__ ( self ) -> Optional[Any]: lowercase_ : ...
7
0
import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, transpose, ) if is_flax_available()...
521
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__ ={ 'junnyu/roformer_chinese_small': 'https://huggingface.co/junnyu...
521
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase = ...
318
'''simple docstring''' from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput ...
318
1
from collections import defaultdict def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ): UpperCAmelCase__: Any = first_str.lower().strip() UpperCAmelCase__: Tuple = second_str.lower().strip() # Remove whitespace UpperCAmelCase__: List[Any] = first_str.replace(" " ,"" ...
113
import fire from utils import calculate_rouge, save_json def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE=None ,**SCREAMING_SNAKE_CASE ): UpperCAmelCase__: Tuple = [x.strip() for x in open(SCREAMING_SNAKE_CASE ).readlines()] UpperCAmelCase__: Dict = [x....
113
1
'''simple docstring''' # Copyright (c) 2021-, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
257
'''simple docstring''' import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_info() __a = ...
257
1
'''simple docstring''' from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, ...
316
'''simple docstring''' import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class A ( _a ): lowercase_ = (DDPMParallelScheduler,) def __lowerCAmelCase ( self : ...
22
0
from __future__ import annotations from math import pi def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ ) -> dict[str, float]: """simple docstring""" if (inductance, frequency, reactance).count(0 ) != 1: raise ValueError('''One an...
177
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters _lowerCamelCase : List[str] = (720, 1280) # Height, Width _lowerCamelCase : Optional[Any] = (0.4, 0.6) # if height or width lower than this scale, drop it. _lower...
177
1
'''simple docstring''' from __future__ import annotations import string from itertools import cycle, product from pathlib import Path a__ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) a__ : list[int] = [ord(letter) f...
51
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _snake_case = { "configuration_efficientformer": [ "EFFICIENTFORMER...
510
0
import warnings from ..trainer import Trainer from ..utils import logging a_ = logging.get_logger(__name__) class __lowerCAmelCase ( lowerCAmelCase__ ): def __init__( self , __UpperCAmelCase=None , **__UpperCAmelCase ): '''simple docstring''' warnings.warn( '...
622
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device a_ = False class __lowerCAmelCase ( unittest.TestCase ): pass @nightly @re...
622
1
from __future__ import annotations __a = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] __a = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def lowerCamelCase__ ( _lowercase ): '''simple docstring''' UpperCAmelCase_ : List[Any...
30
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_transforme...
548
0
"""simple docstring""" import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def UpperCAmelCase__ ( lowerCAmelCase__...
197
"""simple docstring""" import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_...
197
1
'''simple docstring''' import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested...
474
'''simple docstring''' import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class _UpperCamelCase ( A , unittest.TestCase ): '''simple docstring''' lowerCAm...
474
1
"""simple docstring""" def _UpperCAmelCase ( __lowerCamelCase : int = 10_00 ) -> int: _snake_case = -1 _snake_case = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c _snake_case = (n * n - 2 ...
430
"""simple docstring""" def _UpperCAmelCase ( __lowerCamelCase : float , __lowerCamelCase : float ) -> float: return price * (1 + tax_rate) if __name__ == "__main__": print(F"{price_plus_tax(100, 0.25) = }") print(F"{price_plus_tax(1_25.50, 0.05) = }")
430
1
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable _A : str = {"""configuration_gpt_neox""": ["""GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTNeoXConfig"""]} try: if not is_to...
100
import torch from torch import nn class __snake_case ( nn.Module ): '''simple docstring''' def __init__( self , A_ , A_ , A_ , A_ , A_=1 , A_=False ): '''simple docstring''' super().__init__() SCREAMING_SNAKE_CASE_...
100
1
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' ...
705
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_commo...
53
0
from __future__ import annotations import math def snake_case (UpperCamelCase : int ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of...
165
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowercase : List[str] = { 'configuration_gpt_bigcode': ['GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTBigCodeConfig'], } try: if not is_torch_av...
557
0
'''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.m...
514
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_avai...
514
1
"""simple docstring""" import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets __SCREAMING_SNAKE_CASE : Optional[int] = ''' @inproceedings{xu-etal-2016-optimizing, title = {Optimizing Statistical Machine Translatio...
661
"""simple docstring""" import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_prop...
661
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a= logging.get_logger(__name__) a= { '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json''' ), # See all Vivit models a...
702
'''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 TokenizerTesterMixin ...
287
0
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict __a: Optional[Any] = namedtuple( '''_TestCommandArgs''', [ ...
108
from __future__ import annotations from random import random class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self , __UpperCamelCase = None ) -> Any: '''simple docstring''' __UpperCamelCase : Tuple = val...
327
0
'''simple docstring''' import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL,...
343
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging lowercase : str = logging.get_logger(__name__) # TODO: upload to AWS lowercase : Optional[Any] = { 'yjernite/retribert-base-uncased': ( 'https://...
343
1
__a = 'Tobias Carryer' from time import time class lowercase__: """simple docstring""" def __init__( self : str , SCREAMING_SNAKE_CASE_ : List[str] , SCREAMING_SNAKE_CASE_ : Tuple , SCREAMING_SNAKE_CASE_ : Union[str, Any] , SCREAMI...
97
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_r...
99
0
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRCo...
485
"""simple docstring""" import tensorflow as tf from ...tf_utils import shape_list class _UpperCAmelCase ( tf.keras.layers.Layer): def __init__( self : int , lowercase_ : Tuple , lowercase_ : Union[str, Any] , lowercase_ : Tuple , lowercase_ : List[Any] , lowercase_ : Tuple...
485
1
'''simple docstring''' 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__": snake_case_ : Optional[int] = pd.read_csv('sample_data.csv', ...
195
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available snake_case_ : Union[str, Any] = { 'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'], 't...
195
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase : List[Any] = { "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_...
423
import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging lowercase : int = logging.get_logger(__name__) ...
423
1
'''simple docstring''' class __snake_case : """simple docstring""" def __init__( self : Dict , lowerCamelCase : Tuple , lowerCamelCase : List[str] ) -> List[str]: lowerCAmelCase_ : List[Any] = name ...
275
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roberta import RobertaTokenizer _...
40
0
import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
707
# 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 # # Unless required ...
557
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _SCREAMING_SNAKE_CASE = { "configuration_gpt_bigcode": ["GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTBigCod...
369
'''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 _low...
369
1
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, resize, to_channel...
719
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, logging, ) ...
638
0
'''simple docstring''' def UpperCAmelCase__( _SCREAMING_SNAKE_CASE : int = 1000 ): """simple docstring""" __A= 3 __A= 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a a += 1 return result if __name__...
186
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( ...
186
1
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : int = 200 ) ->int: '''simple docstring''' a : Dict = [1, 2, 5, 10, 20, 50, 100, 200] a : Optional[Any] = [0] * (pence + 1) a : List[Any] = 1 # base case: ...
31
"""simple docstring""" # 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/lic...
31
1
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class UpperCAmelCase__ ( A ): lowerCAmelCase_ = ['image_processor', 'tokenizer'] lowerCAmelCase_ = 'AutoImageProcessor' lowerCAmelC...
44
'''simple docstring''' from __future__ import annotations def __a ( A__ , A__ = None , A__ = None , A__ = False , ) -> tuple[int, float, str]: lowerCAmelCase = cipher_alphabet or [chr(A__ ) for i in range(97 , 123 ...
649
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """tanreinama/GPTSAN-2.8B-spout_is_uniform""": ( """https://huggingface.co/tanreinama/GPTSAN-2.8B-spout_is_uniform/resolve/main/config.json""...
712
from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def __lowerCAmelCase ( ): lowercase__ = HfArgumentParser(SCREAMING_SNAKE_CASE_ ) lowercase__ = parser.parse_args_into_dataclasses()[0] lowercase__ = TensorFlowBenchmark(args=SCREA...
37
0
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_de...
486
def lowerCAmelCase_ ( __A, __A ) -> Optional[Any]: '''simple docstring''' UpperCAmelCase__ = [1] for i in range(2, __A ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k out of bounds" ...
486
1
from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('3.8'): import importlib_metadata else: import importlib.metadata as importlib_metadata _a : List[str] = ...
571
def UpperCamelCase__ ( _A: Tuple , _A: List[str] , _A: Tuple , _A: Dict , _A: int , _A: List[str] ): '''simple docstring''' if index == r: for j in range(_A ): ...
571
1
'''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 A ( __UpperCAmelCase , ...
325
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A ( unittest.TestCase ...
325
1
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a ni...
718
import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data import DataLoader, Ra...
321
0
'''simple docstring''' from statistics import mean, stdev def __a ( lowerCAmelCase__ : list , lowerCAmelCase__ : int = 3 ): a__ : List[Any] = min(lowerCAmelCase__ ) a__ : Optional[int] = max(lowerCAmelCase__ ) # normalize data...
688
'''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 __SCREAMING_SNAKE_CASE = logging.get_lo...
688
1
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import TEXT_GUIDED_IM...
701
import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ =logging.get_logger(__name__) UpperCAmelCase_ ={ """vocab_file""": """vocab.txt""", """...
33
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __lowercase : List[str] =logging.get_logger(__name__) __lowercase : Dict ={ """shi-labs/dinat-mini-i...
54
def UpperCAmelCase_ ( ) -> int: """simple docstring""" return 1 def UpperCAmelCase_ ( snake_case__ ) -> int: """simple docstring""" return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def UpperCAmelCase_ ( snake_case__ )...
193
0
'''simple docstring''' import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin A : int = get_tests_dir("""fixtures/test_sentencepiec...
707
'''simple docstring''' from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataColl...
136
0
"""simple docstring""" import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def _UpperCAmelCase ( lowerCamelCase__ ): """simple docstring""" lowerCAmelCase__ = FileLock(str(tmpdir / """foo.lock""" ) ) lowerCAmelCase__ = FileLock(str(tmpd...
644
"""simple docstring""" from __future__ import annotations from random import random from typing import Generic, TypeVar __lowerCAmelCase : Dict = TypeVar("KT") __lowerCAmelCase : Optional[Any] = TypeVar("VT") class a_ ( Generic[KT, VT] ): def __init__( s...
644
1
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('dataset_size' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('input_in_memory_max_size' , ['default', 0, 100 * 2**20, 900 * 2**20] ) def A ( lowercase , lowe...
721
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('dataset_size' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('input_in_memory_max_size' , ['default', 0, 100 * 2**20, 900 * 2**20] ) def A ( lowercase , lowe...
3
0
"""simple docstring""" from decimal import Decimal, getcontext from math import ceil, factorial def UpperCAmelCase ( _lowercase : int ) -> str: """simple docstring""" if not isinstance(a_ , a_ ): raise TypeError('''Undefined for non-integers''' ) elif precis...
552
"""simple docstring""" UpperCAmelCase = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def lowerCam...
677
0
"""simple docstring""" import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def lowercase ( _snake_case : Optional[Any] ) ->Any: """simple docstring""" return x + 2 class _UpperCAmelCase ( unittest.T...
229
"""simple docstring""" from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common imp...
229
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { """configuration_time_series_transformer""": [ """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TimeSeriesTransfor...
437
# Function to print upper half of diamond (pyramid) def __UpperCamelCase ( _A ): for i in range(0 , _A ): for _ in range(0 , n - i - 1 ): # printing spaces print(''' ''' , end='''''' ) for _ in range(0 , i + 1 ):...
431
0
"""simple docstring""" from __future__ import annotations _lowercase : Dict = tuple[int, int, int] _lowercase : Optional[Any] = tuple[str, str, str] # used alphabet -------------------------- # from string.ascii_uppercase _lowercase : Tuple = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" #...
625
"""simple docstring""" _lowercase : str = 0 # The first color of the flag. _lowercase : Dict = 1 # The second color of the flag. _lowercase : Tuple = 2 # The third color of the flag. _lowercase : Optional[int] = (red, white, blue) def snake_case__ ( _...
625
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase = {'''configuration_mmbt''': ['''MMBTConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except O...
119
'''simple docstring''' import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import version fr...
119
1
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 from ..auto import CONFIG_MAPPING a_ = logging.get_logger(__name__) a_ = { """microsoft/ta...
622
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 __lowerCAmelCase ( lowerCAmelCase__ , unittest...
622
1
"""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__ ( UpperCAmelCase_ , UpperCAmelCase_ ...
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
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_f...
28
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : list[int] , snake_case__ : str ): """simple docstring""" _snake_case : str = int(snake_case__ ) # Initialize Result _snake_case : str = [] # Traverse through ...
28
1
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from ...
367
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between che...
367
1
'''simple docstring''' def A_ ( snake_case = 1000 ): SCREAMING_SNAKE_CASE:List[str] = 3 SCREAMING_SNAKE_CASE:Tuple = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a a += 1 return result if __name...
465
'''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_ = { "linear": PIL.Image.Resampling.BILINEAR, "bilinear": PIL...
465
1
from __future__ import annotations import math def lowerCamelCase_ ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): if depth < 0: raise ValueError('''Depth cannot be less than 0''' ) if not scores: ...
141
from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake SCREAMING_SNAKE_CASE : List[str] = numpy.array([0, 0]) SCREAMING_SNAKE_CASE : Tuple = numpy.array([0.5, 0.8660254]) SCREAMING_SNAKE_CASE : Tup...
141
1
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __snake_case ( lowerCAmelCase__ , lowerCAmelCase__ ): @register_to_config def __init__( self , *, _A = 4 , _A = 768 , _A ...
620
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase__ : Any = { "configuration_mvp": ["MVP_PRETRAINED_CONFIG_ARCHIVE_MAP", "MvpConfig", "MvpOnnxConfig"], "tokenization_mvp": ["MvpTokenizer"]...
620
1
'''simple docstring''' import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration snake_case : List[str] = 50_000 snake_case : Tuple = 5_000 snake_case , snake_case : Any = os.path.split(__file__) snake_case : Any = os...
566
'''simple docstring''' import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def lowercase__ ( *__UpperCamelCase : Optional[Any] ): '''simple docstring''' if not isinstance(__UpperCamelCase , __UpperCamelCase ):...
566
1
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, V...
6
'''simple docstring''' from math import log from scipy.constants import Boltzmann, physical_constants lowerCAmelCase__ = 300 # TEMPERATURE (unit = K) def __UpperCAmelCase ( lowerCamelCase_ , lowerCamelCase_ , lowerCamelCase_ , ...
6
1
"""simple docstring""" def lowerCamelCase_( _lowerCamelCase ) -> int: '''simple docstring''' _lowerCamelCase : list[list[int]] = [[0 for _ in range(_lowerCamelCase )] for _ in range(m + 1 )] for i in range(m + 1 ): _lowerCamelCase : ...
46
# limitations under the License. # 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 .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecate...
285
0
from pathlib import Path import fire from tqdm import tqdm def A ( lowercase="ro" , lowercase="en" , lowercase="wmt16" , lowercase=None ) -> Any: '''simple docstring''' try: import datasets except (ModuleNotFoundError, ImportError): raise ImportError('run pip install d...
711
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Dict = logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] = { "vocab_file": ...
3
0
'''simple docstring''' from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def _UpperCamelCase ( ) -> tuple[list[int], int]: lowerCamelCase_ = [randint(-10_00 ,10_00 ) for i in range(10 )] lowerCamelC...
42
'''simple docstring''' from __future__ import annotations from math import pi, sqrt def UpperCamelCase ( lowercase_ : float , lowercase_ : float ) -> tuple: '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) e...
72
0
"""simple docstring""" from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( ...
720
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase = { '''configuration_roberta...
24
0
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.configurati...
548
import re def lowerCamelCase_ ( lowerCamelCase__ ): return [char.split() for char in re.split(r"[^ a-z A-Z 0-9 \s]" , str_ )] def lowerCamelCase_ ( lowerCamelCase__ ): lowerCamelCase_ = split_input(str_ ) return "".join( ...
463
0
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__ = logging.get_logger(__name__) lowerCamelCase__ = { """facebook/levit-128S""": ""...
707
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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResamplin...
547
0
'''simple docstring''' from __future__ import annotations from typing import Any def _A ( _lowerCAmelCase ): """simple docstring""" create_state_space_tree(_lowerCAmelCase , [] , 0 ) def _A ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): ...
474
'''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 diffusers.utils import slow, torc...
474
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, r...
144
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { '''microsoft/focalnet-tiny''': '''https://huggin...
144
1
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.models.wavaveca im...
55
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE = True , *SCREAMING_SNAKE_CASE , **SCREAMING_SNAKE_CASE ): if not is_tqdm_available(): ra...
590
0
from graphs.minimum_spanning_tree_kruskal import kruskal def UpperCamelCase( ) -> Optional[int]: '''simple docstring''' snake_case_ = 9 snake_case_ = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], [2, 8, 2], [8, 6, 6], ...
714
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) lowerCamelCase_ = pytest.mark.integration @pytest.mark.parametrize("""path""" , ["""paws"...
161
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) A : Union[str, Any] = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ConvN...
15
"""simple docstring""" from ..utils import DummyObject, requires_backends class _SCREAMING_SNAKE_CASE ( metaclass=__UpperCAmelCase ): """simple docstring""" _a : Optional[int] = ['''note_seq'''] def __init__( self , *lowerCamelCase__ , **lowerCamelCase__...
200
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ = {"""configuration_sew""": ["""SEW_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SEWConfig"""]} try: if not is_torch_available(): ...
549
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """speechbrain/m-ctc-t-large""": """https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json"...
549
1