code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from transformers import FSMTTokenizer, FSMTConfig, FSMTForConditionalGeneration _lowerCAmelCase : Optional[int] = '''facebook/wmt19-en-de''' _lowerCAmelCase : Optional[Any] = FSMTTokenizer.from_pretrained(mname) # get the correct vocab sizes, etc. from the master mode...
454
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { 'Intel/dpt-large': 'https://huggingface.co/Intel/dpt-large/r...
560
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_avai...
319
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __lowerCAmelCase = { """configuration_squeezebert""": [ """SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Sque...
319
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 ...
599
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { ...
277
0
"""simple docstring""" from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean __lowerCAmelCase = 0 __lowerCAmelCase = [ [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,...
708
"""simple docstring""" import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class _lowerCAmelCase ( nn.Module ): __lowerCAmelCase : int __lowerCAmelCase ...
396
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_ava...
46
def lowerCAmelCase ( UpperCAmelCase, UpperCAmelCase ) ->list: """simple docstring""" __magic_name__ : Optional[Any] = word.split() def justify(UpperCAmelCase, UpperCAmelCase, UpperCAmelCase ) -> str: __mag...
154
0
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, TFAutoModelForSeqaSeqLM @req...
576
from collections.abc import Sequence def __lowercase ( _UpperCAmelCase = None ) -> int: '''simple docstring''' if nums is None or not nums: raise ValueError("Input sequence should not be empty" ) __lowercase = nums[0] for i in range(1 , len(_UpperCAmelCase ) ): __lowerc...
576
1
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from ....
64
'''simple docstring''' from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class a__ ( nn.Module ): def __init__(self : Union[str, Any], __UpperCAmelCase : int = 16, __UpperCAmelCase : int = 88, ...
507
0
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, is_torch_available, ) from . import B...
144
import math UpperCamelCase = 1_0 UpperCamelCase = 7 UpperCamelCase = BALLS_PER_COLOUR * NUM_COLOURS def _a ( lowerCamelCase__ = 20 ) -> str: lowerCamelCase_ : List[str] = math.comb(lowerCamelCase__ , lowerCamelCase__ ) lowerCamelCase_ ...
144
1
import copy import random from transformers import CLIPTokenizer class A_ ( UpperCAmelCase ): """simple docstring""" def __init__( self : Optional[Any] ,*__A : Any ,**__A : Tuple ) -> Dict...
67
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class A_ ( unittest.TestCas...
67
1
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _a( UpperCamelCase__ : NDArray[floataa], UpperCamelCase__ : NDArray[floataa], UpperCamelCase__ : list[int], UpperCamelCase_...
665
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _a( UpperCamelCase__ : NDArray[floataa], UpperCamelCase__ : NDArray[floataa], UpperCamelCase__ : list[int], UpperCamelCase_...
665
1
import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, PixaSt...
258
def lowerCAmelCase_ ( __a , __a ) -> str: """simple docstring""" SCREAMING_SNAKE_CASE : list[list[str]] =[[] for _ in range(__a )] SCREAMING_SNAKE_CASE : Any =key - 1 if key <= 0: ...
258
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCamelCase : int = { ...
417
'''simple docstring''' 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 ...
417
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import YolosConfig, YolosForObjectDetection, YolosImageProcessor from transformers.utils import logging logging.set_...
93
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version __A = { """<""": operator.lt, """<=""": operator.le, """==""": operator.eq, """!=""": operator.ne, """>=""": operator.ge, "...
93
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) if is_sentencepiece_available(): from ..ta.t...
51
"""simple docstring""" def lowercase__ ( lowercase_ ,lowercase_ ) -> None: """simple docstring""" _UpperCamelCase : List[Any] = len(lowercase_ ) print("The following activities are selected:" ) # The first activity is always selected _U...
51
1
from typing import List import numpy as np def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ) -> int: SCREAMING_SNAKE_CASE_ : Dict = {key: len(SCREAMING_SNAKE_CASE ) for key, value in gen_kwargs.items() if isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE )} if len(set(lists_leng...
345
import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets lowerCAmelCase__: int = datasets.logging.get_logger(__name__) lowerCAmelCase__: Optional[int] = "\\n@InProceedings{moosavi...
345
1
'''simple docstring''' import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": UpperCAmelCase_ : int = '%20'.join(argv[1:]) if len(argv) > 1 else quote(str(input...
708
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def A_ ( _lowerCAmelCase : Union[str, Any] ): """simple docstring""" if "img_encoder.pos_embed" in name: ...
11
0
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 _lowercase : Union[str, Any] =collections.namedtuple('''_Datasets'...
305
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() a : Dict = logging.get_logger(__name__) a : Tuple = [ ["attention", "attn"], ...
63
0
def _lowerCAmelCase ( lowerCamelCase__ : int, lowerCamelCase__ : int ) -> bool: return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
708
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import...
295
0
'''simple docstring''' import argparse import json from typing import List from ltp import LTP from transformers.models.bert.tokenization_bert import BertTokenizer def A (__lowerCamelCase :List[str] ): # This defines a "chinese character" as anything in the CJK Unicode block: # https://en.wik...
5
"""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) UpperCAmelCase__ = models.Seque...
224
0
import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.utils import logging lo...
713
from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_form...
75
0
class A : '''simple docstring''' def __init__(self : Any , _UpperCAmelCase : str = "" , _UpperCAmelCase : bool = False ) -> None: """simple docstring""" lowercase__ = {} # A node will be a leaf if the...
15
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TOKEN, USER, get...
493
0
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def __lowerCAmelCase ( __magic_name__ ): _lowercase: Dict = [] _lowercase: List[str] = [] _lowercase: int = ...
206
def __lowerCAmelCase ( __magic_name__ ): return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('Program to check whether a number is a Perfect number or not...') _SCREAMING_SNAKE_CASE : str = int(input(...
206
1
class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : Dict ): SCREAMING_SNAKE_CASE : Optional[int] = {} def _A ( self : str ): print(self.vertex ) for i in self.vertex: ...
62
import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments a : Optional[int] = logging.getLogger(__name__) @dataclass class _a ( _lowerCAmelCase ...
556
0
def lowerCAmelCase_ ( __UpperCAmelCase: Optional[Any] ) -> Any: stooge(__UpperCAmelCase , 0 , len(__UpperCAmelCase ) - 1 ) return arr def lowerCAmelCase_ ( __UpperCAmelCase: int , __UpperCAmelCase: str , __UpperCAmelCase: Union[str...
369
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_conf...
369
1
import sys __A = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "66896648950445244523161731856403098711121722383113" ...
68
"""simple docstring""" import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { '''kakaobrain/alig...
52
0
from collections import deque from .hash_table import HashTable class SCREAMING_SNAKE_CASE__ ( __UpperCamelCase ): def __init__( self : str , *_lowerCAmelCase : str , **_lowerCAmelCase : Union[str, Any] ): super().__init__(*_lowerCAmelCase , **_lowerCAm...
720
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTes...
390
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Optional[int] = logging.get_logger(__name__) _UpperCAmelCase : Optional[Any] = { '''tanreinama/GPTSAN-2.8B-spout_is_uniform''': ( '''https://huggingface.co/tanreinama/GPTSAN...
72
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_...
651
0
'''simple docstring''' from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_av...
700
'''simple docstring''' def A_ ( SCREAMING_SNAKE_CASE_ ) ->int: if not isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): raise ValueError("""multiplicative_persistence() only accepts integral values""" ) if num < 0: raise ValueError("""multiplicative_persistence() does not accept n...
603
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, require_t...
569
'''simple docstring''' import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": snake_case_ = argparse.ArgumentParser() parser.add_argument( '--chec...
421
0
'''simple docstring''' from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = {"vo...
710
'''simple docstring''' import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor _lowerCAmelCase = logging.get_logger(__name__) class __A ( a ): """simple docstring""" def __init__( self ...
318
0
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_ut...
572
'''simple docstring''' import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 _lowerCAmelCase = 0B10_11_00_11_11_10_11_00_10_01_00_00_...
432
0
# Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
719
import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils imp...
375
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case ...
200
"""simple docstring""" import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py __snake_case = 'src/transfor...
200
1
"""simple docstring""" from string import ascii_lowercase, ascii_uppercase def __lowerCamelCase ( SCREAMING_SNAKE_CASE ) -> Optional[Any]: """simple docstring""" if not sentence: return "" _UpperCAmelCase = dict(zip(lowerCAmel...
703
"""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...
494
0
import functools def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ) -> int: # Validation if not isinstance(__lowerCAmelCase , __lowerCAmelCase ) or not all(isinstance(__lowerCAmelCase , __lowerCAmelCase ) for day in days ): rais...
33
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor __A = logging.get_logger(__name__) class lowerCamelCase__ ( lowerCamelCase_ ): def __init__( self , *SCREAMING_SNAKE_CASE ...
134
0
'''simple docstring''' import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def a_ ( lowerCamelCase : Union[dict,...
513
'''simple docstring''' import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput __snake_case ="""scheduler_config.json""" class UpperCAmelCase_ ( __lowercase...
513
1
import requests from bsa import BeautifulSoup def UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): lowercase = BeautifulSoup(requests.get(__SCREAMING_SNAKE_CASE , params=__SCREAMING_SNAKE_CASE ).content , 'html.parser' ) lowercase = ...
84
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet ...
108
0
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
517
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device _SCREAMING_SNAKE_CASE = False cla...
517
1
def UpperCAmelCase ( UpperCAmelCase )-> int: '''simple docstring''' if not isinstance(UpperCAmelCase ,UpperCAmelCase ): raise TypeError('''Input value must be an \'int\' type''' ) SCREAMING_SNAKE_CASE_ = 0 while number: position += ...
393
import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline, ) from transformers.testi...
393
1
'''simple docstring''' import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def lowerCamelCase( a__): _SCREAMING_SNAKE_CASE =[ '''decoder.version''', '''decoder.output_projection.weight''', ...
712
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def lowerCamelCase( a__ ,a__=() ,a__=None ,a__="no" ,a__="29500"): _SCREAMING_SNAKE_CASE =False _SCREAMING_SNAKE_C...
191
0
'''simple docstring''' import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def _a ( __lo...
347
'''simple docstring''' def _a ( __lowerCAmelCase : int , __lowerCAmelCase : int ): """simple docstring""" return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
347
1
"""simple docstring""" import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ...
709
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when swi...
275
0
def _UpperCAmelCase (UpperCamelCase__ : List[Any] = 1000000 ): _A : Any = [i - 1 for i in range(limit + 1 )] for i in range(2 , limit + 1 ): if phi[i] == i - 1: for j in range(2 * i , limit + 1 , UpperCame...
503
'''simple docstring''' import numpy as np def __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> str: __lowerCamelCase = int(np.ceil((x_end - xa) / h ) ) ...
546
0
'''simple docstring''' def __lowerCamelCase ( __snake_case : int = 3, __snake_case : int = 7, __snake_case : int = 1_000_000 ) -> int: """simple docstring""" A__ : int =0 A__ : Tuple =1 for current_denominator in range(1, limit + 1 ):...
687
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from .vae import Decode...
687
1
'''simple docstring''' from collections.abc import Callable import numpy as np def a_ ( __snake_case : Callable , __snake_case : float , __snake_case : float , __snake_case : float , __snake_case : float ) -> np.ndarray: """simple docstrin...
676
'''simple docstring''' import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging a_ :...
676
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { "funnel-transformer/small": "https://huggingface.co/funnel-transformer/small/resolve/main/config.json", "funnel-transformer/small-base": "https://huggingface.co/funnel...
721
from queue import PriorityQueue from typing import Any import numpy as np def lowerCAmelCase__(__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,__snake_case ,) -> float | int: '''simple docstring''' for nxt, d in graph[v]...
29
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowercase : Optional[int] = { 'config...
49
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import BitConfig...
130
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ =logging.get_logger(__name__) UpperCAmelCase__ ={ "microsoft/swinv2-tiny-patch4-window8-256": ( "https://huggingface.co/microsoft/swinv2-tiny-patch4-wi...
708
"""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 if is_torch_available()...
442
0
'''simple docstring''' def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ) -> bool: UpperCAmelCase__ : Dict = len(lowerCAmelCase__ ) + 1 UpperCAmelCase__ : Union[str, Any] = len(lowerCAmelCase__ ) + 1 # dp is a 2d matrix where dp[i][j...
75
'''simple docstring''' from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _lowercase = logging.get_logger(__name__) def __UpperCamelCase ( a : Union[tf.Tensor, np.ndarray] ) ->List[in...
342
0
"""simple docstring""" from collections.abc import Sequence from queue import Queue class __lowercase : '''simple docstring''' def __init__( self , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase=None , _Uppe...
101
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=_UpperCamelCase ) class __lowercase ( _UpperCamelCase ): ...
101
1
'''simple docstring''' def a_ ( UpperCamelCase_ , UpperCamelCase_ ): return 1 if input_a == input_a else 0 def a_ ( ): assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ) == 0 assert xnor_gate(1 ...
452
'''simple docstring''' import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def a_ ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): ...
452
1
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...f...
707
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): """simple docstring""" if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 a...
302
0
# 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 required by applic...
647
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_logg...
647
1
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 from ..image_utils im...
703
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, ) SCREAMING_SNAKE_CASE__ = { """configuration_bert""": ["""B...
688
0
import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class UpperCamelCase_ ( UpperCAmelCase__ ): '''simple docstring''' ...
87
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("""Googling.....""") A_ : List[str] ="""https://www.google.com/search?q=""" + """ """.join(sys.argv[1:]) A_ : int =r...
483
0
import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def lowerCamelCase__ ( a : Tuple ) -> Union[str, Any]: """simple docstring"""...
718
import datasets from .evaluate import evaluate snake_case__ = '''\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={EMNLP}, year={2016} } ''' snake...
373
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer a__ : int = logging.get_logger(__name__) a__ : in...
188
# Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar a__ : Optional[int] = TypeVar('T') class UpperCAmelCase_ ( Generic[T] ): def __init__( ...
188
1
"""simple docstring""" import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab ...
720
"""simple docstring""" from __future__ import annotations from math import pow, sqrt def lowercase ( A_ , A_ , A_ )-> dict[str, float]: '''simple docstring''' if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError("One ...
135
0
from __future__ import annotations class _a : """simple docstring""" def __init__( self : Dict , UpperCAmelCase : int ): A_ = order # a_{0} ... a_{k} A_ = [1.0] + [0.0] * order # b_{...
86
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, E...
86
1
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __lowerCamelCase ( lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" lowercase__ : List[str] = F"""{sampling_rate}""" lowercase__ : ...
715
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''huggingface/informer-tourism-monthly''': ( '''https://huggingface.co/huggingface/i...
81
0
from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { 's-JoL/Open-Llama-V1': 'https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json', } class UpperCamelCase__ ( __magic_name__ ): __SCREAMING_SN...
412
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, ComputeEnvironment, ...
412
1
"""simple docstring""" from __future__ import annotations import pandas as pd def __snake_case ( SCREAMING_SNAKE_CASE: list[int] , SCREAMING_SNAKE_CASE: list[int] , SCREAMING_SNAKE_CASE: int ): """simple docstring""" _lowerCAmelC...
491
"""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 if is_torch_available()...
491
1
'''simple docstring''' import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, Pi...
78
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a : Optional[Any] = { """configuration_distilbert""": [ "...
606
0
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from .....
716
import math import qiskit def _lowerCamelCase ( _a = 1 , _a = 1 , _a = 1 ): """simple docstring""" if ( isinstance(_a , _a ) or isinstance(_a , _a ) or isinstance(_a , _a ) ): raise TypeError('''inputs must be integers.''' ) ...
297
0
'''simple docstring''' from manim import * class a_ ( UpperCAmelCase__ ): def lowercase__ ( self : Optional[int] ): __snake_case = Rectangle(height=0.5 , width=0.5 ) __snake_case = Rectangle(height=0.46 , width=0.46 )....
356
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class a_ ( unittest.TestCase ): def lowercase__ ( self...
356
1
'''simple docstring''' def snake_case__ ( _A: List[str] , _A: Tuple , _A: int , _A: Dict , _A: Tuple , _A: Optional[Any] ) -> Any: '''simple docstring''' if index == r: for j in range(_A ): print(data[j] , ...
605
'''simple docstring''' from __future__ import annotations import time __lowercase = list[tuple[int, int]] __lowercase = [ [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, 0, 0, 0, 0], [1, 0, 1, ...
605
1
import requests def _SCREAMING_SNAKE_CASE ( lowercase : str , lowercase : str ): '''simple docstring''' lowerCamelCase_ = {'Content-Type': 'application/json'} lowerCamelCase_ = requests.post(lowercase , json={'...
70
"""simple docstring""" from __future__ import annotations import queue class lowercase__ : def __init__( self , SCREAMING_SNAKE_CASE) -> int: _lowerCamelCase : int = data _lowerCamelCase : List[str] = None _lowerCamelCase : Any ...
88
0
'''simple docstring''' import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _a = logging.get_logger(__name__) _a = { "vocab_file": "vocab.json", "merges_file": "merges.txt", } ...
711
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils import loggin...
29
0
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) SCREAMING_...
79
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Any = { """huggingface/informer-tourism-monthly""": ( ...
79
1
from __future__ import annotations def lowerCamelCase_ ( UpperCamelCase__ : list[float], UpperCamelCase__ : int ): '''simple docstring''' print(F"""Vertex\tShortest Distance from vertex {src}""" ) for i, d in enumerate(UpperCamelCase__ ): ...
591
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers imp...
591
1
"""simple docstring""" import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_f...
505
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer UpperCamelCase : str = logging.ge...
690
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet impor...
712
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attention_paths, ren...
207
0
'''simple docstring''' import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def a__ ( lowercase : Any, lowercase : Dict, lowercase : str ) -> Dict: ...
98
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : str ,_UpperCAmelCase : str ) -> list: _a : Tuple =len(_UpperCAmelCase ) _a : str =[] for i in range(len(_UpperCAmelCase ) - pat...
694
0
'''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 snake_case ( a_ ...
703
'''simple docstring''' # Lint as: python3 import itertools import os import re UpperCamelCase =re.compile(R"([A-Z]+)([A-Z][a-z])") UpperCamelCase =re.compile(R"([a-z\d])([A-Z])") UpperCamelCase =re.compile(R"(?<!_)_(?!_)") UpperCamelCase =re.compile(R"(_{2,})") UpperCamelCase =...
543
0
"""simple docstring""" import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table im...
115
"""simple docstring""" from __future__ import annotations def A_ (__a ): '''simple docstring''' A_ = 0.00 A_ = 0 for resistor in resistors: if resistor <= 0: A_ = f'Resistor at index {index} has a negative or zero value!' ...
115
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ = { "configuration_llama": ["LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP", "LlamaConfig"]...
703
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, ) SCREAMING_SNAKE_CASE__ = { """configuration_bert""": ["""B...
688
0
"""simple docstring""" import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, T...
76
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch...
431
0
from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = "T5Config" class __magic_name__ ( _a): _UpperCAmelCase ...
713
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __magic_name__ ( _a): @require_torch def _UpperCAmelCase ( self : Tuple ): # this test is a bit tricky since TRAN...
405
0
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( Aud...
75
from ...configuration_utils import PretrainedConfig from ...utils import logging A : Optional[int] = logging.get_logger(__name__) A : Dict = { '''vinvino02/glpn-kitti''': '''https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json''', # See all GLPN mod...
176
0
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black lowerCAmelCase__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) imp...
6
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_uti...
6
1
"""simple docstring""" def __lowerCamelCase ( a_ : str ) -> bool: return credit_card_number.startswith(('''34''', '''35''', '''37''', '''4''', '''5''', '''6''') ) def __lowerCamelCase ( a_ : str ) -> bool: __SCREAMING_SNAKE_CASE :Dict =...
498
"""simple docstring""" from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBacken...
498
1
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def A ( A_ : Dict , A_ : Optional[Any]=False ): snake_case : List[Any] = OmegaConf.load(__UpperCAmelCase ) if display: ...
713
'''simple docstring''' from __future__ import annotations import math def A ( A_ : int ): if num <= 0: snake_case : List[Any] = F"""{num}: Invalid input, please enter a positive integer.""" raise ValueError(A_ ) snake_case ...
555
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A__: Optional[Any] = { '''configuration_table_transformer''': [ '''TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
694
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : int ) -> int: if n == 1 or not isinstance(_UpperCAmelCase ,_UpperCAmelCase ): return 0 elif n == 2: return 1 else: _a ...
694
1
import math def SCREAMING_SNAKE_CASE__ ( __a , __a ): return math.pow(__a , 2 ) - a def SCREAMING_SNAKE_CASE__ ( __a ): return 2 * x def SCREAMING_SNAKE_CASE__ ( __a ): snake_case_ : List[Any] = 2.0 while start <=...
534
import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class SCREAMING_SNAKE_CASE_ ( unitt...
534
1
import datasets from .evaluate import evaluate _lowercase = '''\ @article{hendrycks2021cuad, title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review}, author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball}, journal={arXiv preprint arXiv:2103.06268}, y...
659
import os _lowercase = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 100, '''D''': 500, '''M''': 1000} def UpperCamelCase ( snake_case__): lowerCAmelCase_ : List[str] = 0 lowerCAmelCase_ : Any = 0 while index < len(snake_case__) - 1: ...
659
1
"""simple docstring""" from __future__ import annotations import math def _a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> int: if depth < 0: raise ValueError("""Depth canno...
2
"""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() __SCREAMING_SNAKE_CASE : str = logging.get_logger(__name__) __...
2
1
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrateg...
47
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _lowerCamelCase = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailabl...
6
0
"""simple docstring""" from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torc...
703
"""simple docstring""" lowercase_ = 8.31_4462 # Unit - J mol-1 K-1 def lowerCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): """simple docstring""" if moles < 0 or kelvin < 0 or volume < 0: raise ValueError('''Invalid inputs. Enter positiv...
215
0
"""simple docstring""" import os # Precomputes a list of the 100 first triangular numbers __magic_name__ : Tuple = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def UpperCamelCase (): UpperCamelCase : List[Any] = os.path.dirname(os.path.realpath...
102
def _lowerCamelCase ( __A : int ) -> str: _UpperCAmelCase : Tuple = int(__A ) if decimal in (0, 1): # Exit cases for the recursion return str(__A ) _UpperCAmelCase , _UpperCAmelCase : int = divmod(__A , 2 ) ...
485
0
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast 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 TokenizerTesterMixin lowerCame...
161
import unittest import numpy as np def UpperCamelCase( lowercase_ , lowercase_ , lowercase_ , lowercase_ = None , ) -> np.ndarray: '''simple docstring''' snake_case_ = np.shape(lowercase_ ) snake_case_ = np.shape(lowercase_ ) ...
161
1
from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging lowerCam...
228
from PIL import Image def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ) -> Image: def brightness(__lowerCAmelCase ) -> float: return 128 + level + (c - 128) if not -2_5_5.0 <= level <= 2_5_5.0: raise Va...
228
1
import math def lowercase_ ( _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' if ( not isinstance(_UpperCamelCase , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError('''power_factor must be a valid float v...
711
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_=2 , snake_case_=3 , snake_case_=6_4 , snake_case_=Non...
527
0
'''simple docstring''' import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( 'kwargs, expected' , [ ({'num_shards': 0, 'max_num_jobs': 1}, []), ({'num_shards': 10, 'm...
430
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import...
430
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor UpperCAmelCase__ = logging.get_logger(__name__) class a ( _UpperCAmelCase ): def __init__( self : List[str] , *__lowerCAmelCase : List[Any] , ...
704
"""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__ = { """shi-labs/nat-mini-i...
275
0
import argparse import json import subprocess def lowercase__ ( __snake_case : str , __snake_case : Any ): '''simple docstring''' UpperCAmelCase_ : List[Any] = [] UpperCAmelCase_ : str = ( F"curl -H \"Accept: appl...
406
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig __A : List[str] = logging.get_logger(__name__) __A : Optional[Any] = { '''Intel/dpt-large''': '''https://huggingface.co/Intel/dpt-large/resolve/main/config.json''', ...
343
0
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def UpperCamelCase__ ( ): '''simple docstring''' __lowerCamelCase = [randint(-1000 , 1000 ) for i in range(10 )] ...
704
from ...processing_utils import ProcessorMixin class UpperCamelCase_ ( __UpperCamelCase ): """simple docstring""" A = ['''image_processor''', '''feature_extractor'''] A = '''TvltImageProcessor''' A = '''TvltFeatureExtractor''' def __init__( self ,...
571
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available lowerCAmelCase__ = { 'configuration_audio_spectrogram_transformer': [ 'AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIV...
621
"""simple docstring""" 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 fro...
621
1
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __magic_name__( _A ): '''simple docstring''' ...
719
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar lowerCamelCase_ : List[str] = TypeVar('''T''') lowerCamelCase_ : Optional[int] = TypeVar('''U''') class _SCREAMING_SNAKE_CASE ( Generic[T, U] ...
265
0
from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def UpperCAmelCase__( __UpperCAmelCase : float , __UpperCAmelCase : float , __UpperCAmelCase : bool = False ): if radian_mode: r...
576
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np __magic_name__ = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 __magic_name__ = typing.Union[np.floataa, int, float] # noqa: UP007 def Upper...
576
1
import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is_soundfile_availble, is...
567
import unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_i...
567
1