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
from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline __snake_case :List[Any] = logging.get_logger(__na...
49
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __lowerCAmelCase = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: ...
89
0
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model from transformers.u...
357
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, ...
194
0
"""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
"""simple docstring""" import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelF...
316
1
def __snake_case ( __UpperCamelCase : Optional[Any] ,__UpperCamelCase : List[str] ): """simple docstring""" if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) A_ = str(bin(__UpperCamelCase ) )[2...
360
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map...
329
0
"""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
import collections import importlib.util import os import re from pathlib import Path lowercase = "src/transformers" # Matches is_xxx_available() lowercase = re.compile(r"is\_([a-z_]*)_available()") # Catches a one-line _import_struct = {xxx} lowercase = re.compile(r"^_imp...
178
0
def SCREAMING_SNAKE_CASE ( __UpperCamelCase : float , __UpperCamelCase : float ) -> float: if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) ...
177
import baseaa def SCREAMING_SNAKE_CASE ( __UpperCamelCase : str ) -> bytes: return baseaa.baaencode(string.encode('''utf-8''' ) ) def SCREAMING_SNAKE_CASE ( __UpperCamelCase : bytes ) -> str: return baseaa.baadecode(__UpperCam...
177
1
'''simple docstring''' import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformer...
251
'''simple docstring''' import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging UpperCamelCase_ = logging.get_logger(__name__) class _a ...
251
1
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvai...
106
'''simple docstring''' import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaF...
106
1
import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require_jieba class SCREAMING_SNAKE_CASE__ ( SCREAMING_...
328
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from datasets.utils.py_uti...
328
1
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch ...
221
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaProc...
221
1
'''simple docstring''' def __snake_case( _lowerCAmelCase = 1_000 ) -> int: snake_case__ : Union[str, Any] = 2**power snake_case__ : List[str] = 0 while n: snake_case__ , snake_case__ : int = r + n % 10, n // ...
35
'''simple docstring''' import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTe...
35
1
"""simple docstring""" from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class UpperCamelCase_ ( UpperCame...
195
"""simple docstring""" def UpperCAmelCase__ (lowerCAmelCase_ ): '''simple docstring''' return " ".join( "".join(word[::-1] ) if len(lowerCAmelCase_ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.te...
195
1
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCAmelCase__ : a__ : Optional[Union[str, Path]] = None a__ : bool = False a__ : bool = False a__ : boo...
270
import pprint import requests SCREAMING_SNAKE_CASE__ : str = "https://zenquotes.io/api" def __magic_name__ ( ) -> list: return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def __magic_name__ ( ) -> list: return requests.get(API_ENDPOINT_URL + '''/random'...
270
1
import argparse import os # New Code # import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed fro...
14
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...
14
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowerCAmelCase : Any ={ 'configuration_vision_encoder_decoder': ['VisionEncoderDecoderConfig', 'VisionEncoderDecoderOnnxConf...
9
__lowerCamelCase : List[Any] = 6_5521 def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : str ) -> int: """simple docstring""" SCREAMING_SNAKE_CASE__ = 1 SCREAMING_SNAKE_CASE__ = 0 for plain_chr in plain_text: S...
219
0
'''simple docstring''' import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation import ( ...
367
'''simple docstring''' from __future__ import annotations from typing import Any def __lowerCAmelCase ( UpperCamelCase__ ) -> None: create_state_space_tree(UpperCamelCase__ , [] , 0 ) def __lowerCAmelCase ( UpperCamelCase__ , UpperCamelCase__ , UpperCamel...
237
0
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller UpperCamelCase = 3 def lowercase_ ( _lowerCamelCase : int): print("Generating primitive root of p") while True: lowercase__ : str = ran...
87
UpperCamelCase = [0, 2, 4, 6, 8] UpperCamelCase = [1, 3, 5, 7, 9] def lowercase_ ( _lowerCamelCase : int , _lowerCamelCase : int , _lowerCamelCase : list[int] , _lowerCamelCase : int): if remaining_length == 0: if dig...
87
1
import random def __UpperCamelCase ( _lowerCAmelCase ) -> bool: """simple docstring""" A : Dict = num - 1 A : List[Any] = 0 while s % 2 == 0: A : Tuple = s // 2 t += 1 for _ in range(5 ): A :...
115
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
115
1
'''simple docstring''' # DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_c...
93
"""simple docstring""" import datasets __SCREAMING_SNAKE_CASE : Tuple = '\\n@InProceedings{conneau2018xnli,\n author = "Conneau, Alexis\n and Rinott, Ruty\n and Lample, Guillaume\n and Williams, Adina\n and Bowman, Samuel R.\n ...
347
0
from typing import Optional, Tuple import jax import jax.numpy as jnp from flax import linen as nn from flax.core.frozen_dict import FrozenDict from transformers import CLIPConfig, FlaxPreTrainedModel from transformers.models.clip.modeling_flax_clip import FlaxCLIPVisionModule def UpperCamelCase ( _A, ...
138
from manim import * class snake_case__ ( _lowerCAmelCase ): def __magic_name__ ( self ) -> Dict: __magic_name__ : int = Rectangle(height=0.5 , width=0.5 ) __magic_name__ : Optional[int] = Rectangle(hei...
138
1
"""simple docstring""" import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowercase ( __snake_case : List[Any] , __snake_case : Tuple=1 ): if n_shave_prefix_segments >= 0: return ".".join(p...
33
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __A : List[Any] = { '''configuration_mega''': ['''MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MegaConfig''', '''M...
33
1
"""simple docstring""" from __future__ import annotations lowercase_ = 1_0 def lowercase ( lowerCAmelCase__ : list[int] ) -> list[int]: __a = 1 __a = max(lowerCAmelCase__ ) while placement <= max_digit: # declare and in...
11
"""simple docstring""" from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __lowerCAmelCase ( __SCREAMING_SNAKE_CASE ): ...
11
1
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class lowerCamelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' def lowerCAmelCase_ ( self : str , _lowerCAmelCase : str ): with...
225
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase__ : str = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ], } try: ...
225
1
from random import randint from tempfile import TemporaryFile import numpy as np def __snake_case ( _lowerCAmelCase : Optional[int] , _lowerCAmelCase : str , _lowerCAmelCase : Optional[int] ) -> Dict: A_ : Optional[Any] = 0 if start < end: A_ : Tuple = ...
362
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
70
0
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultiste...
98
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_t...
329
0
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_comm...
354
import cva import numpy as np class a : """simple docstring""" def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ ) -> Any: if k in (0.04, 0.06): _A = k _A = window_size else: ...
81
0
"""simple docstring""" import random def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> bool: lowercase__: Dict = num - 1 lowercase__: Tuple = 0 while s % 2 == 0: lowercase__: int = s // 2 t += 1 for _ in range(5 ): lowercase__: Tuple ...
177
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> int: if not grid or not grid[0]: raise TypeError('''The grid does not contain the appropriate information''' ) for cell_n in range(1 , len(grid[0] ) ): grid[0][cell_n] += grid[0][cell_n - 1] lowercase__...
177
1
import unittest import torch from torch import nn from diffusers.models.activations import get_activation class lowerCAmelCase ( unittest.TestCase ): def A_ ( self : List[str] ) -> Union[str, Any]: lowerCamelCase__ : int = get_activation('swish' ...
370
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class lowerCAmelCase ( pl.LightningModule ): def __init__( self : List[str] , UpperCAmelCase : Optional[Any] ) ...
45
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __snake_case : Dict = {'configuration_deit': ['DEIT_PRETRAINED_CO...
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
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, ...
369
"""simple docstring""" import numpy as np class __SCREAMING_SNAKE_CASE : def __init__( self : List[str] ): '''simple docstring''' A__ : Optional[int] = (0, 0) A__ : Dict = None A__ ...
296
0
"""simple docstring""" import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transfor...
260
"""simple docstring""" def lowercase ( ): '''simple docstring''' _UpperCAmelCase = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] _UpperCAmelCase = 6 _UpperCAmelCase = 1 _UpperCAmelCase = 1901 _UpperCAmelCase ...
260
1
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vis...
208
import os import time import numpy as np import onnxruntime as ort lowerCamelCase : int = "1" lowerCamelCase : int = "0" lowerCamelCase : Union[str, Any] = "1" lowerCamelCase : List[Any] = ort.SessionOptions() lowerCamelCase : Opt...
208
1
'''simple docstring''' import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import torc...
2
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) lowerCAmelCase_ = { 'configuration_speecht5': [ 'SPEECHT5_PRETRAINED_C...
16
0
"""simple docstring""" # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
195
"""simple docstring""" import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, float...
195
1
from sklearn.metrics import fa_score, matthews_corrcoef import datasets from .record_evaluation import evaluate as evaluate_record a__ = """\ @article{wang2019superglue, title={SuperGLUE: A Stickier Benchmark for General-Purpose Language Understanding Systems}, author={Wang, Alex and Pruksacha...
317
"""simple docstring""" from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, logging ...
291
0
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 __lowerCamelCase : Tuple = logging.get_logger(__name__) ...
204
from __future__ import annotations __lowerCamelCase : Tuple = list[list[int]] # assigning initial values to the grid __lowerCamelCase : 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, 0, 3, 1], [0, 0, 3, 0, 1, 0...
204
1
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, ...
123
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowerCAmelCase_ ( __lowerCamelCase ...
123
1
"""simple docstring""" import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def lowercase__ ( lowercase_ ,lowercase_ ,lowercase_ ) -> Tuple: ...
310
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings lowerCamelCase__ = R"\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control...
310
1
'''simple docstring''' import os def UpperCAmelCase_ (__a : List[str] ): """simple docstring""" _a : Dict = len(grid[0] ) _a : Dict = len(__a ) _a : Dict = 0 _a : Optional[int] = 0 _a : Any = 0 # Check vertically, horizontally, ...
271
'''simple docstring''' import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home __lowerCAmelCase = HUGGINGFACE_HUB_CACHE __lowerCAmelCase = """config.json""" __lowerCAmelCase = """diffusion_pytorch_model.bin""" __lowerCAmelCase = """di...
271
1
from __future__ import annotations import math def _A ( __magic_name__ ): 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 # A...
201
def _A ( __magic_name__ ): try: lowercase__ = float(__magic_name__ ) except ValueError: raise ValueError("Please enter a valid number" ) lowercase__ = decimal - int(__magic_name__ ) if fractional_part == 0: return int(__magic_name__ ), 1 else: low...
201
1
from __future__ import annotations from typing import Any class A : def __init__(self : Dict , __UpperCAmelCase : int , __UpperCAmelCase : int , __UpperCAmelCase : float = 0 ) -> None: """simple docstring""" ...
65
from math import isclose, sqrt def a_ ( _A , _A , _A ) -> tuple[float, float, float]: """simple docstring""" snake_case__ = point_y / 4 / point_x snake_case__ = 2 * normal_gradient / (1 + normal_gradient * normal_...
307
0
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_available(): import to...
178
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 __magic_name__ ( __a : dict ): '''simple docstring''' ...
178
1
'''simple docstring''' import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transf...
58
'''simple docstring''' import argparse import logging import pickle from collections import Counter logging.basicConfig( format="""%(asctime)s - %(levelname)s - %(name)s - %(message)s""", datefmt="""%m/%d/%Y %H:%M:%S""", level=logging.INFO ) lowercase_ = logging.getLogger(__name__) if __name__ == "__m...
58
1
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : float , __lowercase : float ) -> float: '''simple docstring''' if mass < 0: raise ValueError("The mass of a body cannot be negative" ) return 0.5 * mass * abs(__lowercase ) * abs(__l...
156
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE :Dict = { '''configuration_upernet''': ['''UperNetConfig'''], } try: if not is_torch_available(): raise OptionalDepende...
156
1
def UpperCamelCase_( lowerCamelCase_ ) -> bool: _lowercase : str = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def UpperCamelCase_( lowerCamelCase_ = 5000 ) -> int: _lowercase : Optional[Any] = [(i * (3 * i - 1)) // 2 f...
21
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : list ) -> list: if any(not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ) or x < 0 for x in sequence ): raise TypeError("""Sequence must be list of non-negative integers""" ) for _ in ...
239
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCAmelCase__ = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_available(): raise OptionalDependen...
290
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCAmelCase__ = { "configuration_clip": [ "CLIP_PRETRAINED_...
290
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case : List[Any] =logging.get_logger(__name__) __snake_case : Union[str, Any] ={ 'google/realm-cc-news-pretrained-embedder': ( 'https://huggingface.co/google/realm-cc-news-pretrained-emb...
129
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 __snake_case : Optional[Any] =logging.get_logger(__name__) __snake_case : Union[str, Any] ...
129
1
def __UpperCamelCase ( lowercase__ : int = 10**9 ) -> int: '''simple docstring''' lowerCAmelCase_ : Any = 1 lowerCAmelCase_ : Dict = 2 lowerCAmelCase_ : str = 0 lowerCAmelCase_ : Optional[Any] = 0 lowerCAmel...
364
import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() __UpperCAmelCase = logging.get_logger('transformers.models.speecht5') def __UpperCamelCase ( lowercase__ : Optional[Any] , lowe...
28
0
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def __A ( *__lowerCamelCase , __lowerCamelCase = None , __lowerCamelCase=True , __lowerCamelCase=2 ) -> Optional[Any]: from .. import __version_...
228
__UpperCamelCase : 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", "hf-doc-builder": "hf-doc-builde...
228
1
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def lowerCamelCase_ (UpperCamelCase__ : Dict ): _UpperCAmelCase : str = SwinConfig(image_size=192 ...
360
"""simple docstring""" from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCamelCase_ (): _UpperCAmelCase : Optional[int] = [randint(-1000 , 1000 ) for i in range(10 )] _UpperCAme...
68
0
"""simple docstring""" import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should...
286
from typing import Dict, Optional import numpy as np import datasets SCREAMING_SNAKE_CASE :List[Any] = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binary (two classes...
15
0
# Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version _S...
213
from __future__ import annotations import time _SCREAMING_SNAKE_CASE : List[Any] = list[tuple[int, int]] _SCREAMING_SNAKE_CASE : Any = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], ...
213
1
from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { "microsoft/xprophetnet-large-wiki100-cased": ( "https://huggingface.co/microsoft/xprophe...
92
'''simple docstring''' import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgumentP...
239
0
def lowerCamelCase__ ( a__ : list , a__ : list , a__ : int , a__ : int , a__ : int ) -> int: if index == number_of_items: return 0 UpperCamelCase_ = 0 UpperCamelCase_ = 0 UpperCamelCase_ ...
261
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def lowerCamelCase__ ( a__ : Dict , a__ : Dict=None ) -> Union[str, Any]: UpperCamelCase_ = None if token is n...
261
1
'''simple docstring''' def __UpperCAmelCase ( A : Tuple , A : Any ) -> int: UpperCAmelCase_ : Union[str, Any] = 0 UpperCAmelCase_ : Optional[int] = len(A ) - 1 while left <= right: # avoid divided by 0 during interpolation if sort...
304
'''simple docstring''' import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax i...
304
1
import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import logging as transformers_logging sys.path.a...
366
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class __lowercase ( unittest.TestCase ): ...
35
0
lowerCAmelCase = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] lowerCAmelCase = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] lowerCAmelCase = { 0: '''Sunday''', 1: '''Monday''', 2: '''Tuesday''', 3: '''Wednesday''', 4: '''Thursday''', 5: '''Friday''', 6: '''Saturday''', } ...
295
def _lowerCamelCase( lowercase__ , lowercase__ = " " ) -> list: '''simple docstring''' __lowercase= [] __lowercase= 0 for index, char in enumerate(lowercase__ ): if char == separator: split_words.append(string[last_index:index] ) __lowercase= index + 1 elif in...
295
1
def SCREAMING_SNAKE_CASE ( snake_case_ : list , snake_case_ : list ): _validate_point(snake_case_ ) _validate_point(snake_case_ ) if len(snake_case_ ) != len(snake_case_ ): raise ValueError("Both points must be in the same n-dimensional space" )...
363
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowerCamelCase : Union[str, Any] = { """configuration_time_series_transformer""": [ """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TimeS...
286
0
'''simple docstring''' from datetime import datetime as dt import os from github import Github __lowerCAmelCase = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''feature request''', '''new model''', '''wip''', ] def __lowerCamelCase ...
89
"""simple docstring""" class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self , snake_case__ = "" , snake_case__ = False ): """simple docstring""" lowerCAmelCase : dict[str, RadixNode] = {} ...
108
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase = {} try: if not is_sentencepiece_available(): raise OptionalDepende...
352
"""simple docstring""" import qiskit def lowercase ( a__ : int = 2 ) -> qiskit.result.counts.Counts: _UpperCamelCase = qubits # Using Aer's simulator _UpperCamelCase = qiskit.Aer.get_backend('''aer_simulator''' ) # Creating a Quan...
54
0
"""simple docstring""" import os import pytest from transformers.dynamic_module_utils import get_imports __snake_case = """ import os """ __snake_case = """ def foo(): import os return False """ __snake_case = """ def foo(): def bar(): if True: import ...
203
"""simple docstring""" def __lowerCAmelCase ( ) -> Union[str, Any]: """simple docstring""" snake_case : Dict = [] snake_case : List[Any] = 1 while len(lowercase ) < 1e6: constant.append(str(lowercase ) ) i += 1 ...
203
1
"""simple docstring""" import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.ber...
352
"""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 _a = logging.get_logger(__name__) _a ...
100
0
"""simple docstring""" import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset fro...
17
from __future__ import annotations def __UpperCamelCase ( lowerCAmelCase__ : list[float] , lowerCAmelCase__ : list[float] ): __a : Dict = sorted(numsa + numsa ) __a , __a : Optional[Any] = divmod(len(lowerCAmelCase__ ) , 2 ) if mod == 1: return all_...
216
0
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _UpperCAmelCase ( lowerCAmelCase__): _lowerCAmelCase : Tuple = ["""image_processor""", """tokenizer"""] _lowerCAmelCase : Optional[i...
360
"""simple docstring""" import math import sys def __lowercase ( _a ): if number != int(_a ): raise ValueError('''the value of input must be a natural number''' ) if number < 0: raise ValueError('''the value of input must not be a negative number''' ) if number == ...
155
0
"""simple docstring""" import math import unittest def _a ( _SCREAMING_SNAKE_CASE ) -> 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...
347
"""simple docstring""" from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class __...
347
1
from datetime import datetime import matplotlib.pyplot as plt import torch def __a ( lowerCAmelCase_ : Union[str, Any] ) -> str: '''simple docstring''' for param in module.parameters(): UpperCAmelCase_= False def __a ( ) -> Optional[Any]...
277
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_mo...
277
1
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_...
5
'''simple docstring''' from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class UpperCamelCase__ ( lowercase_ ): """simple docst...
323
0
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): from transfo...
50
a_ = [ 'DownloadConfig', 'DownloadManager', 'DownloadMode', 'StreamingDownloadManager', ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manager import StreamingDownloadManager
50
1
import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUID...
20
"""simple docstring""" import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin ...
320
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, i...
353
"""simple docstring""" def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : list[int] , _UpperCAmelCase : str ): lowerCAmelCase = int(_UpperCAmelCase ) # Initialize Result lowerCAmelCase = [] # Traverse through all denomination for denomination in reversed(_UpperCAmelCa...
309
0
"""simple docstring""" import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def UpperCAmelCase__ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase...
286
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": __lowerCamelCase : str = input('''Enter image url: ''').strip() print(F"""Downloading image from {url} ...""") __lowerCamelCase : Any = BeautifulSoup(requests.get(url).conten...
219
0
import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def __lowerCamelCase ( lowerCamelCase__ : Tuple ): '''simple ...
361
import math import tensorflow as tf from packaging import version def __lowerCamelCase ( lowerCamelCase__ : Optional[Any] ): '''simple docstring''' lowerCamelCase = tf.convert_to_tensor(lowerCamelCase__ ) lowerCamelCase = 0.5 * (1.0 + tf.math....
66
0
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def a__ ( __UpperCamelCase ): SCREAMING_SNAKE_CASE_ = [] embed.app...
118
'''simple docstring''' import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers...
162
0
from math import pow, sqrt def SCREAMING_SNAKE_CASE__ ( *_UpperCAmelCase ) -> bool: '''simple docstring''' lowerCAmelCase : List[str] = len(a__ ) > 0 and all(value > 0.0 for value in values ) return result def SCREAMING_SNAKE_CASE__ ( _UpperCAme...
361
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __A : Any = logging.get_logger(__name__) __A : Union[str, Any] = { '''shi-labs/dinat-mini-...
323
0
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProcessing ...
227
from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize('repo_id' , ['canonical_dataset_name', 'org-name/dataset-name'] ) @pytest.mark.parametrize('path' , ['filename.csv', 'filename with blanks.csv'] ) @pytest.mark.parametrize('revision' ...
329
0
"""simple docstring""" import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def _snake_case ( lowercase__ : Any , lowercase__ : List[Any]=1 ) -> List[str]: '''simple docstring''' ...
1
"""simple docstring""" import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class _SCREAMING_SNAKE_CASE : def __init__( self , __A ) -> Union[...
1
1
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Config...
275
import random def __lowerCamelCase ( snake_case__ ) -> bool: """simple docstring""" _SCREAMING_SNAKE_CASE = num - 1 _SCREAMING_SNAKE_CASE = 0 while s % 2 == 0: _SCREAMING_SNAKE_CASE = s // 2 ...
306
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_funnel import FunnelTokenizer lowercase : List[Any] = logging.get_log...
367
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask f...
225
0
from collections import Counter from timeit import timeit def UpperCamelCase ( snake_case__ : str = "" , ) -> bool: return sum(c % 2 for c in Counter(input_str.replace(' ' , '' ).lower() ).values() ) < 2 def UpperCamelCase ( snake_case__ : str = "" ) -> bool:...
119
from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class lowerCAmelCase_ ( a__ ): def __init__( self, SCREAMING_SNAKE_CASE_, SCREAMING...
119
1
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 ( TFBaseModelOutputWithNoAttention, TFBaseMode...
362
def __UpperCAmelCase ( __a : int ,__a : int ,__a : int ) -> int: """simple docstring""" if exponent == 1: return base if exponent % 2 == 0: _a : List[Any] = _modexpt(__a ,exponent // 2 ,__a ) % mod...
15
0
"""simple docstring""" from __future__ import annotations from typing import Any class __A : def __init__( self , a__ = 6 ): _lowerCAmelCase : Union[str, Any] = None _lowerCAmelCase : str = None self.create_linked_list(__A ...
44
'''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''')): raise Option...
53
0
"""simple docstring""" from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig A_ = logging.get_logger(__name__) A_ = 'T5Config' class lowercase( _lowerCamelCase...
353
"""simple docstring""" from typing import Any class lowercase: '''simple docstring''' def __init__( self: Dict, a_: Any ): '''simple docstring''' _snake_case : Dict = data _snake_case : Optional[Any] ...
132
0
"""simple docstring""" from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class UpperCAmelCase (UpperCAmelCase__ ): """simple docstring""" def _snake_case ( self ): return [ {"col_1": 3, "col_2": "a"}, ...
177
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class _lowercase ( UpperCAmelCase__ ): '''simple docstring''' @staticmethod @abstractmethod def a ( SCREAMING_SNAKE_CASE__ : ArgumentParser ) -> Tup...
229
0
"""simple docstring""" from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) UpperCamelCase_ =299_792_458 # Symbols UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ =symbols("""c...
128
"""simple docstring""" from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils i...
128
1
def UpperCamelCase__( UpperCamelCase__ : list[list[float]] )->Tuple: A__ = [] for data in source_data: for i, el in enumerate(SCREAMING_SNAKE_CASE_ ): if len(SCREAMING_SNAKE_CASE_ ) < i + 1: da...
193
'''simple docstring''' def __a(SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int ): '''simple docstring''' while a != 0: _lowerCAmelCase , _lowerCAmelCase = b % a, a return b def __a(SCREAMING_SNAKE_CASE_ : int , SCREAMING...
158
0
"""simple docstring""" import math from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { """facebook/data2vec-base-960h""": """https://huggingface.co/facebook/data2...
12
"""simple docstring""" import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency lowercase__ = { """E""": 12.70, """T""": 9.06, """A""": 8.17, """O""": 7.51, """I""": 6.97, """N""": 6.75, """S""": 6.33, """H""": ...
12
1
import heapq def _lowerCamelCase( lowercase__ ) -> List[str]: '''simple docstring''' __lowercase= [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works with a min p...
295
'''simple docstring''' import math class lowerCAmelCase : def snake_case ( self : Optional[int] , __lowercase : list[list[float]] , __lowercase : list[int] ): """simple docstring""" __lowercase =0.0 ...
141
0
"""simple docstring""" import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class __a (__a , unittest.TestCase): ...
359
"""simple docstring""" import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import t...
56
0
"""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 _a : str=...
172
"""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 _a : str=...
172
1
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffu...
363
'''simple docstring''' import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, L...
160
0
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available(check_device=Fa...
99
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Dict = logging.get_logger(__name__) __A : Union[str, Any] = { '''facebook/vit-mae-base''': '''https://huggingface.co/facebook/vit-mae-base/resolve/ma...
33
0
def snake_case_ (UpperCamelCase : int , UpperCamelCase : int , UpperCamelCase : int ): '''simple docstring''' _a = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total...
360
'''simple docstring''' from ..utils import DummyObject, requires_backends class A ( metaclass=_a ): lowercase_ = ['torch', 'scipy'] def __init__( self : Tuple , *lowerCAmelCase_ : str , **lowerCAmelCase_ : Any ) -> ...
179
0
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow class lowerCamelCase_ ...
43
from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, PILImageResampling, get_image_size...
43
1
from math import ceil def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : int = 1_0_0_1 ): '''simple docstring''' __snake_case : Optional[Any] = 1 for i in range(1 , int(ceil(n / 2.0 ) ) ): __snake_case : Tuple = 2 * i + 1 __snak...
20
from __future__ import annotations def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : list , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : int ): '''simple docstring''' __snake_case : str = [] ...
20
1
'''simple docstring''' from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf im...
311
import argparse import hashlib # hashlib is only used inside the Test class import struct class __magic_name__ : '''simple docstring''' def __init__( self, lowercase_ ) -> List[str]: """simple docstring""" a__ =data a__ =[0X67452301, 0Xefcda...
188
0
"""simple docstring""" import argparse from collections import defaultdict def UpperCamelCase_ ( lowerCAmelCase__ : Any , lowerCAmelCase__ : Union[str, Any] , lowerCAmelCase__ : int , lowerCAmelCase__ : Optional[Any] , lowerCAmel...
289
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : str , lowerCAmelCase__ : str ) -> int: """simple docstring""" if len(lowerCAmelCase__ ) != len(lowerCAmelCase__ ): raise ValueError('String lengths must match...
289
1
from __future__ import annotations def lowerCamelCase__ ( _a , _a): print(f"Vertex\tShortest Distance from vertex {src}") for i, d in enumerate(snake_case__): print(f"{i}\t\t{d}") def lowerCamelCase__ ( _a , _a , _a): for j in range(snake_case__): SCREA...
76
"""simple docstring""" from itertools import permutations def lowercase (snake_case__ : tuple ) -> bool: '''simple docstring''' if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 ...
155
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : str = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', 'JukeboxVQVAEConfig', ...
370
from __future__ import annotations def __lowerCAmelCase ( a__ , a__ = None ) -> list[list[str]]: __a = word_bank or [] # create a table __a = len(a__ ) + 1 __a = [] for _ in range(a__ ): table.append([] ) # seed value...
33
0
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_s...
211
'''simple docstring''' from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar __SCREAMING_SNAKE_CASE :Optional[int] = TypeVar('''T''') class A_ ( Generic[T] ): def __init__( self : List[Any] , snake_case_ ...
22
0
import json import os import torch from diffusers import UNetaDModel os.makedirs('hub/hopper-medium-v2/unet/hor32', exist_ok=True) os.makedirs('hub/hopper-medium-v2/unet/hor128', exist_ok=True) os.makedirs('hub/hopper-medium-v2/value_function', exist_ok=True) def lowerCAmelCase_ ( snake_case_ : Dict...
353
'''simple docstring''' from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def lowerCAmelCase_ ( ) -> str: '''simple docstring''' UpperCAmelCase_ = { "repo_name": ["test_repo1"...
106
0