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
"""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 ...
61
'''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""" from ..utils import DummyObject, requires_backends class __lowerCAmelCase ( metaclass=__SCREAMING_SNAKE_CASE ): lowercase = ["transformers", "torch", "note_seq"] def __init__( self , *__UpperCAmelCase , **__UpperCAmelCase ): ...
263
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( snake_case :Dict , snake_case :Optional[Any] , snake_case :List[Any] ) -> Optional[Any]: __UpperCamelCase = OmegaConf...
263
1
def _a ( UpperCamelCase_ : int ) -> int: """simple docstring""" lowerCAmelCase__ = abs(UpperCamelCase_ ) lowerCAmelCase__ = 0 while n > 0: res += n % 10 n //= 10 return res def _a ( ...
340
from collections import UserDict 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 Im...
340
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffuser...
254
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_commo...
254
1
'''simple docstring''' def A__ ( UpperCAmelCase_ = 3 , UpperCAmelCase_ = 7 , UpperCAmelCase_ = 1_0_0_0_0_0_0 ): _UpperCamelCase : Optional[Any] = 0 _UpperCamelCase : Tuple = 1 for current_denominator in range(1 , limit + 1 ): _UpperCamelC...
83
'''simple docstring''' import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class lowercase ( unittest.TestCase , _lowerCamelCase ): """simple docstring""" def _snake_case ( self ) -> Any: _UpperCAmelCase ...
215
0
lowercase__ :Any = "\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https://github.com/huggingface/transformers.git\...
350
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, BertEmbeddings, BertLayer, ...
97
0
lowerCAmelCase__ = { 'a': 'AAAAA', 'b': 'AAAAB', 'c': 'AAABA', 'd': 'AAABB', 'e': 'AABAA', 'f': 'AABAB', 'g': 'AABBA', 'h': 'AABBB', 'i': 'ABAAA', 'j': 'BBBAA', 'k': 'ABAAB', 'l': 'ABABA', 'm': 'ABABB', 'n': 'ABBAA', 'o': 'ABBAB', 'p': 'ABBBA', ...
11
'''simple docstring''' import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokeni...
211
0
"""simple docstring""" from collections import namedtuple lowercase_ = namedtuple("from_to", "from_ to") lowercase_ = { "cubicmeter": from_to(1, 1), "litre": from_to(0.001, 1_0_0_0), "kilolitre": from_to(1, 1), "gallon": from_to(0.00454, 264.172), "cubicyard": from_to(...
359
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin lowercase_ = "\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed...
11
0
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __snake_case ( UpperCamelCase_ ): _a = ['''image_processor''', '''tokenizer'''] _a = '''AutoImageProcessor''' _a = '''AutoTokenizer''' ...
103
# flake8: noqa # Lint as: python3 A : Optional[Any] = [ 'VerificationMode', 'Version', 'disable_progress_bar', 'enable_progress_bar', 'is_progress_bar_enabled', 'experimental', ] from .info_utils import VerificationMode from .logging import disable_progress_bar, enable_progress_bar, is_...
6
0
from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :NDArray[floataa] , SCREAMING_SNAKE_CASE :NDArray[floataa] , SCREAMING_SNAKE_CASE :list[int] , SCREAMING_S...
361
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :list[int] ) -> int: if not numbers: return 0 if not isinstance(SCREAMING_SNAKE_CASE , (list, tuple) ) or not all( isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) for number in numbers ): raise ValueError("""numbe...
232
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCAmelCase : List[Any] = logging.get_logger(__name__) __lowerCAmelCase : int = { "distilbert...
156
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase_ ) class __lowerCAmelCase ( lowerCAmelCase_ ): """simple docstring""" ...
156
1
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments...
358
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block ...
221
0
"""simple docstring""" import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import Accele...
17
"""simple docstring""" from __future__ import annotations from typing import Any class _lowerCAmelCase : """simple docstring""" def __init__( self : Any, UpperCAmelCase__ : int ): __lowercase = num_of_nodes __lowercase = [] __lo...
17
1
from ... import PretrainedConfig lowerCAmelCase = { '''sijunhe/nezha-cn-base''': '''https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json''', } class A ( A_ ): UpperCamelCase_ : Optional[int] =NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP UpperCamelCase_ ...
304
from typing import Any import numpy as np def _lowerCamelCase( lowercase__ ) -> bool: '''simple docstring''' return np.array_equal(lowercase__ , matrix.conjugate().T ) def _lowerCamelCase( lowercase__ , lowercase__ ) -> Any: '''sim...
304
1
from ....configuration_utils import PretrainedConfig from ....utils import logging __lowerCamelCase : Dict = logging.get_logger(__name__) __lowerCamelCase : Optional[int] = { """CarlCochet/trajectory-transformer-halfcheetah-medium-v2""": ( """https://huggingface.co/C...
52
"""simple docstring""" from __future__ import annotations def lowercase ( _snake_case : int | str ) ->bool: """simple docstring""" __snake_case : List[str] = str(_snake_case ) return n == n[::-1] def lowercase ( _snake_case : in...
102
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase : List[Any] = {"""configuration_vit_msn""": ["""VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ViTMSNConfig"""]} try: if not is_torch_available(): raise ...
140
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() __lowerCamelCase : Dict = logging.get_logger("""transformers.models.speecht5""") def A_ ( _lowerCAmelCase , _lowerCAmelCase ...
140
1
import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline lowercase_ : Any = version.parse(version.parse(torch.__versi...
133
"""simple docstring""" # flake8: noqa # Lint as: python3 _UpperCAmelCase = [ """VerificationMode""", """Version""", """disable_progress_bar""", """enable_progress_bar""", """is_progress_bar_enabled""", """experimental""", ] from .info_utils import VerificationMode from .l...
173
0
"""simple docstring""" from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase = {"""configuration_van""": ["""VAN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """VanConfig"""]} try: if not is_torch_available(): r...
54
"""simple docstring""" def lowercase ( a__ : Tuple , a__ : str ) -> Tuple: return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def lowercase ( a__ : Optional[int] , a__ : List[str]=0 ) -> Optional[Any]: return ...
54
1
from __future__ import annotations from typing import Any def SCREAMING_SNAKE_CASE ( lowercase_ ) -> None: """simple docstring""" create_state_space_tree(lowercase_ , [] , 0 ) def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lower...
14
from ...processing_utils import ProcessorMixin class UpperCamelCase_ ( UpperCAmelCase__ ): '''simple docstring''' UpperCAmelCase__ = '''SpeechT5FeatureExtractor''' UpperCAmelCase__ = '''SpeechT5Tokenizer''' def __init__( self : Any , UpperC...
14
1
import heapq as hq import math from collections.abc import Iterator class _A : def __init__( self : Optional[int] , _A : List[Any] ) -> Union[str, Any]: """simple docstring""" lowercase : Any = str(id_ ...
369
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 ): ...
116
0
"""simple docstring""" def UpperCAmelCase ( UpperCAmelCase , UpperCAmelCase ) -> str: if not (isinstance(UpperCAmelCase , UpperCAmelCase ) and isinstance(UpperCAmelCase , UpperCAmelCase )): raise ValueError('longest_common_substring() takes two s...
69
"""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, BatchEncoding, PreTrainedTokenizer from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __Up...
69
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCAmelCase :str = { 'configuration_rembert': ['REMBERT_PRE...
371
"""simple docstring""" from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def lowerCamelCase_ (): _UpperCAmelCase : int = HfArgumentParser(UpperCamelCase__ ) _UpperCAmelCase : Optional[Any] = parser.parse_args...
68
0
'''simple docstring''' import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torc...
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 __future__ import annotations from random import choice def _A (lowerCAmelCase__ :Optional[int] ) -> int: '''simple docstring''' return choice(lowercase_ ) def _A (lowerCAmelCase__ :lis...
357
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class a ( unittest.TestCase ): def __UpperCAmelCase ( self ) -> int: _a = [ 'safety_checker/pytorch_model.bin...
104
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __SCREAMING_SNAKE_CASE :List[str] = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE :Li...
22
'''simple docstring''' 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_com...
250
0
from __future__ import annotations import requests UpperCamelCase__ =set( 'approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked content_categories created_utc down...
325
import numpy as np import datasets UpperCamelCase__ ='\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance.\nIt was introduced by Prof. P....
325
1
import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import GradientAccumulator, c...
302
import pickle import numpy as np from matplotlib import pyplot as plt class lowerCAmelCase__ : '''simple docstring''' def __init__( self , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelCase , __lowerCamelC...
11
0
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class __lowerCamelCase ( unittest.TestCase , a__ ): '''simple docstring''' def _UpperCAmelCase ( self ) -> str: _a ...
153
"""simple docstring""" import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig...
153
1
import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeling_tf_auto imp...
305
import requests from bsa import BeautifulSoup def UpperCamelCase ( __magic_name__ : str = "AAPL" ) -> str: """simple docstring""" lowercase__ = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' lowercase__ = BeautifulSoup(requests.ge...
305
1
from __future__ import annotations def A_ ( _lowerCAmelCase , _lowerCAmelCase ) -> list[str]: if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions > number_of_bytes: raise ValueError("partitions can not > number_of_bytes!" ) ...
351
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() __lowerCamelCase : Dict = logging.get_logger("""transformers.models.speecht5""") def A_ ( _lowerCAmelCase , _lowerCAmelCase ...
140
0
'''simple docstring''' def UpperCamelCase_( snake_case : int ): '''simple docstring''' if not isinstance(snake_case , snake_case ): raise ValueError("Input must be an integer" ) if input_num <= 0: raise ValueError("I...
85
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
61
0
"""simple docstring""" def lowercase__(A ) ->bool: """simple docstring""" if number < 0: raise ValueError("number must not be negative" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest ...
150
"""simple docstring""" from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge a : Optional[Any] = [ """Prosecutor: \"No videos were used in the crash investigat...
150
1
from manim import * class __A ( a ): """simple docstring""" def __lowercase ( self ): """simple docstring""" __UpperCamelCase : Optional[Any] =Rectangle(height=0.5 , width=0.5 ) ...
71
def A ( a_ ,a_ ,a_ ) -> int: def update_area_of_max_square(a_ ,a_ ) -> int: # BASE CASE if row >= rows or col >= cols: return 0 __UpperCamelCase : Optional[int] =update_area_of_m...
71
1
import shutil import tempfile import unittest from transformers import ( SPIECE_UNDERLINE, AddedToken, BatchEncoding, NllbTokenizer, NllbTokenizerFast, is_torch_available, ) from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, requir...
267
import numpy as np import datasets UpperCAmelCase = """ Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance. It was introduced by Prof. P. C. Mah...
267
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCAmelCase = { """configuration_bloom""": ["""BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BloomConfig""", """BloomOnnxConfig"""], } try: if not is_tok...
140
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.Sequential() # Step 1 - Convolution #...
140
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging.set...
358
class __snake_case : def __init__( self ,snake_case ,snake_case=None ,snake_case=None ): '''simple docstring''' lowercase : Tuple = data lowercase : List[Any] = previous lowercase : List[str] = next_...
285
0
"""simple docstring""" from __future__ import annotations import csv import requests from bsa import BeautifulSoup def UpperCAmelCase__ (lowerCAmelCase_ = "" ): '''simple docstring''' __SCREAMING_SNAKE_CASE = url or "https://www.imdb.com/chart/top/?ref_=nv_mv_250" ...
54
"""simple docstring""" import math import random def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ = False ): '''simple docstring''' if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value a__ : Tuple =...
54
1
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGen...
362
import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.test...
193
0
'''simple docstring''' from __future__ import annotations import math import random from typing import Any class a : def __init__( self : Union[str, Any] ): snake_case_ = [] snake_case_ = 0 snake_case_ = 0 def A_...
56
from __future__ import annotations from math import ceil, floor, sqrt def __UpperCamelCase ( _lowerCAmelCase = 200_0000 ) -> int: """simple docstring""" A : list[int] = [0] A : int for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): ...
116
0
"""simple docstring""" import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers.model...
351
"""simple docstring""" 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) _a = logging.getLogger() def ...
23
0
'''simple docstring''' import os def __a(SCREAMING_SNAKE_CASE_ : Optional[int] ): '''simple docstring''' _lowerCAmelCase = len(grid[0] ) _lowerCAmelCase = len(SCREAMING_SNAKE_CASE_ ) _lowerCAmelCase = 0 _lowerCAmelCase = 0 _lowerCAmelCase...
158
'''simple docstring''' import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user pass...
158
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slow, ...
358
def UpperCamelCase ( _A : str , _A : str )-> str: """simple docstring""" A__ = len(_A ) A__ = len(_A ) A__ = ( first_str_length if first_str_length > second_str_length else second_str_length ...
198
0
import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuratio...
306
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class __UpperCAmelCase : __snake_case : torch.Tensor # [batch_size x 3] __snake_case : torch.Tensor # [batch_size x 3] __snake_case : torch.Tensor...
306
1
'''simple docstring''' import qiskit def _a( UpperCamelCase__ : int, UpperCamelCase__ : int ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : int =qiskit.Aer.get_backend('''aer_simulator''' ) SCREAMING_SNAK...
355
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'configuration_lxmert': ['LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'L...
222
0
"""simple docstring""" import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBertF...
74
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, ...
284
0
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME __UpperCamelCase = ["small", "medium", "large"] __UpperCamelCase = "lm_head.decoder.weight" __UpperCamelCase = "lm_head.weight" def ...
13
'''simple docstring''' from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require...
13
1
def UpperCAmelCase__ ( lowerCamelCase ): if len(lowerCamelCase ) <= 1: return [tuple(lowerCamelCase )] lowercase :Tuple = [] def generate(lowerCamelCase, lowerCamelCase ): if k == 1: res.append(tuple(arr[:] ) ) return generate(k - ...
236
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(): import t...
236
1
"""simple docstring""" import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING A: int = logging.get...
76
"""simple docstring""" import os from collections.abc import Iterator def _snake_case ( UpperCamelCase : str = "." ): for dir_path, dir_names, filenames in os.walk(UpperCamelCase ): UpperCAmelCase : List[Any] = [d for d in dir_names if d != """scripts""" and d[0] not in...
76
1
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase = None , UpperCAmelCase = None , UpperCAmelCase = False , ): lowercase__ : str = cipher_alphabet or [chr(__lowercase ) for i in range(97 , 123 )] # ...
198
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.Sequential() # Step 1 - Convolution #...
140
0
def SCREAMING_SNAKE_CASE ( snake_case_ : str , snake_case_ : bool = False ): if not isinstance(snake_case_ , snake_case_ ): snake_case__ : str = F'''Expected string as input, found {type(snake_case_ )}''' raise ValueError(snake_case_ ) if...
286
from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, require_torch @require_torc...
286
1
from __future__ import annotations def UpperCamelCase ( _A ): """simple docstring""" if not nums: return 0 __magic_name__ : Dict = nums[0] __magic_name__ : Union[str, Any] = 0 for num in nums[1:]: _...
342
from dataclasses import dataclass from typing import Dict, 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 .attention_processor import AttentionProcessor, AttnProcessor from .modelin...
330
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase_ : Union[str, Any] = {'''configuration_glpn''': ['''GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GLPNConfig''']} try: if not is_vision_availabl...
62
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _SCREAMING_SNAKE_CASE ( _a ): snake_case__ ...
62
1
'''simple docstring''' import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql ...
267
'''simple docstring''' class lowerCAmelCase__ : """simple docstring""" def __init__( self : List[Any] , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : Union[str, Any] , __SCREAMING_SNAKE_CASE : Any ) -> Tuple: ...
267
1
from __future__ import annotations from typing import Any class __UpperCAmelCase ( lowercase__ ): pass class __UpperCAmelCase : def __init__( self : Dict, __A : Any ): UpperCAmelCase : Any = data UpperCAmelCase : Node | N...
355
from __future__ import annotations import queue class __UpperCAmelCase : def __init__( self : str, __A : Union[str, Any] ): UpperCAmelCase : Dict = data UpperCAmelCase : Tuple = None UpperCAmelCase : Any = None ...
99
0
import requests from bsa import BeautifulSoup def A ( _lowercase = "AAPL" ): SCREAMING_SNAKE_CASE : str = f"""https://in.finance.yahoo.com/quote/{symbol}?s={symbol}""" SCREAMING_SNAKE_CASE : Union[str, Any] = BeautifulSoup(requests.get(_lowercase ...
182
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, ) __UpperCamelCase : Any = {'configuration_mbar...
182
1
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision fro...
361
'''simple docstring''' def _lowerCamelCase ( lowerCamelCase_ : str , lowerCamelCase_ : str = " " ): """simple docstring""" UpperCAmelCase_ : str = [] UpperCAmelCase_ : List[Any] = 0 for index, char in enumerate(lowe...
274
0
'''simple docstring''' 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 _A : str = datasets.logging.get_logger(__name__) _A : Dict = '''\ @InProce...
229
'''simple docstring''' import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _A : str = logging.get_logger(__name__) _A : str = [ ['''a...
229
1
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 OptionalDependencyNotAvailable() excep...
189
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import numpy as np import pandas as pd from datasets import load_dataset import transformers from transformers import ( AutoConfig, BartForSequenceClassification, DataCo...
189
1
'''simple docstring''' def __lowerCamelCase ( lowerCAmelCase_ = 4000000 ) -> int: _a : Optional[Any] = [0, 1] _a : str = 0 while fib[i] <= n: fib.append(fib[i] + fib[i + 1] ) if fib[i + 2] > n: break i += 1 _a : L...
89
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class SCREAMING_S...
23
0
def __lowerCamelCase (UpperCAmelCase__ : int , UpperCAmelCase__ : int ): while b: SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = b, a % b return a def __lowerCamelCase (UpperCAmelCase__ : int , UpperCAmelCase__ ...
350
from __future__ import annotations from collections.abc import Iterator class lowercase : def __init__( self : str , _UpperCamelCase : int ) -> None: '''simple docstring''' SCREAMING_SNAKE_CASE = value SCREA...
206
0
"""simple docstring""" import unittest from transformers import DonutProcessor _lowercase = '''naver-clova-ix/donut-base''' class lowerCAmelCase_ ( unittest.TestCase ): '''simple docstring''' def _SCREAMING_SNAKE_CASE ( self : Any ) -> Any: ...
74
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, blenderbot, blenderbo...
68
0
"""simple docstring""" from __future__ import annotations def _UpperCAmelCase ( __lowerCamelCase : Any , __lowerCamelCase : Union[str, Any] , __lowerCamelCase : int , __lowerCamelCase : Tuple ) -> List[Any]: # noqa: E741 while r - l > 1: _snake_case = (l + r) // ...
363
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMo...
40
0
from maths.is_square_free import is_square_free from maths.prime_factors import prime_factors def __magic_name__ ( A : int ): '''simple docstring''' a = prime_factors(A ) if is_square_free(A ): return -1 if len(A ) % 2 else 1 return 0 if __name__ == "__m...
107
import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor __lowerCAmelCase : List[Any] = logging.get_logger(__name__) class snake_case__ (_UpperCamelCase ): """simple docstring""" def __init__( self : Union[str, Any]...
107
1
from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokenize...
359
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_co...
329
0
import argparse import os import torch from transformers.utils import WEIGHTS_NAME lowerCAmelCase : str = ["""small""", """medium""", """large"""] lowerCAmelCase : Dict = """lm_head.decoder.weight""" lowerCAmelCase : Optional[Any] = """lm_head.weight""" def ...
13
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase : Any = logging.get_logger(__name__) lowerCAmelCase : Tuple = ...
13
1
"""simple docstring""" import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ...
244
"""simple docstring""" import math def a__ ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase = len(_SCREAMING_SNAKE_CASE ) UpperCamelCase = int(math.floor(math.sqrt(_SCREAMING_SNAKE_CASE ) ) ) UpperCamelCase ...
244
1
'''simple docstring''' import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTok...
1
"""simple docstring""" import math def lowercase ( _snake_case : int ) ->bool: """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 ar...
102
0
import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from ...utils import log...
232
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 _UpperCAmelCase = '▁' _UpperCAmelCase = {'vocab_file': 'spiece.model'} ...
232
1
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import Generation...
50
"""simple docstring""" import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerat...
126
0
import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, AutoModelWithLMHead, Au...
110
from __future__ import annotations class lowercase : def __init__( self , A_ , A_ ) -> Any: """simple docstring""" UpperCamelCase , UpperCamelCase = text, pattern UpperCamelCase , UpperCamelCase = len(A_ ), len(A_ ) def __UpperCamelCase (...
110
1
"""simple docstring""" from __future__ import annotations import math def lowerCAmelCase__ ( UpperCamelCase__ ): '''simple docstring''' if num <= 0: _a : Optional[Any] = F"""{num}: Invalid input, please enter a positive integer.""" ra...
294
"""simple docstring""" import os import unicodedata 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 SPIECE_UNDERLINE, logging _snake_ca...
294
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Any class _lowercase : """simple docstring""" def __init__( self : int , UpperCamelCase__ : Any ) -> Optional...
85
"""simple docstring""" from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable __lowercase = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXConfi...
85
1
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "huggingface/time-series-transformer-tourism-monthly": ( "https://huggingface.co/huggingface/time-s...
90
import logging from transformers import PretrainedConfig _UpperCAmelCase = logging.getLogger(__name__) _UpperCAmelCase = { """bertabs-finetuned-cnndm""": """https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json""", } c...
140
0
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCamelCase_ ( lowerCAmelCase: int )-> int: # A local function to see if a dot lands in the circle. def is_in_circle(lowerCAmelCase: float , lowerCAmelCase...
260
from __future__ import annotations def lowerCamelCase_ ( lowerCAmelCase: list , lowerCAmelCase: int | None = None , lowerCAmelCase: int | None = None )-> None: if start is None: _snake_case : int = 0 if end is None: _snake_case : Option...
260
1
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_utils import enable_full_determin...
62
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def A ( snake_case__ , snake_case__ , snake_ca...
165
0
from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class A ( UpperCAmelCase__ ): '''simple docstring''' A__ = CustomTokenizer pass
146
import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor A : List[Any] = logging.get_logger(__name__) class A ( UpperCAmelCase__ ): '''simple docstring''' def __init__(self : List[Any] , *_UpperCAm...
146
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase : List[str] = { '''configuration_roc_bert''': ['''ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''RoCBertConfig'''], '''tokenization_roc_b...
252
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
94
0
"""simple docstring""" import argparse import json from typing import List from ltp import LTP from transformers import BertTokenizer def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> Any: '''simple docstring''' if ( (cp >= 0x4e00 and cp <= 0x9fff) ...
313
"""simple docstring""" 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, B...
313
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''google/bi...
104
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformers import ( AutoTokeni...
257
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { """sayakpaul/vit-msn-base""": """https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.js...
364
"""simple docstring""" import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING:...
244
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A : Tuple = logging.get_logger(__name__) A : Dict = { "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json", } class _U...
57
"""simple docstring""" def lowercase ( A_ , A_ )-> float: '''simple docstring''' if mass < 0: raise ValueError("The mass of a body cannot be negative" ) return 0.5 * mass * abs(A_ ) * abs(A_ ) if __name__ == "__main__": im...
40
0
'''simple docstring''' import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requi...
174
'''simple docstring''' import os lowerCamelCase_ = {'''I''': 1, '''V''': 5, '''X''': 10, '''L''': 50, '''C''': 1_00, '''D''': 5_00, '''M''': 10_00} def __lowercase ( __lowercase ) -> int: '''simple docstring''' _A = 0 _A = 0 whi...
174
1
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, ...
201
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { 'huggingface/informer-tourism-monthly': ( 'https://huggingface.co/huggi...
201
1
from __future__ import annotations import numpy as np def lowercase_ ( _lowerCamelCase: np.ndarray ) -> tuple[np.ndarray, np.ndarray]: '''simple docstring''' __lowerCamelCase : Any = np.shape(_lowerCamelCase ) if rows != columns: __lowerCamelCas...
354
"""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_utils im...
64
0
class _lowerCAmelCase : def __init__( self ) -> Optional[int]: lowerCAmelCase_ = {} # Mapping from char to TrieNode lowerCAmelCase_ = False def __a ( self , _UpperCamelCase ) -> Optional[Any]: for word in words: ...
231
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase : Optional[int] = logging.get_logger(__name__) __UpperCAmelCase : Optional[int] ...
111
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer a_ : List[Any] = logging.get...
360
from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, va...
327
0
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer lowerCamelCase__ : List[s...
246
"""simple docstring""" from __future__ import annotations __A = 1.6_021e-19 # units = C def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , ) ->tuple[str, float]: """simple docstring""" if (conductivity, electron_conc, mobility).co...
293
0
'''simple docstring''' import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class a_ ( lower...
354
'''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/li...
183
0
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-...
139
'''simple docstring''' from __future__ import annotations import numpy as np def A_ ( snake_case ): return np.maximum(0 , snake_case ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
139
1
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device ...
347
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline __UpperCamelCase : Any = datasets.ut...
347
1
"""simple docstring""" import math from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case : List[Any] = logging.get_logger(__name__) __snake_case : Tuple = { 'facebook/data2vec-base-960h': 'https://huggingface.c...
269
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 = { "camembert-base": "https://huggingface.co/camembert-base/resolve/mai...
209
0
UpperCamelCase__ = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(100000)] def _a ( SCREAMING_SNAKE_CASE_ : int ): __lowerCAmelCase = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_...
102
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 a__ ( unittest.TestCase ): @prop...
102
1
"""simple docstring""" from pathlib import Path import numpy as np from PIL import Image def lowercase ( _SCREAMING_SNAKE_CASE : np.ndarray ): '''simple docstring''' _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase = rg...
260
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Tuple = logging.get_logger(__name__) __A : Optional[Any] = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-...
260
1
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 logging __snake_case = loggin...
78
from __future__ import annotations def lowerCAmelCase_ ( __lowerCAmelCase , __lowerCAmelCase )-> list[list[int]]: '''simple docstring''' UpperCAmelCase : list[list[int]] =[] create_all_state(1 , __lowerCAmelCase , __lowerCAmelCase , ...
78
1
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class a ( __snake_case ): SCREAMING_SNAKE_CASE : int = ["""image_processor""", """tokenizer"""] SCRE...
183
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, p...
183
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case : Tuple = { "configuration_clipseg": [ "CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP", "CLIPSegConfig", "CLIPSegTextConfig", "CLIPSegVisionConfi...
359
import numpy class _snake_case : def __init__( self , _a , _a ): __magic_name__ : Optional[Any] = input_array # Random initial weights are assigned where first argument is the # number of nodes in previous layer and second argument is the #...
41
0
"""simple docstring""" def lowerCamelCase__ ( __snake_case, __snake_case, __snake_case, __snake_case, __snake_case ) -> int: """simple docstring""" if index == number_of_items: return 0 _UpperCamelCase = 0 _UpperCamelC...
194
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_dimen...
308
0
def _lowerCAmelCase ( A__: str , A__: int ): '''simple docstring''' UpperCAmelCase = word.split() def justify(A__: list , A__: int , A__: int ) -> str: UpperCAmelCase = max_width - width UpperCAmelC...
350
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 OptionalDependencyNotAvai...
152
0
'''simple docstring''' import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids...
79
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : int = { "configuration_autoformer": [ "AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "AutoformerConfig", ], }...
252
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 KandinskyVaaPriorPipeli...
366
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorSt...
266
0