code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import Model...
210
from decimal import Decimal, getcontext from math import ceil, factorial def UpperCAmelCase ( lowercase ): """simple docstring""" if not isinstance(lowercase , lowercase ): raise TypeError('''Undefined for non-integers''' ) elif precision < 1: ...
210
1
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepar...
21
'''simple docstring''' from __future__ import annotations from typing import Any def lowerCamelCase ( UpperCAmelCase__ : list ) -> int: if not postfix_notation: return 0 lowercase_ : Any = {"""+""", """-""", """*""", """/"""} lowercase_ ...
21
1
"""simple docstring""" from __future__ import annotations from typing import TypedDict class __UpperCamelCase ( a__ ): lowerCamelCase : str lowerCamelCase : int def _SCREAMING_SNAKE_CASE ( _lowercase : str ) ->l...
105
'''simple docstring''' from __future__ import annotations def __a ( UpperCAmelCase , UpperCAmelCase ) ->Tuple: """simple docstring""" if len(UpperCAmelCase ) <= 1 or n <= 1: return insert_next(UpperCAmelCase , n - 1 ) rec_insertion_sort(UpperCAmelCase , n - ...
258
0
'''simple docstring''' import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_...
363
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_tr...
147
0
from __future__ import annotations from fractions import Fraction def a ( A__ : int , A__ : int ) -> bool: """simple docstring""" return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def ...
205
import os def a ( ) -> Any: """simple docstring""" with open(os.path.dirname(A__ ) + '/p022_names.txt' ) as file: _lowercase =str(file.readlines()[0] ) _lowercase =names.replace('"' , '' ).split(',' ...
205
1
from __future__ import annotations def _lowerCAmelCase ( A__: int = 4 ): '''simple docstring''' UpperCAmelCase = abs(A__ ) or 4 return [[1 + x + y * row_size for x in range(A__ )] for y in range(A__ )] def _lowerCAmelCase ( A__: ...
152
import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversat...
152
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __A = { "configuration_layoutlmv2": ["LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "LayoutLMv2...
90
import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import Toke...
7
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __lowercase = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''], '''tokeni...
85
"""simple docstring""" def lowerCAmelCase (__UpperCamelCase : int = 1_0_0_0 ): """simple docstring""" __UpperCamelCase =-1 __UpperCamelCase =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 ...
85
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 __lowerCAmelCase ( datasets.BeamBasedBuilder ): def snake_case ( self ): ...
82
from collections.abc import Iterable from typing import Generic, TypeVar A__ = TypeVar("""_T""") class __lowerCAmelCase ( Generic[_T] ): def __init__( self , _snake_case = None ): """simple docstring""" _lowerCAmelCase = list(...
82
1
import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) lowerCamelCase_ = logging.getLogger() def UpperCamelC...
34
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def UpperCamelCase( lowercase_ = "" ) -> dict[str, float]: '''simple docstring''' snake_case_ = url or """https://www.imdb.com/chart/top/?ref_=nv_mv_250""" snake_case_ = ...
34
1
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule _lowercase : int = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys ...
332
1
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge lowercase = [ """Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw a cell phone video of ...
359
from __future__ import annotations from typing import Any def lowerCamelCase_ ( UpperCamelCase__ : list ): '''simple docstring''' if not postfix_notation: return 0 UpperCamelCase__ = {'''+''', '''-''', '''*''', '''/'''} ...
35
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ : Dict = logging.get_logger(__name__) UpperCAmelCase__ : ...
25
from ....configuration_utils import PretrainedConfig from ....utils import logging A : str = logging.get_logger(__name__) # TODO: upload to AWS A : Dict = { "yjernite/retribert-base-uncased": ( "https://huggingface.co/yjernite/retribert-base-uncased/resolve/main/config.json"...
118
0
'''simple docstring''' import os # Precomputes a list of the 100 first triangular numbers A__ : Dict =[int(0.5 * n * (n + 1)) for n in range(1, 1_01)] def UpperCamelCase__ ( ): """simple docstring""" _lowerCAmelCase = ...
220
'''simple docstring''' import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, ...
220
1
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): from tra...
11
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase_ : List[Any] ) -> str: __lowerCamelCase : Tuple = 0 __lowerCamelCase : Optional[int] = len(UpperCAmelCase_ ) for i in range(n - 1 ): for j in range(i + 1 , UpperCA...
185
0
from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class a__ ( snake_case__ ): _a : str = ["""imag...
102
from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_allow_in_graph class ...
102
1
"""simple docstring""" import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) ...
40
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __lowercase = { """configuration_rag""": ["""RagConfig"""], """retrieval_rag""": ["""RagRetriever"""], ""...
40
1
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(">=", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.checkpoint.def...
366
def UpperCamelCase ( _A : str )-> str: """simple docstring""" A__ = "" for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def UpperCamelCase ( _A...
198
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case_ = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} try: if not is_torch_available()...
214
def snake_case__ ( SCREAMING_SNAKE_CASE_ : str = "The quick brown fox jumps over the lazy dog" , ): '''simple docstring''' lowercase__ : str = set() # Replace all the whitespace in our sentence lowercase__ : Tuple = input_str.replace(' ' , ...
214
1
'''simple docstring''' import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel Upper...
246
'''simple docstring''' def lowercase__( __UpperCamelCase: list[list[float]] ): """simple docstring""" SCREAMING_SNAKE_CASE : list[list[float]] = [] for data in source_data: for i, el in enumerate(__UpperCamelCase ): ...
246
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE : Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Tuple ...
21
import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_available, is_vision_available ...
21
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....
205
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging _A = logging.get_logger(__name__) _A = { 'CarlCochet/trajectory-transformer-halfcheetah-medium-v2': ( 'https://huggingface.co/CarlCochet/trajectory-transformer-halfcheetah-...
205
1
import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class SCREAMING_SNAKE_CASE__ : snake_case__ : int = None def SCREAMING_SNAKE_CASE ( self : Optional[int] ) -> Tuple: ...
32
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_mvp import MvpTokenizer...
147
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy lowercase__ = logging.get_logger(__n...
83
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_mod...
83
1
'''simple docstring''' import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_t...
152
'''simple docstring''' import socket def _a( ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Tuple =socket.socket(socket.AF_INET, socket.SOCK_STREAM ) SCREAMING_SNAKE_CASE__ : str =socket.gethostname() ...
152
1
import os # Precomputes a list of the 100 first triangular numbers __lowerCamelCase : Union[str, Any] = [int(0.5 * n * (n + 1)) for n in range(1, 101)] def SCREAMING_SNAKE_CASE ( ): snake_case__ : Optional[int] = os.path.dirname(os.path.realpath(snake_case_ )...
286
__lowerCamelCase : Optional[int] = """Tobias Carryer""" from time import time class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : List[Any] , __A : List[Any] , __A : Optional[int] , __A : List[st...
286
1
'''simple docstring''' import numpy as np import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModelWithProjection, PreTrainedModel from ...utils import logging _SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) class _snake_case ( lowercase_ ...
85
'''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, ) _SCREAMING_SNAKE_CASE : Optional[Any...
85
1
'''simple docstring''' import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig lowerCAmelCase__ = logging.get_logger(__name__) class lowercase_ : """s...
357
'''simple docstring''' import string def _A ( A__ ): """simple docstring""" for key in range(len(string.ascii_uppercase ) ): __lowercase = '''''' for symbol in message: if symbol in string.ascii_uppercase: __lowercase = string.ascii_uppercase.find(A__...
52
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A ={'configuration_plbart': ['PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PLBartConfig...
34
'''simple docstring''' import os from distutils.util import strtobool def snake_case_ (_a : Union[str, Any] , _a : List[Any] ): for e in env_keys: UpperCAmelCase = int(os.environ.get(_a , -1 ) ) if val >= 0: return ...
34
1
"""simple docstring""" import math from collections.abc import Iterator from itertools import takewhile def __snake_case ( SCREAMING_SNAKE_CASE__ : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True ...
358
"""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/LICENSE-...
202
0
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class snake_case ( __lowerCamelCase , __lowerCamelCase ): """simple docst...
53
'''simple docstring''' def __snake_case( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ) -> float: snake_case__ : str = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total def ...
35
0
def SCREAMING_SNAKE_CASE_ ( __magic_name__ : float , __magic_name__ : int ) -> float: """simple docstring""" if digit_amount > 0: return round(number - int(__magic_name__ ) , __magic_name__ ) return number - int(__magic_name__ ) if __name__ == "__main_...
62
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow class _SCREAMING_S...
62
1
"""simple docstring""" import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _SCREAMING...
220
"""simple docstring""" import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node _UpperCamelCase : List[Any] = 4 _UpperCamelCase : Optional[Any] = 3 cla...
220
1
import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class SCREAMING_SNAKE_CASE__ ( tf.keras.layers.Layer ): def __init__( sel...
20
import random def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : list , __SCREAMING_SNAKE_CASE : Optional[int] ): '''simple docstring''' __snake_case , __snake_case , __snake_case : Tuple = [], [], [] for element in data: if element < pivot...
20
1
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate.uti...
102
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import Tokenize...
102
1
import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _snake_case = logging.get_logger(__name__) class UpperCAmelCase_ ( a): lowerCamelCase__ = ['input_ids', 'attention_mask'] ...
364
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP _snake_case = False try: _snake_case = _is_package_available("goo...
300
0
import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPriorPipeline, PriorTransformer,...
244
'''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 tensorflow as tf from transformers import AutoTokenizer, TFAutoMode...
198
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE_:Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:Dict = { """distilbert-bas...
115
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_:Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:Dict = { """BAAI/AltCLIP""": """https://huggingface.co/BAAI/AltCLIP/resol...
115
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator class _UpperCAmelCase : def __init__( self , _A ) -> None: '''simple docstring''' _UpperCAmelCase : Tuple = value ...
246
"""simple docstring""" 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 impor...
246
1
"""simple docstring""" from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class UpperCamelCase_ ( UpperCamelCase__): """simple docstring""" ...
355
"""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, ) if is_sentencepiece_available(): from ..ta...
195
0
class __lowerCAmelCase : def __init__( self , lowerCAmelCase , lowerCAmelCase=None , lowerCAmelCase=None ) -> Dict: '''simple docstring''' _lowercase =data _lowercase =previous _lowercase =next_node ...
205
import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, Be...
205
1
def UpperCamelCase( lowercase_ ) -> bool: '''simple docstring''' if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
34
from __future__ import annotations def UpperCamelCase( lowercase_ , lowercase_ , lowercase_ ) -> dict[str, float]: '''simple docstring''' if (voltage, current, resistance).count(0 ) != 1: raise ValueError("""One and only one argument must be 0""" ) if r...
34
1
'''simple docstring''' def A__ ( UpperCAmelCase_ = 1_0**1_2 ): _UpperCamelCase : str = 1 _UpperCamelCase : Any = 0 _UpperCamelCase : List[str] = 1 _UpperCamelCase : Any = 1 while numerator <= 2 * min_total - 1: prev...
83
'''simple docstring''' import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import j...
83
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCamelCase = {'''processing_layo...
38
"""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 lower...
38
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase_ : str = logging.get_logger(__name__) lowerCamelCase_ : List[Any] ...
286
"""simple docstring""" def UpperCAmelCase__ ( _UpperCAmelCase ): """simple docstring""" if isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(_UpperCAmelCase , _UpperCAmelCas...
286
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase__ : Optional[int] = logging.get_logger(__name__) UpperCamel...
164
'''simple docstring''' def UpperCAmelCase ( a_ , a_ ) -> int: """simple docstring""" A_ : int = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): A_ : Tuple = n - k # Calculate...
164
1
from __future__ import annotations def UpperCAmelCase_ ( __snake_case , __snake_case , __snake_case , __snake_case , __snake_case , ) -> None: """simple docstring""" _lowercase =len(__snake_case ) # If row is equal to the ...
5
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase : Any = { """configuration_electra""": ["""ELECTRA_PRETRAINED_CONF...
52
0
"""simple docstring""" from __future__ import annotations def _lowercase ( __snake_case ,__snake_case ) -> Union[str, Any]: if b == 0: return (1, 0) (__lowerCAmelCase) : List[Any] = extended_euclid(lowerCAmelCase__ ,a % b ) __l...
365
"""simple docstring""" def _lowercase ( __snake_case ) -> int: if not isinstance(__snake_case ,__snake_case ): raise ValueError("Input must be an integer" ) if input_num <= 0: raise ValueError("Input must be positive" ) return sum( ...
58
0
import math from numpy import inf from scipy.integrate import quad def UpperCamelCase_( lowerCamelCase_ ) -> float: if num <= 0: raise ValueError('math domain error' ) return quad(__snake_case , 0 , __snake_case , args=(__snake_case) )[0] def UpperCamelC...
21
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_...
202
0
import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__=5 ): # Adapted from https://github.com/pytorch/fairseq/blob/master/fairseq/models/robe...
194
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxMo...
194
1
def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : int ): __UpperCamelCase =generate_pascal_triangle(SCREAMING_SNAKE_CASE__ ) for row_idx in range(SCREAMING_SNAKE_CASE__ ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): pri...
62
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
62
1
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() lowerCAmelCase :Tuple = logging.get_logger('''transformers.models.speecht5''') def lowerCamelCase ( lowerCAme...
275
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel...
275
1
from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resi...
20
from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets lowercase : str = """\ @inproceedings{wang2019glue, title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding}, author={Wang, Alex and Sing...
20
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase ={ 'configuration_nllb_moe': [ 'NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NllbMoeConfig', ] } try: if not is_torch_available(...
242
'''simple docstring''' import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever lowercase =logging.getLogger(__name__) class __magic_name__ ( lowerCAmelCase ): ...
242
1
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline a__ : Any = logging.get_logger(__name__) # pylint: disable=invalid-name class a_ ( lowerCamelCase__ ): ...
313
from typing import 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 import BatchFeature from ....file_utils import Pa...
300
0
"""simple docstring""" def _lowercase ( __snake_case ) -> int: __lowerCAmelCase : Any = [1] __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase : Tuple = 0, 0, 0 __lowerCAmelCase : int = ugly_nu...
58
"""simple docstring""" __snake_case : Any = [ 999, 800, 799, 600, 599, 500, 400, 399, 377, 355, 333, 311, 288, 266, 244, 222, 200, 199, 177, 155, 133, 111, 88, 66...
58
1
"""simple docstring""" def lowerCamelCase ( _UpperCamelCase : int , _UpperCamelCase : int ) -> str: '''simple docstring''' return "\n".join( f'''{number} * {i} = {number * i}''' for i in range(1 , number_of_terms + 1 ) ...
115
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except Option...
115
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMix...
226
"""simple docstring""" import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # p...
226
1
'''simple docstring''' from maths.prime_check import is_prime def __lowerCamelCase ( lowerCAmelCase_ ) -> int: if not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ): _a : List[str] = f"""Input value of [number={number}] must be an integer""" raise Ty...
89
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient UpperCAmelCase = WebClient(token=os.environ['''CI_SLACK_BOT_TOKEN''']) def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE...
195
0
"""simple docstring""" from collections.abc import Callable import numpy as np def SCREAMING_SNAKE_CASE ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase) -> np.array: a = int(np.ceil((x_end - xa) / step_size)) a = ...
368
from __future__ import annotations def SCREAMING_SNAKE_CASE ( __UpperCamelCase) -> list[int]: a = 2 a = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(__UpperCamelCase) if n...
180
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A =logging.get_logger(__name__) A ={ 'google/fnet-base': 'https://huggingface.co/google/fnet-base/resolve/main/config.json', 'google/fnet-large': 'https://huggingface.co/google/fnet-lar...
34
'''simple docstring''' from __future__ import annotations def snake_case_ (_a : Dict , _a : str , _a : Optional[Any] , _a : List[str] ): # noqa: E741 while r - l > 1: UpperCAmelCase = (l + r) // 2 if v[m] >= key: ...
34
1
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class a_ ( __a ): """simple...
359
import math from collections.abc import Iterator from itertools import takewhile def UpperCAmelCase_( a__ ): """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 ...
19
0
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 ...
38
import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup UpperCAmelCase_ : Any = logging.get_logger(__name__) class _SCREAMI...
38
1
'''simple docstring''' from __future__ import annotations from math import pi, sqrt def _UpperCAmelCase ( _UpperCamelCase : float, _UpperCamelCase : float ) -> tuple: if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) ...
18
'''simple docstring''' from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case : int = logging.get_logger(__name__) __snake_case : str = { 'microsoft/xprophetnet-large-wiki100-cased': ( ...
18
1
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def _A ( lowercase__ , lowercase__=1 ): if n_shave_prefix_segments >= 0: return ".".join(path.split(""".""" )[n_shave_prefix_s...
164
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __A = logging.get_logger(__name__) __A = {"vocab_file": "spm_char.mod...
164
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available...
39
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a__: List[Any] = logging.get_logger(__name__) a__: Optional[Any] = { 'microsoft/unispeech-large-1500h-cv': ( 'https://huggingface.co/microsoft/unispeec...
39
1
'''simple docstring''' from __future__ import annotations import math def _UpperCamelCase ( __A , __A , __A , __A , __A ) -> int: '''simple docstring''' if depth < 0: raise ValueError("Depth cannot be less than 0" ) ...
80
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.se...
58
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_proc...
350
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase__ = { "configuration_mega": ["MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP", "MegaConfig", "MegaOnnxConfig"], } try: if not is_torch_available(): ...
290
0
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ....
194
"""simple docstring""" import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.utils.file_utils import hash_url_to_filename _a = """htt...
194
1
import argparse import datetime def snake_case_(_UpperCamelCase ) -> List[str]: """simple docstring""" _snake_case = { '''0''': '''Sunday''', '''1''': '''Monday''', '''2''': '''Tuesday''', '''3''': '''Wednesday''', '''4''': '''Thursday''', ...
361
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def snake_case_(_UpperCamelCase , _UpperCamelCase , _UpperCamelCase = 1 / sqrt(2 ) ) -> IIRFilter: """simple docstring""" _snake_case = tau * frequency / samplerate _snake_case ...
278
0
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STAND...
275
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class __lowercase (unittest.TestCase ): def UpperCamelCase__ ( self ) ->None: '''simple docstring''' __lowerCAmelCase : ...
275
1
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : int ): """simple docstring""" _snake_case : Optional[Any] = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def UpperCAmelCase__ (snake_case__ : int = 1_00 ): ""...
132
"""simple docstring""" import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin A_ = get_tests_dir(''...
132
1
"""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/licenses/LICENSE-2.0 # ...
242
"""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/LICENSE-2...
242
1
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, ...
56
"""simple docstring""" import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class __a (tf.keras.optimizers.schedules.LearningRateSchedule): ...
56
1
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): ...
58
'''simple docstring''' from collections.abc import Sequence def lowerCamelCase ( __lowerCamelCase : Sequence[float] , __lowerCamelCase : bool = False ) ->float: if not arr: return 0 _SCREAMING_SNAKE_CASE = 0 if allow_empty_subarrays else float("""-...
58
1
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( ...
361
'''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 from transformers i...
106
0
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, r...
226
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_...
226
1
'''simple docstring''' import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( __A , __A ...
369
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import t...
160
0
'''simple docstring''' import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels a__ : Optional[Any] = object() # For specifying empty leaf dict `{}` a__ :...
161
def snake_case ( snake_case__ :str = "The quick brown fox jumps over the lazy dog" , ) -> bool: _A = set() # Replace all the whitespace in our sentence _A = input_str.replace(""" """ , """""") for alpha in input_str: if "a" <= alpha.l...
180
0
"""simple docstring""" from ..models.whisper import WhisperForConditionalGeneration, WhisperProcessor from .base import PipelineTool class __snake_case ( __lowercase): snake_case__ : Optional[Any] = '''openai/whisper-base''' snake_case__ : str = ( '...
361
"""simple docstring""" import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config i...
175
0
'''simple docstring''' import math import sys import cva import numpy as np def a ( __a , __a ) -> np.ndarray: '''simple docstring''' UpperCamelCase__ :Optional[int] = math.sqrt(__a ) UpperCamelCase__ :Tuple = 1 / (sigma * math.sqrt(2 * math.pi ...
97
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils import FrozenDict fro...
19
0
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor _UpperCamelCase = logging.get_logger(__name__) class lowercase ( _UpperCamelCase ): '''simple docstring''' def __init__(self , *__a , **__a ) -> Union[str, Any]...
369
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 ( BnbQuantizationConfig, Compu...
335
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer __lowerCamelCase ...
18
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline, UNetaDConditi...
18
1
"""simple docstring""" import torch from torch import nn class UpperCamelCase_ (nn.Module ): def __init__( self : Optional[int] , lowerCAmelCase_ : Dict , lowerCAmelCase_ : Dict , lowerCAmelCase_ : Dict , lowerCAmelCase_ : Optional[Any] , ...
358
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping lowerCamelCase_ = tuple[int, int] class UpperCamelCase_ : def __init__( self : List[Any] , lowerCAmelCase_ : set[int] , lowerCAmelCase_ : Mapping[EdgeT,...
253
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { '''distilbert-base-uncased''': '''https://huggingface.co/...
39
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 ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set...
39
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'microsoft/unispeech-large-1500h-cv': ( 'https://huggingface.co/microsoft/unispeech-large...
303
"""simple docstring""" 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_modelin...
303
1
def UpperCamelCase ( lowerCAmelCase__ , lowerCAmelCase__ ): '''simple docstring''' if mass < 0: raise ValueError('''The mass of a body cannot be negative''' ) return 0.5 * mass * abs(lowerCAmelCase__ ) * abs(lowerCAmelCase__ ) if __name__ == "__main__": import do...
101
"""simple docstring""" import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex lowercase__ = logging.getLogger(__name__) class __snake_case : def __init__( self) -> ...
290
0
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __lowerCAmelCase : int =logging.get_logger(__name__) class _A ( lowerCAmelCase ): def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ): ...
364
"""simple docstring""" import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def UpperCAmelCase__ ( lowerCAmelCase__ :Any , lowerCAmelCase__ :Optional[Any] , lowerCAmelCase__ :Dict , lowerCAmelCase__ :Any ) ->...
32
0
def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ) -> int: return int(input_a == input_a == 0 ) def A ( ) -> None: print("Truth Table of NOR Gate:" ) print("| Input 1 | Input 2 | Output |" ) print(f'''| 0 | 0 ...
48
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAva...
278
0
import argparse from collections import defaultdict def UpperCamelCase (lowercase_: List[str] , lowercase_: Optional[int] , lowercase_: Optional[Any] , lowercase_: Union[str, Any] , lowercase_: Any ) -> int: A__ : Optional[Any] = f"""{file}_{class_name}...
141
from typing import Any def UpperCamelCase (lowercase_: list ) -> list[Any]: if not input_list: return [] A__ : Any = [input_list.count(lowercase_ ) for value in input_list] A__ : List[Any] = max(lowercase_ ) # Gets the maximum count in the input list. # G...
141
1
"""simple docstring""" import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def _lowercase ( __lowerCAmelCase ) -> int: SCREAMI...
132
"""simple docstring""" import os import sys a :Union[str, Any] = os.path.join(os.path.dirname(__file__), "src") sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoModelForSequ...
132
1
def _A ( lowerCAmelCase_ : List[Any] ): """simple docstring""" lowerCAmelCase__ = [] lowerCAmelCase__ = set({"(", "[", "{"} ) lowerCAmelCase__ = set({")", "]", "}"} ) lowerCAmelCase__ = {'''{''': '...
365
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# UpperCamelCase = [ # (stable-diffusion, HF Diffusers) ('time_embed.0.weight', 'time_embedding.linea...
221
0
'''simple docstring''' import os import sys a : str = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, AutoModelForSequenceCla...
56
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_ax...
56
1
'''simple docstring''' from collections.abc import Sequence def _A ( _lowerCAmelCase , _lowerCAmelCase ): """simple docstring""" return sum(c * (x**i) for i, c in enumerate(_lowerCAmelCase ) ) def _A ( _lowerCAmelCase , _lowerCAmelCase ): ...
357
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase =SwinConfig(image_size=192 ) ...
48
0
'''simple docstring''' 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 f...
344
"""simple docstring""" __UpperCamelCase : Optional[Any] = [ 9_9_9, 8_0_0, 7_9_9, 6_0_0, 5_9_9, 5_0_0, 4_0_0, 3_9_9, 3_7_7, 3_5_5, 3_3_3, 3_1_1, 2_8_8, 2_6_6, 2_4_4, 2_2_2, 2_0_0, 1_9_9, 1_7_7, 1_5_5, 1_3_3, ...
106
0
# 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...
196
def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ) -> Any: # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) UpperCamelCase__ : int = (boundary[1] - boundary[0]) / steps UpperCamelCase__ : Optional[An...
196
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { '''configuration_xlm_roberta_xl''': [ '''XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMRobertaXLConfig''', '''XLMRobertaXLOnnxConfig''', ...
340
"""simple docstring""" def __A ( a_ :int = 60_08_51_47_51_43) -> int: try: __a : List[Any] = int(a_) except (TypeError, ValueError): raise TypeError('''Parameter n must be int or castable to int.''') if n <= 0: raise V...
160
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowercase ( _UpperCAmelCase ): lowercase__ : List[str] = ["image_processor", "tokenizer"] lowercase__ : int = "ViTImag...
352
# 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...
206
0
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, ...
52
import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replic...
175
0
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers.testing_utils i...
259
"""simple docstring""" from __future__ import annotations import time A : Union[str, Any] = list[tuple[int, int]] A : int = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, ...
259
1