code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase_ = { "configuration_efficientformer": [ "EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", ...
411
a__ : Tuple = "Tobias Carryer" from time import time class UpperCAmelCase__: '''simple docstring''' def __init__( self : str , lowerCAmelCase : List[str] , lowerCAmelCase : Any , lowerCAmelCase : str , lowerCAmelCase : ...
622
0
"""simple docstring""" from sklearn.metrics import mean_squared_error import datasets UpperCamelCase_ : Optional[Any] = '''\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. ...
482
"""simple docstring""" import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from tra...
482
1
"""simple docstring""" from __future__ import annotations import math def _UpperCamelCase ( _A ) -> list[int]: """simple docstring""" if num <= 0: _UpperCAmelCase = F"""{num}: Invalid input, please enter a positive integer.""" raise ValueError(_A ) _Up...
555
"""simple docstring""" import warnings from functools import wraps from typing import Callable def _UpperCamelCase ( _A ) -> Callable: """simple docstring""" @wraps(_A ) def _inner_fn(*_A , **_A ): warnings.warn( (F"""'{fn.__name__}' is experiment...
555
1
'''simple docstring''' import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import ...
220
'''simple docstring''' from __future__ import annotations from random import random from typing import Generic, TypeVar __UpperCAmelCase = TypeVar('KT') __UpperCAmelCase = TypeVar('VT') class _a ( Generic[KT, VT] ): """simple docstring""" def __...
220
1
'''simple docstring''' from ...processing_utils import ProcessorMixin class _snake_case ( __UpperCAmelCase ): _A : Optional[int] = 'WhisperFeatureExtractor' _A : Optional[Any] = 'WhisperTokenizer' def __init__( self : str ,SCREAM...
143
"""simple docstring""" import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger lowerCAmelCase__ = get_logger(__name__) lowerCAmelCase__ = r'\n Args:\n input_ids (`jnp.ndarray` of ...
621
0
import argparse from pathlib import Path import fairseq import torch from fairseq.models.xmod import XMODModel as FairseqXmodModel from packaging import version from transformers import XmodConfig, XmodForMaskedLM, XmodForSequenceClassification from transformers.utils import logging if version.parse(fairseq.__ve...
713
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @dataclass class...
230
0
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import C...
509
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, A...
509
1
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_colla...
664
from __future__ import annotations def UpperCAmelCase__ ( _SCREAMING_SNAKE_CASE : list )->list: if len(_SCREAMING_SNAKE_CASE ) == 0: return [] _lowerCAmelCase , _lowerCAmelCase = min(_SCREAMING_SNAKE_CASE ), max(_SCREAMING_SNAKE_CASE ) _lowerCAmelCase ...
664
1
"""simple docstring""" from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar UpperCAmelCase = TypeVar("""T""") def _snake_case ( __snake_case : int ): """simple docstring""" return (position - 1) // 2...
88
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_...
144
0
from typing import List import numpy as np def a ( snake_case__: dict ): '''simple docstring''' lowercase_ = {key: len(snake_case__ ) for key, value in gen_kwargs.items() if isinstance(snake_case__ , snake_case__ )} if len(set(lists_len...
409
import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('>=', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distributed.check...
409
1
import gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class _low...
89
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class _lowercase : def __init__( self ): snake_case__ : List[str] ="""""" snake_case__ : List[Any] ="""""" snake_case__ : Optional[int] =[] ...
385
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase : Any ={ """configuration_chinese_clip""": [ """CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ChineseCLIPConfig""", ...
504
from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def _lowerCAmelCase (_lowerCAmelCase): return ConvertCommand( args.model_type , args.tf_checkpoint , args.pytorch_dump_output , args.config , args.finetuning_task_name)...
504
1
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate...
95
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 SCREAMING_SNAKE_CASE ( __snake_case ): """simple docstring""" ...
187
0
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import TokenizerTest...
180
from __future__ import annotations from math import pi, sqrt def __lowercase ( snake_case, snake_case ): """simple docstring""" if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: raise ValueError('''Capacita...
180
1
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerationT...
15
"""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 Ada...
174
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase__ = { "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config", "M2M100OnnxConfig"], "tokenization_m2m_100": ["M2M100T...
594
import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) class _a ( lowerCamelCase_ ): """simple docstring""" __SCREAMING_SNAKE_CASE ...
594
1
"""simple docstring""" import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": __A : Dict = argparse.ArgumentParser() par...
231
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : Optional[int] = logging.get_logger(__name__) __A : O...
231
1
"""simple docstring""" 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,...
705
"""simple docstring""" from __future__ import annotations _a : str= "#" class UpperCamelCase : def __init__(self : str) -> None: __snake_case : dict = {} def _lowercase (self : Union[str, Any] , _A : str...
192
0
from __future__ import annotations def A ( lowercase__ : int ) -> list[int]: UpperCamelCase__ :Union[str, Any] = [True] * limit UpperCamelCase__ :int = False UpperCamelCase__ :Optional[Any] = False UpperCamelCase__ :str = True for i in range(3 , int...
45
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_en...
1
0
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class lowercase__: """simple docstring""" def __init__( self : str , SC...
409
from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json', 'tiiuae/falcon-7b': 'https://huggingface.co/tiiuae/falcon...
409
1
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-...
495
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB 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/l...
495
1
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .s...
345
from __future__ import annotations from typing import Any def __lowercase( __snake_case : list ) -> int: if not postfix_notation: return 0 __snake_case = {'+', '-', '*', '/'} __snake_case = [] for token in postfix_notation: ...
345
1
"""simple docstring""" import functools def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): # Validation if not isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) or not all(isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) for day in days ): ...
82
"""simple docstring""" import unittest from transformers import MraConfig, 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, floats_tensor, ids...
82
1
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class UpperCAmelCase ...
139
lowercase__ : Optional[int] = range(2, 20 + 1) lowercase__ : List[str] = [10**k for k in range(ks[-1] + 1)] lowercase__ : dict[int, dict[int, list[list[int]]]] = {} def lowerCamelCase__ ( _A , _A , _A , _A ): '''simple docstring''...
139
1
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging __magic_na...
576
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers impor...
576
1
'''simple docstring''' from __future__ import annotations def snake_case_ ( _lowerCAmelCase : int ) -> bool: UpperCAmelCase : Dict = str(UpperCamelCase__ ) return len(UpperCamelCase__ ) == 9 and set(UpperCamelCase__ ) == ...
720
'''simple docstring''' from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup UpperCamelCase__: Union[str, Any] = "https://www.indeed.co.in/jobs?q=mobile+app+development&l=" def snake_case_ ( _l...
528
0
"""simple docstring""" import os from datetime import datetime as dt from github import Github UpperCamelCase = [ 'good first issue', 'good second issue', 'good difficult issue', 'enhancement', 'new pipeline/model', 'new scheduler', 'wip', ] def lowerCAmelCase_ () ...
473
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipeli...
473
1
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration _lowercase = { '''tiny.en''': '''https://openaipublic.azureedge.net/main/whisper/models/d3dd57d3...
703
from ... import PretrainedConfig _lowercase = { '''sijunhe/nezha-cn-base''': '''https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json''', } class __A ( A_ ): UpperCamelCase :Optional[Any] = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP UpperCamelCase :int...
96
0
import warnings from .generation import TFGenerationMixin class a ( _A ): '''simple docstring''' warnings.warn( 'Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will ' 'be removed in Transformers v5....
144
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_...
144
1
"""simple docstring""" from math import sqrt def __a ( _lowercase ): """simple docstring""" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multi...
121
"""simple docstring""" import fire from utils import calculate_rouge, save_json def __a ( _lowercase , _lowercase , _lowercase=None , **_lowercase ): """simple docstring""" lowerCamelCase__ : str = [x.strip() for x in open(_lowercase )...
121
1
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = " " ): snake_case_ = [] snake_case_ = 0 for index, char in enumerate(a_ ): if char == separator: split_words.append(string[last_index:index] ) ...
39
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'microsoft/wavlm-base': 'https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json', # See ...
494
0
import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizerOutpu...
218
def snake_case_ (__A : int = 1_0**9 ) -> int: __lowerCAmelCase : Any = 1 __lowerCAmelCase : Optional[int] = 2 __lowerCAmelCase : List[Any] = 0 __lowerCAmelCase : Union[str, Any] = 0 __lowerCAmelCase :...
218
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformer...
652
'''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_distilbert import DistilBertTokenizer __SCREAMING_SNAKE_CASE = logging.get_lo...
688
0
import numpy as np def snake_case_ (_a : np.ndarray , _a : float ): return np.where(vector > 0 , _a , (alpha * (np.exp(_a ) - 1)) ) if __name__ == "__main__": import doctest doctest.testmod()
717
'''simple docstring''' import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, 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...
358
0
import warnings 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_ : Any = logging.get_logger(__name__) Upp...
21
'''simple docstring''' def _a (__SCREAMING_SNAKE_CASE ): """simple docstring""" _UpperCamelCase =[0] * len(__SCREAMING_SNAKE_CASE ) for i in range(1 , len(__SCREAMING_SNAKE_CASE ) ): # use last results for better performance - dynamic programming _UpperCamelCase ...
404
0
"""simple docstring""" def lowerCamelCase__ ( __snake_case = 1_00_00_00 ) -> int: """simple docstring""" _UpperCamelCase = limit + 1 _UpperCamelCase = [0] * limit for first_term in range(1, __snake_case ): for n...
703
"""simple docstring""" import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# _a = [ # (stable-diffusion, HF Diffusers) ("""time_embed.0.weight""", "...
78
0
import os import numpy import onnx def __snake_case ( _lowerCAmelCase : List[Any] , _lowerCAmelCase : List[Any] ) -> Optional[int]: A_ : Union[str, Any] = a.name A_ : List[str] = b.name A_ : Any = ""...
454
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProces...
392
0
from collections import Counter from timeit import timeit def lowerCAmelCase_ ( lowerCamelCase = "" , ): return sum(c % 2 for c in Counter(input_str.replace(""" """ , """""" ).lower() ).values() ) < 2 def lowerCAmelCase_ ( lowerCamelCase = "" ): if len(lowe...
719
# 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 # # Unless req...
367
0
"""simple docstring""" def a ( __snake_case : list ): '''simple docstring''' if len(__snake_case ) <= 1: return lst UpperCAmelCase_ :Union[str, Any] = 1 while i < len(__snake_case ): if lst[i - 1] <= lst[i]: i += 1 else: ...
608
"""simple docstring""" from __future__ import annotations from collections.abc import MutableSequence class _snake_case : '''simple docstring''' def __init__( self : Dict , snake_case : int , snake_case : MutableSequence[float] ): if len(snake_case ) !=...
608
1
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipel...
225
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 import F...
225
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case : Dict = logging.get_logger(__name__) __snake_case : Tuple = { """sayakpaul/vit-msn-base""": """https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json""", # See all ViT ...
540
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 ...test_modeling_common...
540
1
import math def A_ ( snake_case : Optional[Any] ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all mult...
701
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowercase__ : Tuple = logging.get_logger(__name__) lo...
451
0
'''simple docstring''' def A_( A : int): UpperCamelCase , UpperCamelCase = [], [] while len(A) > 1: UpperCamelCase , UpperCamelCase = min(A), max(A) start.append(A) end.append(A) collection.remove(A) ...
3
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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLI...
364
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : List[Any] = logging.get_logger(__name__) __lowerCamelCase : Tuple = { '''RWKV/rwkv-4-169m-pile''': '''https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json''', '''R...
501
# flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatter, format_table, query_table, ) f...
501
1
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict" , [ SplitDict(), SplitDict({"train": SplitInfo(name="train" , num_bytes=1_3_3_7 , num_examples=4_2 , dataset_na...
54
from __future__ import annotations def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" lowercase__ , lowercase__ = position lowercase__ = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1, x - 2), (y - 1, x - 2), ...
43
0
'''simple docstring''' import math _A = 1_0 _A = 7 _A = BALLS_PER_COLOUR * NUM_COLOURS def _UpperCamelCase ( SCREAMING_SNAKE_CASE_ = 20 ): lowercase_ : int = math.comb(lowerCamelCase_ , lowerCamelCase_ ) lowercase_ ...
713
'''simple docstring''' import math import os import sys def _UpperCamelCase ( SCREAMING_SNAKE_CASE_ ): lowercase_ : List[str] = '' try: with open(SCREAMING_SNAKE_CASE_ , 'rb' ) as binary_file: lowercase_ : Di...
438
0
import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.utils i...
33
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils imp...
401
0
"""simple docstring""" from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils impor...
712
"""simple docstring""" import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils impor...
251
0
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from diffusers.utils...
62
# NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet ...
108
0
import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorState from acc...
714
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, ...
388
0
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class _snake_case ( u...
143
'''simple docstring''' def A_ ( snake_case ): SCREAMING_SNAKE_CASE:str = [1] SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE:List[str] = 0, 0, 0 SCREAMING_SNAKE_CASE:List[str] = ugly_nums[ia] * 2 SCREAMING_SNAKE_CASE:Union[str,...
143
1
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _lowerCamelCase : O...
157
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, l...
157
1
import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor _snake_case : Optional[int] = logging.get_logger(__name__) class a (_lowerCAmelCase ): """simple docstring""" def __init__( self : Optional[Any] , ...
81
'''simple docstring''' import math def lowercase__ ( __lowercase : int ) -> int: """simple docstring""" if not isinstance(__lowercase , __lowercase ): __UpperCamelCase = F'''Input value of [number={number}] must be an integer''' rai...
399
0
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 ( _lowerCamelCase ): def __init__( self : Optional[int] , ...
710
# flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatter, format_table, query_table, ) f...
501
0
'''simple docstring''' import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from trans...
109
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_...
577
0
from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowerCAmelCase = 10 def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , l...
675
import pytest import datasets # Import fixture modules as plugins lowerCAmelCase = ["""tests.fixtures.files""", """tests.fixtures.hub""", """tests.fixtures.fsspec"""] def __SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> str: '''simple docstring''' ...
675
1
import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock import patch import...
651
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { """camembert-base""": """https://hu...
651
1
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { '''facebook/wav2vec2-base-960h''': '''https://huggingface.co/facebook/wav2vec2-base-960h/reso...
700
"""simple docstring""" import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING ...
101
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, norm...
8
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf ...
159
0
import unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_i...
81
# 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 appli...
81
1
"""simple docstring""" import math import sys def lowercase__(A ) ->int: """simple docstring""" if number != int(A ): raise ValueError("the value of input must be a natural number" ) if number < 0: raise Val...
218
"""simple docstring""" def lowercase__(A ) ->str: """simple docstring""" if isinstance(A , A ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(A , A ): raise TypeErro...
218
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowerCAmelCase = { "configuration_ctrl": ["CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP", "CTRLConfig"], "tokenization_ctrl": ["CTRLTokenizer"], } try: if not is...
719
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { "EleutherAI/gpt-neox-20b": "https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json", # See all GPTNeoX models at https://huggingface.c...
71
0
from typing import Any def __A ( _A ): """simple docstring""" if not input_list: return [] __a = [input_list.count(_A ) for value in input_list] __a = max(_A ) # Gets the maximum count in the input list. # Gets values of modes return sorted({input_li...
197
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
197
1
'''simple docstring''' import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL...
715
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers...
126
0
_lowerCamelCase : str = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} _lowerCamelCase : Union[str, Any] = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def _lowerCAmelCase ( __magic_name__ :dict[int, list[int]] , __magic_name__ :int , ...
121
import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.auto.modeli...
121
1
from __future__ import annotations def A__ ( __lowerCamelCase, __lowerCamelCase ): print(F'''Vertex\tShortest Distance from vertex {src}''' ) for i, d in enumerate(__lowerCamelCase ): print(F'''{i}\t\t{d}''' ) def A__ ( __lowerCamelCase, __lowerCamelCase, __low...
704
import numpy as np def A__ ( __lowerCamelCase, __lowerCamelCase, __lowerCamelCase, __lowerCamelCase, __lowerCamelCase ): SCREAMING_SNAKE_CASE_ = int(np.ceil((x_end - xa) / h ) ) SCREAMING_SNAKE_CASE_ = np.zeros((n + 1,) ) SCREAMING_SNAKE_CASE_ = ya SCREAMING_SNAKE_CASE_ ...
597
0
from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class lowerCAmelCase__ : A_ : str = field( metadata={'help': 'The output...
106
from sklearn.metrics import mean_squared_error import datasets lowerCAmelCase_ = '''\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blondel, M. and Pre...
60
0
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ : Tuple = logging.get_logger(__name__) a_ : Union[str, Any] = { 'google/pegasus-large': 'https://huggingface.co/google/pegasus-large/resolve/main/config.json', # See a...
714
def _SCREAMING_SNAKE_CASE ( snake_case_ : str ): return " ".join( ''''''.join(word[::-1] ) if len(snake_case_ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words('Hey wollef sroirraw'))
678
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer a__ = logging.get_logger(__name__) a__ = ...
477
import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_available, ) ...
477
1
'''simple docstring''' from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class UpperCame...
708
'''simple docstring''' import math class UpperCamelCase__ : """simple docstring""" def __init__( self : List[str] , lowerCamelCase_ : Tuple=0 ): # a graph with Node 0,1,...,N-1 '''simple docstring''' SCREAMING_SNAKE_CASE : Any = n SCR...
79
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCamelCase__ : Union[str, Any] = { """configuration_xlm_roberta_xl""": [ """XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMRobert...
33
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('ignore', category=UserWarning, module='torch.optim.lr_scheduler') class __lowerCAmelCase : ...
291
0
"""simple docstring""" from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): imp...
309
"""simple docstring""" import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_dev...
309
1
import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_flax_common import FlaxModelTes...
354
from collections.abc import Sequence from queue import Queue class __a : def __init__( self : str , snake_case_ : List[str] , snake_case_ : Tuple , snake_case_ : Tuple , snake_case_ : Optional[Any]=None , snake_case_ ...
354
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : Dict = {'''configuration_wavlm''': ['''WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''WavLMConfig''']} try: if not is_torch_ava...
710
'''simple docstring''' import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetectio...
474
0
from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class lowerCamelCase ( __lowerCamelCase , __lowerCamelCase ): @register_to_config def __init__( sel...
462
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _lowerCamelCase : List[str] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAva...
663
0
from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class UpperCAmelCase_ ( _A ): a__ = None a...
706
import math def a__ ( A_, A_ = 0, A_ = 0 ): '''simple docstring''' __magic_name__ = end or len(A_ ) for i in range(A_, A_ ): __magic_name__ = i __magic_name__ = array[i] while temp_index != start and temp_index_value < arra...
76
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCAmelCase_ : Dict = {'''processing_layoutxlm''': ['''LayoutXLMProcessor''']...
17
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __A ={ '''configuration_gpt_neo''': ['''GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoConfig''', '''GPTNeoOnnxConfig'''], } try: if not is_torch_available(): ...
463
0
'''simple docstring''' import math def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ) -> float: if initial_intensity < 0: raise ValueError('The value of intensity cannot be negative' ) # handling of negative values of initial intensity if angle < 0 ...
705
'''simple docstring''' def _UpperCamelCase ( __UpperCamelCase = 1 ,__UpperCamelCase = 10_00 ) -> int: lowerCamelCase_ = 1 lowerCamelCase_ = 0 for divide_by_number in range(__UpperCamelCase ,digit + 1 ): lowerCamelCase_ = [] ...
384
0
'''simple docstring''' import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def snake_case_ ( ): '''simple docstring''' raise RuntimeError("CUDA out of memory."...
672
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __magic_name__ : Optional[int] = { """configuration_swiftformer""": [ """SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
672
1
def __lowerCAmelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE )-> int: """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def __lowerCAmelCase ()-> None: """simple docstring""" assert and_gate(0 , 0 ...
531
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging UpperCAmelCase = logging.get_logger(__name__) def __lowerCAmelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ...
531
1
"""simple docstring""" import gc import unittest from transformers import CTRLConfig, 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 ....
49
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def lowerCAmelCase_ ( _lowerCamelCase: Optional[int] , _lowerCamelCase: str , _lowerCamelCase: str , _lowerCamel...
578
0
'''simple docstring''' from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class __magi...
7
'''simple docstring''' from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import ...
7
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase_ : Optional[int] = { '''configuration_canine''': ['''CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
255
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('ignore', category=UserWarning, module='torch.optim.lr_scheduler') class __lowerCAmelCase : ...
291
0
import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import tensorflow as tf from tokenizers import pre_...
708
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING...
182
0
from __future__ import annotations a__ = list[list[int]] # assigning initial values to the grid a__ = [ [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, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5], ...
14
def __lowerCamelCase ( _lowercase ) -> list: UpperCamelCase = len(_lowercase ) for _ in range(_lowercase ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: UpperCamelCase , UpperCa...
282
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ...
653
'''simple docstring''' from __future__ import annotations import os from typing import Any import requests lowercase_ : List[str] = '''https://api.github.com''' # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user lowercase_ : Any =...
653
1
'''simple docstring''' import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common impor...
577
'''simple docstring''' import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, ...
577
1
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def UpperCAmelCase ( A : Optional[int] , A : Dict , A : Union[str, Any] ): '''simple docstring''' ...
710
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers....
24
0
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 _lowercase ( a__ : int ) -> str: "...
147
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def _lowercase ( a__ : Dict ) -> Any: """simple docstring""" if not is_accelerate_available(): return method _UpperCamelCase = version.parse(...
147
1
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentParser, ...
152
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
152
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE :int = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :List[str] = { 'SenseTime/deformable-detr': 'https://huggingface.co/sens...
55
from __future__ import annotations from dataclasses import dataclass @dataclass class UpperCAmelCase : '''simple docstring''' lowerCAmelCase_ = 42 lowerCAmelCase_ = None lowerCAmelCase_ = None def lowerCamelC...
376
0
"""simple docstring""" from PIL import Image def lowercase__ ( lowercase_ ) -> Union[str, Any]: """simple docstring""" _UpperCamelCase : Dict = image.size _UpperCamelCase : Union[str, Any] = 0 _UpperCamelCase : Optional[int] ...
714
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def lowercase__ ( lowercase_ = 1_000_000 ,lowercase_ = 10 ) -> int: """simple docstring""" _UpperCamelCase : defaultdict = defaultdict(lowercase_ ) for outer_w...
51
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule _A: Dict = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import s...
126
'''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 UpperCAmelCase ( UpperCAmelCase_ ...
126
1
from collections.abc import Iterable from typing import Generic, TypeVar __UpperCAmelCase : Dict = TypeVar("_T") class __snake_case ( Generic[_T] ): '''simple docstring''' def __init__( self : Union[str, Any] , A : Ite...
155
import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def A__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__) ...
155
1
import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion import Stable...
429
def _UpperCAmelCase (UpperCamelCase_ : int , UpperCamelCase_ : float , UpperCamelCase_ : float ): '''simple docstring''' return round(float(moles / volume ) * nfactor ) def _UpperCAmelCase (UpperCamelCase_ : float , UpperCamelCase_ : float...
429
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_ ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase=1024 , _lowerCAmelCase=1024 , _lowerCAmelC...
721
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_f...
38
0
import math class lowerCamelCase_ : def __init__( self : Union[str, Any] , __A : List[str]=0 ): # a graph with Node 0,1,...,N-1 __A : List[str] = n __A : List[str] = [ [math.inf for j in range(0 , __A )] for i in ran...
17
from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neuroncore, ...
154
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _lowerCAmelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDepende...
705
"""simple docstring""" import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO, ) _lowerCAmelCase = ...
480
0
class lowercase_ : def __init__( self , lowercase_ , lowercase_=None , lowercase_=None) -> Tuple: a__ =data a__ =previous a__ =next_node def __str__( self) -> str: return F"""{self.data}""" de...
20
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json', } ...
665
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 tra...
333
def UpperCAmelCase_( a__ ): """simple docstring""" return 10 - x * x def UpperCAmelCase_( a__ , a__ ): """simple docstring""" if equation(a__ ) * equation(a__ ) >= 0: raise ValueError('''Wrong space!''' ) SCREAMING_SNAKE...
333
1