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''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { "configuration_clipseg": [ "CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP", "CLIPSegConfig", "CLIPSegTextConfig", "CLIPSegVisio...
164
"""simple docstring""" from collections.abc import Callable import numpy as np def _snake_case ( UpperCamelCase : Callable , UpperCamelCase : float , UpperCamelCase : float , UpperCamelCase : float , UpperCamelCase : float ): UpperCAmelCase : Any...
109
0
from typing import Any class _UpperCamelCase : def __init__( self: Union[str, Any] , _SCREAMING_SNAKE_CASE: Any ) -> str: """simple docstring""" UpperCamelCase_ = data UpperCamelCase_ = None def _...
328
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCAmelCase = { 'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'], 'tokenization_tapas': ['TapasTokenizer'], } try: if not i...
328
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( A__ ): A : Tuple = 'timm_backbone' def __init__( self , SCREAMING_SNAKE_CASE__=None , SCR...
337
def __lowercase ( _UpperCamelCase, _UpperCamelCase, _UpperCamelCase, _UpperCamelCase ) ->Union[str, Any]: """simple docstring""" lowercase : Union[str, Any] = [False] * len(_UpperCamelCase ) lowercase : Optional[int] = [] queue.appe...
337
1
'''simple docstring''' import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCAmelCase_ : '''simple docstring''' lowerCAmelCase_ : Union[str, Any] = None lowerCAmelCase_ : List[str] ...
371
'''simple docstring''' from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { 'nielsr/canine-s': 2_0_4_8, } # Unicode defines 1,114,112 total ...
61
0
"""simple docstring""" import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.n...
242
"""simple docstring""" import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def lowercase_ ( __UpperCAmelCase ) ->...
242
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __SCREAMING_SNAKE_CASE :str = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE :Lis...
365
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : list ) -> list: '''simple docstring''' for i in range(len(__lowercase ) - 1 , 0 , -1 ): _UpperCAmelCase = False for j in range(__lowercase , 0 , ...
156
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanorama...
305
def A_ ( _lowerCAmelCase ) -> str: UpperCamelCase : Optional[int] = int(_lowerCAmelCase ) if decimal in (0, 1): # Exit cases for the recursion return str(_lowerCAmelCase ) UpperCamelCase , UpperCamelCase : Dict = divmod(_lowerCAmelCase , 2 )...
52
0
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: list ) -> list: _UpperCAmelCase : Dict = len(lowerCAmelCase ) for _ in range(lowerCAmelCase ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: _UpperCAmelCase...
189
from typing import Any class a : def __init__( self , A_ ): '''simple docstring''' _UpperCAmelCase : List[Any] = data _UpperCAmelCase : Any = None class a : def __init__( self ): ...
189
1
import sys 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 check...
147
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __a = { "configuration_bloom": ["BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP", "BloomConfig", "BloomOnnxConfig"], } try: if not i...
35
0
"""simple docstring""" from __future__ import annotations from typing import TypedDict class snake_case ( _UpperCamelCase): __UpperCamelCase = 42 __UpperCamelCase = 42 def a__ ( __lowercase ) -> list[str]: if not isinstance(__lowercase ...
163
"""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 a__ ...
163
1
import math class A : def _A (self , lowerCAmelCase , lowerCAmelCase ): __lowercase= 0.0 __lowercase= 0.0 for i in range(len(lowerCAmelCase ) ): da += math.pow((sample[i] - weights[0][i]) , 2 ) ...
295
import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accelerate.test_utils import require_m...
295
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_feature...
361
'''simple docstring''' from __future__ import annotations from math import pi, sqrt def _A ( _lowerCAmelCase , _lowerCAmelCase ): """simple docstring""" if inductance <= 0: raise ValueError('Inductance cannot be 0 or negative' ) elif capacitance...
48
0
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): im...
278
"""simple docstring""" import math import os import sys def UpperCamelCase ( UpperCAmelCase ) ->str: """simple docstring""" a_ = "" try: with open(UpperCAmelCase , "rb" ) as binary_file: a_ = binary_file.read() for dat in data: a_ ...
243
0
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 BartForConditionalGeneration, BartTokenize...
366
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCAmelCase : List[str] = { "configuration_roberta": ["ROBERTA_PRETRAINED_CONF...
293
0
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from t...
216
import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils imp...
216
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
371
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common i...
146
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_a...
271
'''simple docstring''' import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow __lowerCAmelCase = logging.getLogger() @unittest.skip('''Temporar...
271
1
from __future__ import annotations def SCREAMING_SNAKE_CASE__ ( lowercase ) -> bool: snake_case : List[Any] = str(lowercase ) return len(lowercase ) == 9 and set(lowercase ) == set("""123456789""" ) def SCREAMING_SNAKE_CASE__ ( ) -> in...
176
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler,...
176
1
"""simple docstring""" import requests _a = '' # <-- Put your OpenWeatherMap appid here! _a = 'https://api.openweathermap.org/data/2.5/' def __a ( __lowerCamelCase = "Chicago", __lowerCamelCase = APPID ): return requests.get(URL_BASE + "weather", params=locals() )...
61
"""simple docstring""" from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def __a ( ): UpperCAmelCase_ : List[Any] = { "repo_name": ["test_repo1", "test_repo2", "test_repo3"], "p...
61
1
import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common impo...
213
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE : int = { "configuration_timesformer": ["TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TimesformerConfig"], } try: if not is_torch_availab...
213
1
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, renew...
138
'''simple docstring''' def A_ ( snake_case ): if not all(x.isalpha() for x in string ): raise ValueError("String must only contain alphabetic characters." ) SCREAMING_SNAKE_CASE:Optional[int] = sorted(string.lower() ) return len(snake_case ) ...
139
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Optional[Any] = { "abeja/gpt-neox-japanese-2.7b": "https://huggingface.co/abeja/gpt-neox-japanese-2.7b...
359
"""simple docstring""" import os from collections.abc import Iterator def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : str = "." ): for dir_path, dir_names, filenames in os.walk(_UpperCAmelCase ): lowerCAmelCase = [d for d in dir_names if d != 'scripts' and d[0] not in '._'] for filename in ...
309
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): ...
64
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (snake_case__ : list[float] ): """simple docstring""" _snake_case : int = 0.00 _snake_case : int = 0 for resistor in resistors: if resistor <= 0: ...
64
1
"""simple docstring""" from math import pow, sqrt def _A (*__a ) -> bool: """simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[int] = len(__a ) > 0 and all(value > 0.0 for value in values ) return result def _A (__a , __a ) ...
318
"""simple docstring""" from __future__ import annotations UpperCAmelCase_ : List[str] = list[list[int]] # assigning initial values to the grid UpperCAmelCase_ : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, ...
318
1
'''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, prepare_ima...
4
"""simple docstring""" from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration SCREAMING_SNAKE_CASE__ = HfArgumentParser(InitializationArguments) SCREAMING_SNAKE_CASE__ = parser.parse_args() ...
150
0
"""simple docstring""" import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_...
364
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer lowercase__ = logging.get_logger(__name__)...
203
0
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( lowercase_ ) -> list: A__ = int(lowercase_ ) if n_element < 1: A__ = ValueError("a should be a positive number" ) raise my_error A__ = [1] A__, A__, A__ = (0, 0, 0) A__ ...
247
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, ...
247
1
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, requir...
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 argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from transforme...
184
from ...configuration_utils import PretrainedConfig from ...utils import logging A : str = logging.get_logger(__name__) A : int = { "alibaba-damo/mgp-str-base": "https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json", } class _lowercas...
184
1
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCamelCase__ : '''simple docstring''' snake_case_ =None snake_case_ =False snake_case_ =False snake_case_ =False snake_case_ =None sn...
371
def lowerCAmelCase__ ( lowerCamelCase_ : str = "The quick brown fox jumps over the lazy dog" ,): '''simple docstring''' lowerCAmelCase__ : Any = set() # Replace all the whitespace in our sentence lowerCAmelCase__ : List[Any] = input_str.re...
94
0
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, ...
210
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interle...
210
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase : Union[str, Any] = logging.get_logger(__name__) UpperC...
371
"""simple docstring""" import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedData...
263
0
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax...
55
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
55
1
"""simple docstring""" def _lowerCAmelCase ( lowercase_ ): return str(lowercase_ ) == str(lowercase_ )[::-1] def _lowerCAmelCase ( lowercase_ ): return int(lowercase_ ) + int(str(lowercase_ )[::-1] ) def _lowerCAmelCase ( ...
181
"""simple docstring""" from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from dif...
181
1
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def lowerCAmelCase_ ( )-> int: '''simple docstring''' UpperCAmelCase : str ={ '''repo_name''': ['''test_repo1''',...
348
__snake_case = '''Input must be a string of 8 numbers plus letter''' __snake_case = '''TRWAGMYFPDXBNJZSQVHLCKE''' def lowerCAmelCase_ ( __lowerCAmelCase )-> bool: '''simple docstring''' if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): ...
348
1
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...te...
250
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case__ : str = logging.get_logger(__name__) snake_case__ : Optional[int] = { 'google/pix2struct-textcaps-base':...
250
1
'''simple docstring''' from ...processing_utils import ProcessorMixin class A__ ( _snake_case ): lowercase = "WhisperFeatureExtractor" lowercase = "WhisperTokenizer" def __init__( self , UpperCamelCase__ , UpperCamelCase__ ) -> int: ...
162
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> list[list[float]]: A_ = [] for data in source_data: for i, el in enumerate(UpperCAmelCase__ ): if len(UpperCAmelCase__ ) < i + 1: data_lists.appen...
162
1
def A ( _lowercase , _lowercase = False ): if not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): SCREAMING_SNAKE_CASE : Dict = f"""Expected string as input, found {type(SCREAMING_SNAKE_CASE__ )}""" raise ValueE...
367
from __future__ import annotations import numpy as np def A ( _lowercase ): return np.maximum(0 , _lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
258
0
import os import unittest from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
5
from typing import Any def UpperCAmelCase_ ( __snake_case , __snake_case , __snake_case , __snake_case , __snake_case , ) -> list: """simple docstring""" _validation( __snake_case , __snake_case , __snake_case , ...
5
1
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score fro...
25
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase : Optional[Any] = { """CarlCochet/trajectory-transformer-halfcheetah-m...
25
1
"""simple docstring""" 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, requi...
266
"""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, prepare_image_inputs i...
266
1
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _a ( unittest.TestCase , _lowerCAmelCase ): def __snake_case (self ) -> Optional[int]: UpperCAmelCase_: Optional[int] = l...
82
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer a : List[str] = {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'} ...
82
1
'''simple docstring''' from __future__ import annotations from typing import Any def UpperCamelCase ( _lowerCamelCase : list[Any] ): create_state_space_tree(_lowerCamelCase , [] , 0 ) def UpperCamelCase ( _lowerCamelCase :...
237
'''simple docstring''' import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import AdamW from tor...
237
1
"""simple docstring""" def lowerCamelCase ( _UpperCamelCase : int , _UpperCamelCase : int , _UpperCamelCase : list[list[int]] ) -> int: '''simple docstring''' def update_area_of_max_square(_UpperCamelCase : int , _UpperCamelCase : int )...
320
"""simple docstring""" UpperCAmelCase : Dict = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def lowerCamelCase ( _UpperCamelCase : bytes ) -> bytes: '''simple docstring''' if not isinstance(_UpperCamelCase , _UpperCamelCase ...
320
1
import math def UpperCamelCase__ ( A__ ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # All...
143
from abc import ABC, abstractmethod from argparse import ArgumentParser class __snake_case ( _lowerCamelCase ): @staticmethod @abstractmethod def __a ( __UpperCamelCase ) -> Dict: '''simple docstring''' raise NotImplementedEr...
143
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { 'weiweishi/roc-bert-base-zh': 'https://huggingface.co/weiweishi/roc-bert-base-zh/resolve/main/config.json', } class UpperCAmelCase_ ...
353
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowercase = {"""configuration_deit""": ["""DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DeiTConfig""", """D...
229
0
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A_ : List[str] = logging.get_logger(__name__) A...
333
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILIm...
333
1
"""simple docstring""" from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class UpperCamelCase ( lowercase_ ...
321
"""simple docstring""" class UpperCamelCase : def __init__( self ,__UpperCamelCase ,__UpperCamelCase ) -> int: '''simple docstring''' lowercase_ : List[Any] = name lowercase_ : int = val def __str__( s...
321
1
import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
30
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __a = {'configuration_deit': ['DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DeiTConfig', 'DeiTOnnxConfig']} try: ...
30
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) __A ={ '''configuration_trocr''': ['''TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TrOCRConfig'''], '''processing_t...
47
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __A ={ '''configuration_bridgetower''': [ '''BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BridgeTowerConfig''', '''BridgeTowerTextConfig''', ...
47
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcesso...
245
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall...
245
1
"""simple docstring""" import os import time import numpy as np import onnxruntime as ort _lowercase : Union[str, Any] = '1' _lowercase : str = '0' _lowercase : List[Any] = '1' _lowercase : Dict = ort.SessionOptions() _lowercase : int = ...
86
"""simple docstring""" from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar _lowercase : List[Any] = TypeVar('T') class _UpperCAmelCase ( Generic[T] ): a__ : deque[T] # Cache store of keys a__ : s...
86
1
import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def A (__A : Optional[int] , __A : Any , __A : str=1024 , __A : Tuple=1024 , __A : int=...
51
import math def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : int ) -> bool: assert isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are prime...
325
0
'''simple docstring''' def a__ ( lowercase : list, lowercase : int = 0 ) -> list: """simple docstring""" _UpperCamelCase = length or len(lowercase ) _UpperCamelCase = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]: ...
287
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class __lowerCAmelCase ( unittest.TestCase ): """simple docstring""" def snake_case__ ( self : Tuple ) -> int: '''simple d...
287
1
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _a ( __a ): __a : Optional[A...
34
"""simple docstring""" SCREAMING_SNAKE_CASE_ : Optional[int] = tuple[float, float, float] SCREAMING_SNAKE_CASE_ : Optional[int] = tuple[float, float, float] def _snake_case ( UpperCAmelCase_ : Pointad , UpperCAmelCase_ : Pointad ): ...
335
0
'''simple docstring''' 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, BartForSequenceC...
21
'''simple docstring''' import os import numpy import onnx def lowerCamelCase ( UpperCAmelCase__ : Optional[int] , UpperCAmelCase__ : str ) -> Tuple: lowercase_ : Tuple = a.name lowercase_ : Tuple = b.name lowercase_ : Any ...
21
1
UpperCamelCase__ = frozenset( [ """prompt""", """height""", """width""", """guidance_scale""", """negative_prompt""", """prompt_embeds""", """negative_prompt_embeds""", """cross_attention_kwargs""", ] ) UpperCamelCase__ = froz...
92
from typing import TYPE_CHECKING from ...utils import _LazyModule UpperCamelCase__ = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys UpperCamelCase__ ...
92
1
def SCREAMING_SNAKE_CASE ( __UpperCamelCase : list ) -> list: if len(_snake_case ) <= 1: return lst UpperCAmelCase_ = 1 while i < len(_snake_case ): if lst[i - 1] <= lst[i]: i += 1 else: ...
352
# 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 dif...
177
0
import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # noqa: F401 # Here to ...
14
"""simple docstring""" import random from typing import Any def _A (__a ) -> list[Any]: """simple docstring""" for _ in range(len(__a ) ): SCREAMING_SNAKE_CASE_ : Optional[int] = random.randint(0 , len(__a ) - 1 ) ...
91
0
from collections import namedtuple import requests from lxml import html # type: ignore A_ : int = namedtuple("covid_data", "cases deaths recovered") def lowerCamelCase_ ( _lowerCamelCase = "https://www.worldometers.info/coronavirus/" ): lowerCamelCase__ : Any ...
360
"""simple docstring""" def lowerCamelCase_ ( _lowerCamelCase ): lowerCamelCase__ : Union[str, Any] = [] lowerCamelCase__ : List[str] = [] lowerCamelCase__ : Tuple = { '^': 3, '*': 2, '/': 2, '%': 2, '+': 1, ...
316
0
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import ...
290
"""simple docstring""" import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class __lowerCAmelCase ( __SCREAMING_SNAKE_CASE )...
316
0
def __lowerCAmelCase ( ): return [ a * b * (1000 - a - b) for a in range(1 , 999 ) for b in range(_snake_case , 999 ) if (a * a + b * b == (1000 - a - b) ** 2) ][0] if __name__ == "__main__": print(F'{solution() = }')
352
from __future__ import annotations from typing import TypedDict class _snake_case ( lowercase__): UpperCamelCase__ : str UpperCamelCase__ : int def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ ): if not isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): ...
224
0
"""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 ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging loggin...
320
from scipy.stats import pearsonr import datasets _lowerCamelCase =""" Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assumption that each dataset i...
287
0
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _snake_case : str ...
365
'''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_bert import BertTokenizer _snake_case : Any = log...
179
0
import os def a__ ( __UpperCamelCase = "input.txt" ): with open(os.path.join(os.path.dirname(__UpperCamelCase ) , __UpperCamelCase ) ) as input_file: SCREAMING_SNAKE_CASE_ = [ [int(__UpperCamelCase ) for element in line.split("," )] for l...
118
def a__ ( __UpperCamelCase ): if not head: return True # split the list to two parts SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = head.next, head while fast and fast.next: SCREAMING_SNAKE_CASE_ = fast.next.next SCREAM...
118
1
def A (__A : list , __A : list ) -> float: """simple docstring""" _validate_point(__A ) _validate_point(__A ) if len(__A ) != len(__A ): raise ValueError('''Both points must be in the same n-dimensional space'''...
7
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class __snake_case ( unittest.TestCase ): def lowerCamelCase ( self : Dict): """simple...
7
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __snake_case = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], """configuration_maskformer_...
259
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase_ = { "configuration_maskformer": ["MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "MaskFormerConfig"], ...
251
0
"""simple docstring""" from __future__ import annotations def lowerCAmelCase (__UpperCamelCase : int , __UpperCamelCase : int ): """simple docstring""" __UpperCamelCase =[] create_all_state(1 , __UpperCamelCase , __UpperCamelCase , [] , __Upper...
357
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversati...
85
0
'''simple docstring''' from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBas...
70
'''simple docstring''' import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttent...
58
0
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> Dict: SCREAMING_SNAKE_CASE__ : Dict = [] SCREAMING_SNAKE_CASE__ : Optional[Any] = [] SCREAMING_SNAKE_CASE__ : int = { """^""": 3, """*""": 2, """/""": 2, ...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: while b: SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ : int = b, a % b return a def _lowercase ( __lowerCAmelCase , __lowerCAmelCase )...
56
1
"""simple docstring""" def a_ ( _lowerCAmelCase : str , _lowerCAmelCase : str ): '''simple docstring''' lowercase__ : List[str] = len(_lowerCAmelCase ) + 1 lowercase__ : Any = len(_lowerCAmelCase ) + 1 # dp is a 2d matrix where dp[i]...
77
'''simple docstring''' def __A ( lowerCamelCase_ , lowerCamelCase_ ): """simple docstring""" return number | (1 << position) def __A ( lowerCamelCase_ , lowerCamelCase_ ): """simple docstring""" return number & ~(1 << position) ...
323
0
'''simple docstring''' from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE__ : def __init__( self , A_ = 6 )-> None: '''simple docstring''' UpperCamelCase = None Upp...
251
'''simple docstring''' from ... import PretrainedConfig lowerCAmelCase : List[str] = { 'sijunhe/nezha-cn-base': 'https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json', } class SCREAMING_SNAKE_CASE__ ( snake_case_): lowerCAmelCase_ = NEZHA_PRETRAINED_...
251
1
from __future__ import annotations import collections import pprint from pathlib import Path def lowerCAmelCase_ ( snake_case_ ): return "".join(sorted(_snake_case ) ) def lowerCAmelCase_ ( snake_case_ ): return word_by_signature[signature(_snake_case ...
26
"""simple docstring""" from scipy.stats import spearmanr import datasets a = ''' The Spearman rank-order correlation coefficient is a measure of the relationship between two datasets. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Positive correlati...
315
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig lowercase : Optional[int] = { """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/config.json""", """al...
369
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner import Split, ...
225
0
import os import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer from ...test_tokenization_common import TokenizerTesterMixin class SCREAMING_SNAKE_CASE_ ( __lowerCAmelCase , unittest.TestCase ): __lowerCAmelCase = PhobertTokenizer ...
343
from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE_ ( __lowerCAmelCase ): pass class SCREAMING_SNAKE_CASE_ : def __init__( self : List[Any] , lowerCamelCase_ : Any ): """simple docstring""" UpperCamelCase = d...
343
1
"""simple docstring""" import math import random from typing import Any from .hill_climbing import SearchProblem def UpperCAmelCase__ (snake_case__ : List[str] , snake_case__ : bool = True , snake_case__ : float = math.inf , snake_case__ : float = -math.inf , ...
356
"""simple docstring""" import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodule...
132
0
"""simple docstring""" def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' if upper_limit < 0: raise ValueError("Limit for the Catalan sequence must be ≥ 0" ) __SCREAMING_SNAKE_CASE = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1...
54
import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils import logging logging.set_verbosity_inf...
233
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a__ ( ...
366
'''simple docstring''' from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record __UpperCAmelCase = '''\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Un...
228
0
'''simple docstring''' import collections import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a__ : Dict =logging.get_logger(__name__) a__ : Optional[Any] ='''▁''' ...
53
'''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 fr...
53
1
"""simple docstring""" import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB...
371
"""simple docstring""" def A_ ( _lowerCAmelCase : str ): """simple docstring""" _a = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def A_ ( _lowerCAmelCase ...
153
0
'''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 l...
3
"""simple docstring""" import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ): lowercase__ = "Speech2TextFeatureExtractor" lowercase__ = "Speech2...
136
0
from collections.abc import Iterable from typing import Generic, TypeVar snake_case = TypeVar("""_T""") class SCREAMING_SNAKE_CASE ( Generic[_T] ): '''simple docstring''' def __init__( self : Tuple , UpperCAmelCase_ : Iterable[_T] | None = None ): SCREAMI...
319
class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : Union[str, Any] , UpperCAmelCase_ : list ): SCREAMING_SNAKE_CASE : Union[str, Any] = set_counts SCREAMING_SNAKE_CASE : Any = max(UpperCAmelCase_ ) SCREAMING_SNAKE_CASE ...
319
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { "facebook/dpr-ctx_encoder-single-nq-base": ( "https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resolve/...
211
'''simple docstring''' from __future__ import annotations from typing import TypedDict class __A ( A ): '''simple docstring''' __lowerCamelCase : str __lowerCamelCase : int def lowerCAmelCase (__A): """simple docstring""" if not isinstance(__A...
211
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowercase__ : Optional[int] = logging.get_logger(__name__) ...
289
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : list[int] , lowerCAmelCase__ : list[int] ) -> None: """simple docstring""" lowerCAmelCase_ : List[Any] = len(lowerCAmelCase__ ) print('The followin...
289
1
from __future__ import annotations from math import pow, sqrt def __UpperCAmelCase ( a_ , a_ , a_): if (resistance, reactance, impedance).count(0) != 1: raise ValueError('One and only one argument must be 0') if resistance == 0: retu...
178
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", "GPTNeoXConfig"]} try: if not is_tokenizers_av...
178
1
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { '''SenseTime/deformable-detr''': '''https://huggingface.c...
365
"""simple docstring""" import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class SCREAMING_SNAKE_CASE__ ( lowercase ...
133
0
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_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to incl...
204
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMi...
204
1
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> list: lowercase__: Optional[int] = [0] * len(__UpperCAmelCase ) for i in range(1 , len(__UpperCAmelCase ) ): # use last results for better performance - dynamic programming lowercase__: ...
2
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = {"ctrl": "https://huggingface.co/ctrl/resolve/main/config.json"} class UpperCAmelCase (_UpperCAmelCase ): """simple docs...
2
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class a ( metaclass=_lowerCamelCase ): snake_case_ = ["torch", "transformers", "onnx"] def __init__( self : int , *lowercase_ : List[Any] , **lowercase_ : List[str...
56
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_im...
56
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @...
369
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
348
0
'''simple docstring''' from __future__ import annotations import math import numpy as np from numpy.linalg import norm def __snake_case( _lowerCAmelCase , _lowerCAmelCase ) -> float: return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(_lowerCAmelCase , _lowerCAmelCas...
35
"""simple docstring""" 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 impor...
77
0
import math def A__ ( lowerCamelCase = 1_00 ) -> Tuple: UpperCamelCase_: Tuple = sum(i * i for i in range(1 , n + 1 ) ) UpperCamelCase_: Dict = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return square_of_sum - sum_of_squares if ...
370
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : Optional[int] = logging.get_logger(__name__) lowerCamelCase_ : Dict = { """studio-ousia/luke-base""": """https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json""", """studio-o...
223
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase : Optional[Any] = {"""configuration_swin""": ["""SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwinConfig""", """SwinOnnxConfig"""]} try:...
95
'''simple docstring''' def _A ( lowercase__ , lowercase__ ): if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) lowercase__ = str(bin(lowercase__ ) )[2:] # remove the leading "0b" lowercase__ ...
164
0
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : str = "The quick brown fox jumps over the lazy dog" , ): """simple docstring""" _snake_case : Any = set() # Replace all the whitespace in our sentence _snake_case : List[Any] = input_str.replace(""" ...
356
"""simple docstring""" import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodule...
132
0
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, flip_channel_order, get_resize_output_image_size, rescale, resize, ...
24
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_availa...
132
0
a : Tuple = 'Input must be a string of 8 numbers plus letter' a : Dict = 'TRWAGMYFPDXBNJZSQVHLCKE' def lowerCAmelCase_ (lowerCAmelCase__: str ): """simple docstring""" if not isinstance(lowerCAmelCase__ , lowerCAmelCa...
82
import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging a : Tuple = logging.get_logger(__name__) a : Optional[Any] = { 'facebook/encodec_24khz': 'https://huggingface.co/facebo...
82
1
from math import ceil def A ( _lowerCamelCase = 1_001 ): '''simple docstring''' _lowerCAmelCase : int = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): _lowerCAmelCase : List[Any] = 2 * i + 1 _lowerCAmelC...
36
def __SCREAMING_SNAKE_CASE ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) -> int: '''simple docstring''' if exponent == 1: return base if exponent % 2 == 0: UpperCAmelCase = _modexpt(UpperCamelCase__ , exponent // 2 , UpperCamelCase__ )...
273
0
"""simple docstring""" import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def lowercase__ ( snake_case_ :Optional[Any] , snake_case_ :int , snake_case_ :Union[str, Any] , snake_case_ :List[str]=5 ): # Adapted from https://github.com/pytorc...
86
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import...
86
1
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMSch...
87
"""simple docstring""" import os import sys import unittest lowerCAmelCase__ : Tuple = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 ...
98
0
import unittest from transformers import LiltConfig, 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 ModelTesterMixin,...
350
lowercase : Optional[int] = { '''Pillow''': '''Pillow''', '''accelerate''': '''accelerate>=0.11.0''', '''compel''': '''compel==0.1.8''', '''black''': '''black~=23.1''', '''datasets''': '''datasets''', '''filelock''': '''filelock''', '''flax''': '''flax>=0.4.1''...
36
0