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 inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from ...te...
647
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) de...
647
1
'''simple docstring''' import argparse import os import re import zipfile import torch from transformers import AutoTokenizer, GPTaConfig def snake_case (UpperCamelCase : Tuple , UpperCamelCase : Optional[int] , UpperCamelCase : List[str]=0 ): '''simple docstring'...
705
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 3 are not primes return False # ...
235
0
import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_p...
151
from argparse import ArgumentParser from .env import EnvironmentCommand def UpperCAmelCase_ ( ): SCREAMING_SNAKE_CASE__ =ArgumentParser("""Diffusers CLI tool""", usage="""diffusers-cli <command> [<args>]""" ) SCREAMING_SNAKE_CASE__ =parser.add_subparsers(help="...
151
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) ...
143
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, ...
143
1
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING _lowercase = logging.get_logger(__name__) class lowerCAmelCase_ ( __UpperCamelCase ): '''simple docstring'...
91
from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_config...
600
0
'''simple docstring''' import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) a_ : Dict = models...
710
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _snake_case ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self) -> str: debug_launcher(test_script.main) de...
444
0
"""simple docstring""" from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def UpperCamelCase__ ( lowercase__ : Optional[int] , lowercase__ : str , lowercase__ : Dict = 1 / sqrt(2 ) ): snake_case : List[str] = tau * freque...
134
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _a: int = logging.get_logger(__name__) _a: Optional[Any] = { """SenseTime/deformable-detr""": """https://huggingface.co/sensetime/deformable-detr/resolve...
162
0
'''simple docstring''' import numpy as np def lowercase__( __UpperCamelCase: np.ndarray ): """simple docstring""" return 1 / (1 + np.exp(-vector )) def lowercase__( __UpperCamelCase: np.ndarray ): """simple docstring"...
707
'''simple docstring''' import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def lowercase__( __UpperCamelCase: bytes ,__UpperCamelCase: int ): """simple docstring""" SCREAMING_SNAKE_CA...
508
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCamelCase ) class lowerCamelCase_ ( lowerCamelCase ): a__ = field(default='''language-modeling''' , meta...
0
import argparse import os import re import packaging.version _UpperCAmelCase = """examples/""" _UpperCAmelCase = { """examples""": (re.compile(r"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), """init""": (re.compile(r""...
558
0
"""simple docstring""" import math import unittest def lowerCamelCase (a_ :int) -> bool: assert isinstance(a_ , a_) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes ...
475
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = ...
475
1
"""simple docstring""" import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def UpperCAmelCase ( snake_...
227
"""simple docstring""" import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def UpperCAmelCase ( snake_case : str ): if "model" in orig_key: _lowerCAmelCase:str = orig_key.replace('''model.''' , '''''' ) if "norm1" ...
227
1
'''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_commo...
624
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters lowerCAmelCase__ = (720, 1280) # Height, Width lowerCAmelCase__ = (0.4, 0.6) # if height or width lower than this scale, drop it. lowerCAmelCase...
624
1
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : Dict , _SCREAMING_SNAKE_CASE : Optional[Any] , _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : List[Any] ) -> Tuple: """simple docstring""" UpperCAmelCase_ : Dict ...
71
"""simple docstring""" import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sente...
657
0
def lowerCamelCase__ ( _lowerCamelCase = 3 , _lowerCamelCase = 7 , _lowerCamelCase = 100_0000 ) ->int: _UpperCAmelCase =0 _UpperCAmelCase =1 for current_denominator in range(1 , limit + 1 ): _UpperCAmelCase =current_denominator * numerator // denominator if curr...
705
from __future__ import annotations def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase ) ->bool: _UpperCAmelCase =get_failure_array(_lowerCamelCase ) # 2) Step through text searching for pattern _UpperCAmelCase , _UpperCAmelCase =0, 0 # index into text, pattern ...
592
0
import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require_tf, require_torch from t...
81
from queue import PriorityQueue from typing import Any import numpy as np def __lowerCAmelCase ( __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ , ): for nxt, d in graph[v]: if...
226
0
from __future__ import annotations from collections import Counter from random import random class _lowerCamelCase : """simple docstring""" def __init__( self ) -> int: """simple docstring""" UpperCamelCase__ : int = {} de...
711
from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig 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_common imp...
462
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase_ : Any = { """configuration_llama""": ...
331
'''simple docstring''' def _lowerCAmelCase (_lowercase = 3 , _lowercase = 7 , _lowercase = 1_00_00_00 ): """simple docstring""" a__ = 0 a__ = 1 for current_denominator in range(1 , limit + 1 ): a__ = cu...
331
1
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): UpperCamelCase = yaml.safe_load( '\\nname: ""\nallow_empty: false\nallow_empty_text: true\nsubsections:\n - name: "...
125
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def _A ( lowerCAmelCase_ : Tuple , lowerCAmelCase_ : Dic...
125
1
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTe...
467
'''simple docstring''' from __future__ import annotations from collections.abc import Sequence from typing import Literal def a__ ( UpperCamelCase_ : str, UpperCamelCase_ : str ): UpperCAmelCase__ :Any = list(UpperCamelCase_ ) UpperCAmelCase__ :O...
467
1
from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ = False): '''simple docstring''' if radian_mode: return [magn...
73
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowerCAmelCase__ ( ...
73
1
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def UpperCAmelCase_ ( lowerCAmelCase_ ): """simple docstring""" lowercase = FileLock(str(tmpdir / "foo.lock" ) ) lowercase = FileLock(str(tm...
310
'''simple docstring''' import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class UpperCAmelCase : def __init__(self : Optional[Any] , A__...
310
1
'''simple docstring''' def _lowercase ( lowerCamelCase__ : int, lowerCamelCase__ : int ): return number | (1 << position) def _lowercase ( lowerCamelCase__ : int, lowerCamelCase__ : int ): return number & ~(1 << position) def _lowercase ( lowerCamelCase_...
691
'''simple docstring''' def _lowercase ( lowerCamelCase__ : list[int], lowerCamelCase__ : list[int], lowerCamelCase__ : int ): return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(lowerCamelCase__ ) ) def _lowercas...
691
1
def SCREAMING_SNAKE_CASE__ ( ): return [list(range(1_000 - i , -1_000 - i , -1 ) ) for i in range(1_000 )] _lowerCamelCase = generate_large_matrix() _lowerCamelCase = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]], [[3, 2], ...
6
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 ( UpperCamelCase__ ): _a = ["i...
307
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __SCREAMING_SNAKE_CASE : List[Any] = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : str = { ...
714
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_common im...
580
0
"""simple docstring""" from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar a_ = TypeVar('KEY') a_ = TypeVar('VAL') @dataclass(frozen=snake_case , slots=snake_case ) class UpperCAmelCase...
76
"""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 import BertTokenizer a_ = lo...
76
1
from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_ten...
649
lowerCamelCase : List[str] = '''0.18.2''' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_li...
649
1
'''simple docstring''' import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel __UpperCamelCase : int = HfApi() __UpperCamelCase : str = {} # fmt: off __UpperCamelCase : str = torch.tensor(...
448
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE ...
502
0
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
165
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated UpperCAmelCase_ : Tuple = coll...
165
1
'''simple docstring''' import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from acceler...
229
"""simple docstring""" import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils impo...
237
0
"""simple docstring""" def _a ( _snake_case = 10 , _snake_case = 22 ): """simple docstring""" UpperCAmelCase = range(1 , _snake_case ) UpperCAmelCase = range(1 , _snake_case ) return sum( 1 for power in powers fo...
74
"""simple docstring""" import math def _a ( _snake_case ): """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...
74
1
'''simple docstring''' from math import isqrt def a_ ( UpperCamelCase_ ): A_ = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , UpperCamelCase_ , UpperCamelCase_ ): ...
452
'''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...
452
1
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # 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...
486
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 ( AutoCo...
486
1
def _A ( SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : int = 0 ): """simple docstring""" a__ : Optional[Any] =length or len(SCREAMING_SNAKE_CASE ) a__ : int =False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]...
563
from math import factorial UpperCAmelCase : Tuple = {str(d): factorial(d) for d in range(10)} def _A ( SCREAMING_SNAKE_CASE : int ): """simple docstring""" return sum(DIGIT_FACTORIAL[d] for d in str(SCREAMING_SNAKE_CASE ) ) def _A ( ): ...
563
1
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( _SCREAMING_SNAKE_CASE ): lowerCAmelCase_ : Dict =[1] lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ : List[Any] =0, 0, 0 lowerCAmelCase_ : Union[str, Any] =u...
305
'''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 __lowercase = get_tests_dir('''fixtures/test_sentencepiece_w...
305
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 _A = logging.get_logger(__name__) _A = { "microsoft/beit-base-patch16-224-pt22k": ( "https://hu...
290
from random import randint from tempfile import TemporaryFile import numpy as np def __UpperCAmelCase ( __a : Optional[Any] ,__a : int ,__a : Any ) -> int: """simple docstring""" _a : int = 0 if start < end: _a ...
14
0
"""simple docstring""" import inspect import unittest from transformers import DecisionTransformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_comm...
700
"""simple docstring""" import re def __UpperCAmelCase ( __lowerCamelCase ) -> bool: lowercase__ : Optional[Any] = re.compile( r'''^(?:0|94|\+94|0{2}94)''' r'''7(0|1|2|4|5|6|7|8)''' r'''(-| |)''' r'''\d{7}$''' ) return bool(re.search(__lowerCam...
122
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' ...
306
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 ...
306
1
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def a ( __UpperCAmelCase : int = 8 ) -> str: __magic_name__: Union[str, Any] = a...
213
"""simple docstring""" import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def a ( __UpperCAmelCase : Optional[Any] , __Upp...
213
1
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class snake_case ( lowercase ): """simple docstring""" def snake_case ( self ...
675
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a_ : Optional[Any] = { """configuration_ctrl""": ["""CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CTRLConfig"""], """...
675
1
'''simple docstring''' from math import loga def _snake_case ( _SCREAMING_SNAKE_CASE : int ) -> List[str]: """simple docstring""" if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(_lowerCAmelCase ...
711
'''simple docstring''' import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": UpperCAmelCase = argparse.ArgumentParser( description=( 'Extraction some layers of the full RobertaForMaskedLM or GPT2LMHead...
344
0
'''simple docstring''' import math def lowercase_ ( ) -> None: """simple docstring""" lowercase : Union[str, Any] =input('''Enter message: ''' ) lowercase : List[Any] =int(input(F'Enter key [2-{len(__A ) - 1}]: ' ) ) lowercase : ...
94
"""simple docstring""" from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split __magic_name__ = datasets.load_iris() __magic_name__ = np.array(data["data"]) __magic_name__ = np.array(data["target"]) __magic_name__ ...
155
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { '''google/switch-base-8''': '''https://huggingface.co/google/switch-base-8/blob/main/config.json''', } class A__ ( __UpperC...
711
import math import random def lowerCAmelCase ( UpperCAmelCase, UpperCAmelCase = False ) ->float: """simple docstring""" if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value lowercase...
336
0
'''simple docstring''' import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def _a ( *_lowerCamelCase , _lowerCamelCase = None , _lowerCamelCase=True , _lowerCamelCase=2 ) -> Union[str, Any]: ...
26
"""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...
52
0
"""simple docstring""" import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_...
529
"""simple docstring""" import inspect import unittest from transformers import ViTMSNConfig 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_configuration_common imp...
529
1
from manim import * class UpperCamelCase ( __a ): def A_ (self ) -> Union[str, Any]: UpperCamelCase_ : Union[str, Any] = Rectangle(height=0.5 , width=0.5 ) UpperCamelCase_ : Union[str, Any] = Rectangle(h...
635
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType,...
635
1
"""simple docstring""" def __lowerCAmelCase ( __lowerCAmelCase : int = 200 ) -> int: _UpperCamelCase : str = [1, 2, 5, 10, 20, 50, 100, 200] _UpperCamelCase : Optional[Any] = [0] * (pence + 1) _UpperCamelCase : List[str] = 1 # base case: 1 ...
239
"""simple docstring""" from math import ceil def __lowerCAmelCase ( __lowerCAmelCase : int = 1001 ) -> int: _UpperCamelCase : Tuple = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): _UpperCamelCase : Tuple = 2 * i + 1 _UpperCamelCase...
239
1
"""simple docstring""" import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() a_ = logging.get_logger(__name__) ...
76
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase = { 'configuration_m2m_100': ['M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP', 'M2M100Config', 'M2M100OnnxConfig'], 'tokenization_m...
144
0
"""simple docstring""" import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, ...
713
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Tuple = logging.get_logger(__name__) _lowercase : Optional[int] = { 'google/realm-cc-news-pretrained-embedder': ( 'https://huggingface....
397
0
from typing import List, Optional, Tuple, Union import torch from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCAmelCase_ ( __lowercase ): """simple docstring""" ...
14
"""simple docstring""" import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, Distil...
609
0
'''simple docstring''' import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def _sna...
460
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def _snake_case ( ): """simple docstring""" import os as original_os from os import path as original_path from os import rename as original...
460
1
import argparse 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 Accel...
47
import numpy as np import datasets A__ : int = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance.\nIt was introduced by P...
183
0
from __future__ import annotations def __a ( __UpperCAmelCase : int , __UpperCAmelCase : int ) -> list[str]: """simple docstring""" if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions > number_of_byte...
253
class snake_case_ : '''simple docstring''' def __init__( self : str ) -> Optional[int]: lowerCamelCase_ : Optional[Any] = "" lowerCamelCase_ : Dict = "" lowerCamelCase_ : Union[str, Any] = [] ...
253
1
"""simple docstring""" import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging A__ : str = logging.get_logger(__name__) def _lowerCAmelCase ( _UpperCamelCase , _UpperCame...
353
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase : List[Any] = ...
396
0
'''simple docstring''' def UpperCamelCase__ ( __magic_name__ : int , __magic_name__ : int ) -> float: '''simple docstring''' return base * power(__magic_name__ , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print("Raise base to the ...
419
'''simple docstring''' def UpperCamelCase__ ( __magic_name__ : str , __magic_name__ : str ) -> str: '''simple docstring''' snake_case__ : int = len(__magic_name__ ) snake_case__ : int = len(__magic_name__ ) snake_case__...
419
1
"""simple docstring""" import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def snake_case ( A__ ,A__=False ): UpperCAmelCase_ : Any = OmegaConf.load(A__ ) if display: print(yaml.dump(OmegaConf.to_container(A__ ...
95
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_a...
95
1
import csv import tweepy # Twitter API credentials lowercase = """""" lowercase = """""" lowercase = """""" lowercase = """""" def A__ ( _UpperCAmelCase : str ) -> None: '''simple docstring''' snake_case__ : Any = tweepy.OAuthHandler(_UpperCAmelCase ...
707
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput ...
150
0
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTe...
187
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def a(lowercase__ ): '''simple docstring''' snake_case_ = 384 ...
187
1
'''simple docstring''' from __future__ import annotations from typing import Any def UpperCAmelCase ( a_ ) -> Union[str, Any]: """simple docstring""" if not postfix_notation: return 0 A_ : Union[str, Any] = {"""+""", """...
709
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, ski...
385
0
"""simple docstring""" import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput __A = """scheduler_config.json""" class _lo...
93
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE ) ->str: """simple docstring""" lowerCAmelCase__ :List[Any] = int(_SCREAMING_SNAKE_CASE ) if decimal in (0, 1): # Exit cases for the recursion return str(_SCREAMING_SNAKE_CASE ) lowerCAmelCase__ ...
93
1
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, random_attention_mask from ...test...
353
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): from trans...
353
1
import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokenizer, ...
352
from datetime import datetime import requests def __a ( __lowerCAmelCase ) -> bytes: SCREAMING_SNAKE_CASE : int = 'https://downloadgram.net/wp-json/wppress/video-downloader/video?url=' SCREAMING_SNAKE_CASE : Any = requests.get(base_url +...
352
1
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class _UpperCamelCase( unittest.TestCase ): def a__ ( self : str ): _UpperCAmelCase : Tuple = get_activation("swish" ) self.assert...
718
# 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 requir...
328
0
'''simple docstring''' 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 ...
90
'''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, ftp_ge...
384
0
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class lowercase__ ( _UpperCAmelCase ): def A_ ( self : Any ): return [ {"col_1": 3, "col_2": "a"}, {"col_1": 2, "col_2": "b"}, ...
400
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __snake_case = { """configuration_layoutlmv3""": [ """LAYOUTLMV3_PRETRAINED_CONF...
400
1
"""simple docstring""" import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) ...
76
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 A__ ( __A : Any , __A : Dict , __A : Optional[...
184
0
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example lowercase_ : List[str] = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0,...
701
'''simple docstring''' from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
653
0
'''simple docstring''' from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE = "isbn/0140328726" ): _snake_case = olid.strip().strip("""/""" ) # Remove leading/trailing whitespace & slashes ...
585
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _Uppe...
367
0
'''simple docstring''' 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 ...
713
'''simple docstring''' 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] ) ...
238
0
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metrics as comput...
491
import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ....
491
1
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from...
703
"""simple docstring""" from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures...
505
0
from __future__ import annotations def __lowerCamelCase ( lowerCamelCase__ : list[int] , lowerCamelCase__ : list[int] , lowerCamelCase__ : int ): '''simple docstring''' lowerCamelCase = list(range(len(lowerCamelCase__ ) ) ) ...
457
import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer UpperCAmelCase : Any = logging.getLogger(__name__) def __lowerCamelCase ( ): '''simple docstring''' lowerCamelCase = argparse.ArgumentParser( ...
457
1
import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, req...
604
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow from ..test_modeling...
604
1
"""simple docstring""" from collections.abc import Callable def lowerCamelCase__ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ )-> float: """simple docstring""" UpperCamelCase = a UpperCamelCase = b if fun...
554
"""simple docstring""" import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class ...
554
1
"""simple docstring""" import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_f...
707
"""simple docstring""" def lowerCamelCase_ ( __lowerCAmelCase , __lowerCAmelCase = False ) -> str: '''simple docstring''' if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): lowerCamelCase__ =F'''Expected string as input, foun...
132
0
import copy import random from transformers import CLIPTokenizer class UpperCamelCase_ ( SCREAMING_SNAKE_CASE__ ): def __init__( self :Any , *__A :Dict , **__A :List[str] ) -> Optional[Any]: """simple docstring""" super().__init__(*__...
6
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) A : Dict = { "configuration_speecht5": [ "SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP", "SPEECHT5_PRETRAINED_HIFIGAN_CON...
140
0
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __UpperCAmelCase :List[str] = (7_2_0, 1_2_8_0) # Height, Width __UpperCAmelCase :int = (0.4, 0.6) # if height or ...
702
'''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) ...
266
0
import numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) lowercase_ = models.Sequential() # Step 1 - Convolution # Here ...
74
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from...
225
0
from __future__ import annotations def __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_): '''simple docstring''' if days_between_payments <= 0: raise ValueError("days_between_payments must be > 0") if daily_interest_rate < 0: raise ValueErr...
73
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class lowerCAmelCase__ ( unittest.TestCase ): """simple docstring""" def _Up...
73
1
'''simple docstring''' def __UpperCAmelCase ( A : list ) -> list: UpperCAmelCase_ : List[str] = len(A ) for i in range(1 , A ): UpperCAmelCase_ : str = collection[i] UpperCAmelCase_ : List[Any] ...
541
'''simple docstring''' import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _UpperCamelCase : str = {1: (1, 1), 2: (2, 1), 3: (3, 1),...
541
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 # # Unles...
217
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { 'faceboo...
217
1
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 a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__=N...
99
'''simple docstring''' def _A ( lowercase__ ): assert ( isinstance(lowercase__ , lowercase__ ) and number_of_steps > 0 ), f'''number_of_steps needs to be positive integer, your input {number_of_steps}''' if number_of_steps == 1: return 1 lowercase__ ...
325
0
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 _UpperCamelCase ...
193
from __future__ import annotations import math import random from typing import Any class _UpperCamelCase : '''simple docstring''' def __init__( self : Union[str, Any] ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE : list[Any] = [] ...
193
1
"""simple docstring""" import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, ...
19
"""simple docstring""" import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class _UpperCAmelCase( lo...
19
1
import math def lowerCamelCase__ ( _a): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # All primes number are in format of 6k +/- 1 for i in range(5 ...
700
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dataclass c...
193
0
'''simple docstring''' _UpperCAmelCase : Tuple = '''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/''' def UpperCamelCase ( lowercase_ : bytes ) -> bytes: '''simple docstring''' if not isinstance(lowercase_ , lowercase_ ): lowercase =f'a bytes-...
72
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import l...
86
0
'''simple docstring''' import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pyto...
715
'''simple docstring''' import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def UpperCAmelCase__ ( ...
667
0
"""simple docstring""" from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging lowercase_ : List[Any] = logging.get_logger(__name__) ...
572
'''simple docstring''' from math import isqrt def a__ ( a__ ): """simple docstring""" return all(number % divisor != 0 for divisor in range(2 , isqrt(a__ ) + 1 ) ) def a__ ( a__ = 10**6 ): """simple docstring""" __SCREAMING_SNAKE_CASE = 0 ...
627
0
"""simple docstring""" def __snake_case ( UpperCamelCase ) -> list: """simple docstring""" if len(UpperCamelCase ) <= 1: return lst a__ = 1 while i < len(UpperCamelCase ): if lst[i - 1] <= lst[i]: i += 1 else: a__ , a__ = ls...
158
"""simple docstring""" import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging import di...
158
1
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import T...
332
from ..utils import DummyObject, requires_backends class a ( metaclass=__SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase_ : Optional[int] = ['note_seq'] def __init__( self : Dict , *lowerCamelCase__ : int , **lowerCamelC...
332
1
'''simple docstring''' import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def low...
713
'''simple docstring''' from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def lowerCamelCase ( lowerCamelCase : str , lowerCamelCase : complex , lowerCamelCase : str = "x" , lowerCamelCase : float = 10**-1...
27
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DiffusionPipeline, EulerDiscreteScheduler, StableDiffu...
3
'''simple docstring''' import colorsys from PIL import Image # type: ignore def A_( A : float , A : float , A : int): UpperCamelCase = x UpperCamelCase = y for step in range(A): # noqa: B007 UpperCamelCase ...
3
1
from __future__ import annotations def _A (lowerCAmelCase__ :list ) -> float: '''simple docstring''' if not nums: raise ValueError('List is empty' ) return sum(lowerCAmelCase__ ) / len(lowerCAmelCase__ ) if __name__ == "__main__": import d...
714
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a_ : str = { "configuration_data2vec_audio": ["DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP", "Data2VecAudioCon...
532
0
'''simple docstring''' from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig _lowerCamelCase : List[Any] = { "susnato/ernie-m-base_pytorch": "https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json"...
430
from collections.abc import Sequence def __A(lowerCAmelCase = None ) -> int: """simple docstring""" if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) _UpperCamelCase = nums[0] for i in range(1 , len(lowerCAmelCase ) ): _U...
612
0
import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline, ...
577
def UpperCAmelCase__ ( lowerCamelCase_ : list[int] , lowerCamelCase_ : list[int] ): # Check if the input is valid if not len(lowerCamelCase_ ) == len(lowerCamelCase_ ) == 3: raise ValueError('Please enter a valid equation.' ) if e...
577
1
from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ...test_pipeline...
16
'''simple docstring''' from __future__ import annotations def __lowercase ( __lowercase , __lowercase ) -> list[int]: '''simple docstring''' _A = 0 _A = len(__lowercase ) - 1 while i < j: if nums[i] + nums[j] == target: ...
330
0
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake SCREAMING_SNAKE_CASE_ = numpy.array([0, 0]) SCREAMING_SNAKE_CASE_ = numpy.array([0.5, 0.8_6_6_0_2_5_4]) SCREAMING_SNAKE_CASE_ = num...
201
'''simple docstring''' import numpy # List of input, output pairs SCREAMING_SNAKE_CASE_ = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) SCREAMING_SNAKE_CASE_ = (((5_15, 22, 13), 5_55), ((61, 35, 49), 1_50)) SCREAMING_SNAKE_CASE...
201
1
import argparse import json from tqdm import tqdm def _lowercase ( ): """simple docstring""" UpperCamelCase = argparse.ArgumentParser() # Required parameters parser.add_argument( """--src_path""" , type=SCREAMING_SNAKE_CASE_ ...
386
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IM...
386
1
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 ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, ViltForMaskedLM, Vilt...
700
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tens...
300
0
'''simple docstring''' 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 fro...
384
'''simple docstring''' from collections.abc import Sequence def _UpperCAmelCase ( _lowerCamelCase : Sequence[float] , _lowerCamelCase : float ) -> float: return sum(c * (x**i) for i, c in enumerate(_lowerCamelCase ) ) def _UpperCAmelCase ( _lowerCamelCase : ...
384
1
"""simple docstring""" import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import DEFA...
158
"""simple docstring""" import math import qiskit def __snake_case ( UpperCamelCase = 1 , UpperCamelCase = 1 , UpperCamelCase = 1 ) -> qiskit.result.counts.Counts: """simple docstring""" if ( isinstance(UpperCamelCase , UpperCamelCase ) or isinstance(UpperCam...
158
1