code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
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 snake_case__ ( SCREAMING_SNAKE_CASE_ : int ): '''simple docstring'...
214
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCAmelCase : int = {"configuration_swin": ["SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwinConfig", "SwinOnnxConfig"]} try: if not is_torch_available(): rai...
236
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) snake_case : str = { "configuration_wav2vec2": ["WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP", "Wav2Vec2Config"],...
94
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class __lowerCAmelCase ( datasets.BuilderConfig): _a = None class __lowerCAmel...
236
0
'''simple docstring''' from __future__ import annotations def UpperCamelCase( UpperCAmelCase_ , UpperCAmelCase_ ): # Checks if the entire collection has been sorted if len(UpperCAmelCase_ ) <= 1 or n <= 1: return insert_next(UpperCAmelCase_ , n - 1 ) rec_insertion_so...
151
_UpperCAmelCase : Tuple = {str(digit): digit**5 for digit in range(10)} def UpperCAmelCase__ ( lowerCamelCase ): return sum(DIGITS_FIFTH_POWER[digit] for digit in str(lowerCamelCase ) ) def UpperCAmelCase__ ( ): return sum( number for number in range(1...
236
0
'''simple docstring''' import inspect import unittest from transformers import DecisionTransformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTeste...
346
import numpy # List of input, output pairs _UpperCAmelCase : List[str] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) _UpperCAmelCase : Optional[Any] = (((515, 22, 13), 555), ((61, 35, 49), 150)) _UpperCAmelCase : Tuple = [2, 4, 1, 5...
236
0
from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastapi.routing import APIRou...
343
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.t...
236
0
'''simple docstring''' import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XC...
125
import os import pytest from attr import dataclass _UpperCAmelCase : List[str] = "us-east-1" # defaults region @dataclass class __lowerCAmelCase : _a = 42 _a = '''arn:aws:iam::558105141721:role/sagemaker_execution_role''' _a = { ...
236
0
'''simple docstring''' 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 ...
55
from typing import Union import fire import torch from tqdm import tqdm def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase = "cpu", lowerCamelCase = None ): lowercase :Optional[Any] = torch.load(lowerCamelCase, map_location=lowerCamelCase ) for k, v in tqdm(state_dict.items...
236
0
'''simple docstring''' import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowercase : List[str] = logging.get_logger(__name__) class lowerCAmelCase__ ( ...
93
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging...
236
0
'''simple docstring''' from collections.abc import Sequence def UpperCamelCase_ ( _UpperCAmelCase : List[str] = None ) -> Tuple: """simple docstring""" if nums is None or not nums: raise ValueError("Input sequence should not be empty" ) _Upp...
31
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase ): # Return True if there is node that has not iterated. lowercase :Union[str, Any] = [False] * len(lowerCamelCase ) lowercase :Union[str, Any] = [] queue.append(lowerCamelCase ...
236
0
'''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 impor...
319
import os from math import logaa def UpperCAmelCase__ ( lowerCamelCase = "base_exp.txt" ): lowercase :float = 0 lowercase :str = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(lowerCamelCase ), lowerCamelCase ) ) ): lowercase , low...
236
0
'''simple docstring''' import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class __lowerCAmelCase (lowercase_ , lowercase_ ): ...
2
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase ): lowercase :List[str] = "" for word_or_phrase in separated: if not isinstance(lowerCamelCase, lowerCamelCase ): raise Exception("join() accepts only strings to be joined" ) joined += word_or_phrase + separa...
236
0
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__snake_case ) class SCREAMING_SNAKE_CASE__ (__snake_case ): __lowerCamelCase : Dict = field(default="...
214
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTest...
236
0
import os import sys import unittest snake_case : List[str] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_obj...
94
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureExt...
236
0
'''simple docstring''' # Lint as: python3 import itertools import os import re lowercase__ = re.compile(r"([A-Z]+)([A-Z][a-z])") lowercase__ = re.compile(r"([a-z\d])([A-Z])") lowercase__ = re.compile(r"(?<!_)_(?!_)") lowercase__ = re.compile(r"(_{2,})") lowercase__...
151
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : List[str] = { "configuration_blenderbot": [ "BLENDERBOT_PRETRAINED_CON...
236
0
'''simple docstring''' import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate UpperCAmelCase_ = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow('', '|'...
346
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : List[Any] = {"voca...
236
0
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, AutoF...
343
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig _UpperCAmelCase : Tuple = { "susnato/ernie-m-base_pytorch": "https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json", "susnato/ernie-m-large_pytorch": "https://huggingfa...
236
0
'''simple docstring''' import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : int, SCREAMING_SNAKE_CASE__ : Tuple, SCREAMING_SNAKE_CASE__ : Optional[Any], SCREAMING_SNAK...
125
import math import sys def UpperCAmelCase__ ( lowerCamelCase ): if number != int(lowerCamelCase ): 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 == 0: ...
236
0
'''simple docstring''' import re import string import numpy as np import datasets a_ : Dict = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" a_ : Any = "\nArgs:\n p...
55
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import t...
236
0
'''simple docstring''' import string def snake_case_ ( __SCREAMING_SNAKE_CASE : Optional[int] ): """simple docstring""" for key in range(len(string.ascii_uppercase ) ): lowercase_ : Any = "" fo...
93
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Dict = logging.get_logger(__name__) _UpperCAmelCas...
236
0
'''simple docstring''' def UpperCamelCase_ ( _UpperCAmelCase : Dict ) -> Union[str, Any]: """simple docstring""" return 10 - x * x def UpperCamelCase_ ( _UpperCAmelCase : str , _UpperCAmelCase : Tuple ) -> Dict: """simple d...
31
import torch def UpperCAmelCase__ ( ): if torch.cuda.is_available(): lowercase :Optional[int] = torch.cuda.device_count() else: lowercase :Dict = 0 print(F"Successfully ran on {num_gpus} GPUs" ) if __name__ == "__main__": main()
236
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils i...
319
from typing import TYPE_CHECKING from ....utils import _LazyModule _UpperCAmelCase : Dict = {"tokenization_tapex": ["TapexTokenizer"]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _UpperCAmelCase : Optional[Any] = _LazyModule(__name__, globals()["...
236
0
'''simple docstring''' 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 lowerCamelCase : int = logging.get_logger(__name__) ...
2
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accel...
236
0
def snake_case__ ( SCREAMING_SNAKE_CASE_ : int ): '''simple docstring''' if not numbers: return 0 if not isinstance(SCREAMING_SNAKE_CASE_ , (list, tuple) ) or not all( isinstance(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) for number in numbers ...
214
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCAmelCase : int = {"configuration_swin": ["SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwinConfig", "SwinOnnxConfig"]} try: if not is_torch_available(): rai...
236
0
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() snake_case : int = logging.get_logger(__name__) snake_case : Optional[Any] = {name: getattr(transformers, na...
94
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class __lowerCAmelCase ( datasets.BuilderConfig): _a = None class __lowerCAmel...
236
0
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase__ = logging.get_lo...
151
_UpperCAmelCase : Tuple = {str(digit): digit**5 for digit in range(10)} def UpperCAmelCase__ ( lowerCamelCase ): return sum(DIGITS_FIFTH_POWER[digit] for digit in str(lowerCamelCase ) ) def UpperCAmelCase__ ( ): return sum( number for number in range(1...
236
0
'''simple docstring''' 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...
346
import numpy # List of input, output pairs _UpperCAmelCase : List[str] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) _UpperCAmelCase : Optional[Any] = (((515, 22, 13), 555), ((61, 35, 49), 150)) _UpperCAmelCase : Tuple = [2, 4, 1, 5...
236
0
import math def lowercase( ) -> Optional[int]: '''simple docstring''' UpperCamelCase = input("""Enter message: """ ) UpperCamelCase = int(input(f"""Enter key [2-{len(UpperCamelCase_ ) - 1}]: """ ) ) UpperCamelCase = input("""Encryption/Decryptio...
343
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.t...
236
0
'''simple docstring''' import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin snake_case_ : Any ...
125
import os import pytest from attr import dataclass _UpperCAmelCase : List[str] = "us-east-1" # defaults region @dataclass class __lowerCAmelCase : _a = 42 _a = '''arn:aws:iam::558105141721:role/sagemaker_execution_role''' _a = { ...
236
0
'''simple docstring''' import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers,...
55
from typing import Union import fire import torch from tqdm import tqdm def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase = "cpu", lowerCamelCase = None ): lowercase :Optional[Any] = torch.load(lowerCamelCase, map_location=lowerCamelCase ) for k, v in tqdm(state_dict.items...
236
0
'''simple docstring''' import comet # From: unbabel-comet import torch import datasets _lowercase : List[Any] = datasets.logging.get_logger(__name__) _lowercase : Any = "\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Crai...
93
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging...
236
0
'''simple docstring''' from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig __SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Tuple = "T5Conf...
31
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase ): # Return True if there is node that has not iterated. lowercase :Union[str, Any] = [False] * len(lowerCamelCase ) lowercase :Union[str, Any] = [] queue.append(lowerCamelCase ...
236
0
'''simple docstring''' def SCREAMING_SNAKE_CASE( __lowercase , __lowercase ) -> Union[str, Any]: A: List[str] = "" for word_or_phrase in separated: if not isinstance(__lowercase , __lowercase ): raise Exce...
319
import os from math import logaa def UpperCAmelCase__ ( lowerCamelCase = "base_exp.txt" ): lowercase :float = 0 lowercase :str = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(lowerCamelCase ), lowerCamelCase ) ) ): lowercase , low...
236
0
'''simple docstring''' from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_...
2
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase ): lowercase :List[str] = "" for word_or_phrase in separated: if not isinstance(lowerCamelCase, lowerCamelCase ): raise Exception("join() accepts only strings to be joined" ) joined += word_or_phrase + separa...
236
0
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_tests_di...
214
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTest...
236
0
from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def __lowerCamelCase ( UpperCAmelCase_ : str , UpperCAmelCase_ : Union[str, Any] , UpperCAmelCase_ : str = False ): """simple docstring""" ...
94
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureExt...
236
0
'''simple docstring''' from __future__ import annotations from collections.abc import Callable def UpperCamelCase( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ = 1_00 , ): UpperCAmelCase : Optional[Any] = x_start Upper...
151
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : List[str] = { "configuration_blenderbot": [ "BLENDERBOT_PRETRAINED_CON...
236
0
'''simple docstring''' 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): ...
346
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : List[Any] = {"voca...
236
0
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_con...
343
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig _UpperCAmelCase : Tuple = { "susnato/ernie-m-base_pytorch": "https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json", "susnato/ernie-m-large_pytorch": "https://huggingfa...
236
0
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __a (tf.keras.layers.Layer ): def __init__( self : Optional[Any] , __magic_name__ : str , __magic_name__ : Optional[int] , __magic_name__ : List[...
125
import math import sys def UpperCAmelCase__ ( lowerCamelCase ): if number != int(lowerCamelCase ): 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 == 0: ...
236
0
'''simple docstring''' def __snake_case ( UpperCAmelCase_ : Optional[int] = 1000 ): lowerCamelCase_ = 2**power lowerCamelCase_ = str(UpperCAmelCase_ ) lowerCamelCase_ = list(UpperCAmelCase_ ) lowerCamelCase_ = 0 for i in list_num: sum_of_num += int(U...
55
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import t...
236
0
'''simple docstring''' from manim import * class lowerCAmelCase__ ( lowerCamelCase_ ): def _snake_case ( self ): """simple docstring""" lowercase_ : Tuple = Rectangle(height=0.5 , width=0....
93
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Dict = logging.get_logger(__name__) _UpperCAmelCas...
236
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __SCREAMING_SNAKE_CASE : List[str] = { "configuration_blenderbo...
31
import torch def UpperCAmelCase__ ( ): if torch.cuda.is_available(): lowercase :Optional[int] = torch.cuda.device_count() else: lowercase :Dict = 0 print(F"Successfully ran on {num_gpus} GPUs" ) if __name__ == "__main__": main()
236
0
'''simple docstring''' import os import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer from ...test_tokenization_common import TokenizerTesterMixin class lowerCAmelCase_ ( UpperCAmelCase_ , unittest.TestCase ): ...
319
from typing import TYPE_CHECKING from ....utils import _LazyModule _UpperCAmelCase : Dict = {"tokenization_tapex": ["TapexTokenizer"]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _UpperCAmelCase : Optional[Any] = _LazyModule(__name__, globals()["...
236
0
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class __lowerCAmelCase (datasets.BeamBasedBuilder ): '''simple docstring''' ...
2
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accel...
236
0
from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer snake_case_ = logging.get_logger(__name__) snake_case_ = {"vocab_file": "vocab.json", "merges_file": "merges.txt", "tokeni...
214
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCAmelCase : int = {"configuration_swin": ["SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwinConfig", "SwinOnnxConfig"]} try: if not is_torch_available(): rai...
236
0
from abc import ABC, abstractmethod from argparse import ArgumentParser class _snake_case ( _snake_case ): @staticmethod @abstractmethod def SCREAMING_SNAKE_CASE__ ( _lowerCamelCase ): raise NotImplementedError() @abstractmethod def SCREAMING_SNAKE_CASE__...
94
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class __lowerCAmelCase ( datasets.BuilderConfig): _a = None class __lowerCAmel...
236
0
'''simple docstring''' import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard...
151
_UpperCAmelCase : Tuple = {str(digit): digit**5 for digit in range(10)} def UpperCAmelCase__ ( lowerCamelCase ): return sum(DIGITS_FIFTH_POWER[digit] for digit in str(lowerCamelCase ) ) def UpperCAmelCase__ ( ): return sum( number for number in range(1...
236
0
'''simple docstring''' from typing import Union import fire import torch from tqdm import tqdm def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : Union[str, Any] , SCREAMING_SNAKE_CASE__ : str = "cpu" , SCREAMING_SNAKE_CASE__ : int = None ): '''simple docstring''' UpperCAm...
346
import numpy # List of input, output pairs _UpperCAmelCase : List[str] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) _UpperCAmelCase : Optional[Any] = (((515, 22, 13), 555), ((61, 35, 49), 150)) _UpperCAmelCase : Tuple = [2, 4, 1, 5...
236
0
from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split _SCREAMING_SNAKE_CASE = datasets.load_iris() _SCREAMING_SNAKE_CASE = np.array(data["""data"""]) _SCREAMING_SNAKE_CASE = np.array(data["""target"""]) _S...
343
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.t...
236
0
'''simple docstring''' 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, rand...
125
import os import pytest from attr import dataclass _UpperCAmelCase : List[str] = "us-east-1" # defaults region @dataclass class __lowerCAmelCase : _a = 42 _a = '''arn:aws:iam::558105141721:role/sagemaker_execution_role''' _a = { ...
236
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ : Tuple = { "configuration_lxmert": ["LXMERT_PRETRAINED_CONFIG_ARCHIVE_M...
55
from typing import Union import fire import torch from tqdm import tqdm def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase = "cpu", lowerCamelCase = None ): lowercase :Optional[Any] = torch.load(lowerCamelCase, map_location=lowerCamelCase ) for k, v in tqdm(state_dict.items...
236
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _lowercase : int = ...
93
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging...
236
0
'''simple docstring''' class lowerCamelCase_ : '''simple docstring''' def __init__( self : Optional[Any] , A : int ): _UpperCAmelCase : Optional[int] = size _UpperCAmelCase : Dict = [0] * size ...
31
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase ): # Return True if there is node that has not iterated. lowercase :Union[str, Any] = [False] * len(lowerCamelCase ) lowercase :Union[str, Any] = [] queue.append(lowerCamelCase ...
236
0
'''simple docstring''' import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCamelCase ...
319
import os from math import logaa def UpperCAmelCase__ ( lowerCamelCase = "base_exp.txt" ): lowercase :float = 0 lowercase :str = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(lowerCamelCase ), lowerCamelCase ) ) ): lowercase , low...
236
0
'''simple docstring''' from __future__ import annotations import typing from collections import Counter def _SCREAMING_SNAKE_CASE (A ) -> Optional[Any]: """simple docstring""" lowercase__ = Counter() for base in range(1 , max_perimeter + 1 ):...
2
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase ): lowercase :List[str] = "" for word_or_phrase in separated: if not isinstance(lowerCamelCase, lowerCamelCase ): raise Exception("join() accepts only strings to be joined" ) joined += word_or_phrase + separa...
236
0
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common imp...
214
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTest...
236
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging snake_case : Any = logging.get_logger(__name__) snake_case : List[Any] ...
94
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureExt...
236
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase__ = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "Mask2FormerConfig",...
151
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : List[str] = { "configuration_blenderbot": [ "BLENDERBOT_PRETRAINED_CON...
236
0
'''simple docstring''' def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : str ): '''simple docstring''' UpperCAmelCase__ = len(SCREAMING_SNAKE_CASE__ ) UpperCAmelCase__ = len(matrix[0] ) UpperCAmelCase__ = min(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_C...
346
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : List[Any] = {"voca...
236
0
def lowercase( UpperCamelCase_ ) -> Dict: '''simple docstring''' if num < 0: return False UpperCamelCase = num UpperCamelCase = 0 while num > 0: UpperCamelCase = rev_num * 10 + (num % 10) num //= 10 return num_copy == rev_num if __name__ == "__mai...
343
from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig _UpperCAmelCase : Tuple = { "susnato/ernie-m-base_pytorch": "https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json", "susnato/ernie-m-large_pytorch": "https://huggingfa...
236
0
'''simple docstring''' import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch snake_case_ : Optional[int] = ...
125
import math import sys def UpperCAmelCase__ ( lowerCamelCase ): if number != int(lowerCamelCase ): 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 == 0: ...
236
0
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs i...
55
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import t...
236
0
'''simple docstring''' def snake_case_ ( __SCREAMING_SNAKE_CASE : Union[str, Any] , __SCREAMING_SNAKE_CASE : List[str] ): """simple docstring""" lowercase_ : Union[str, Any] = [0 for i in range(r + 1 )] # ...
93
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Dict = logging.get_logger(__name__) _UpperCAmelCas...
236
0
'''simple docstring''' from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common im...
31
import torch def UpperCAmelCase__ ( ): if torch.cuda.is_available(): lowercase :Optional[int] = torch.cuda.device_count() else: lowercase :Dict = 0 print(F"Successfully ran on {num_gpus} GPUs" ) if __name__ == "__main__": main()
236
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCamelCase = { "configuration_convnext": ["CONVNEXT_PRETRAINED_CONFIG...
319
from typing import TYPE_CHECKING from ....utils import _LazyModule _UpperCAmelCase : Dict = {"tokenization_tapex": ["TapexTokenizer"]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _UpperCAmelCase : Optional[Any] = _LazyModule(__name__, globals()["...
236
0
'''simple docstring''' import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import Threade...
2
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_accel...
236
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable snake_case_ = { "configuration_gpt_neox_japanese": ["GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPTNeoXJapaneseConfig"], "tokenization_gpt_neox_japanese...
214
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _UpperCAmelCase : int = {"configuration_swin": ["SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwinConfig", "SwinOnnxConfig"]} try: if not is_torch_available(): rai...
236
0
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class _snake_case ( _snake_case ): def __init__( self , _lowerCamelCase , _lowerCamelCase ): a :Union[str, Any] = params a :Tuple = ...
94
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class __lowerCAmelCase ( datasets.BuilderConfig): _a = None class __lowerCAmel...
236
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { "sayakpaul/vit-msn-base": "https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json", # See all ViT M...
151
_UpperCAmelCase : Tuple = {str(digit): digit**5 for digit in range(10)} def UpperCAmelCase__ ( lowerCamelCase ): return sum(DIGITS_FIFTH_POWER[digit] for digit in str(lowerCamelCase ) ) def UpperCAmelCase__ ( ): return sum( number for number in range(1...
236
0
'''simple docstring''' import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py UpperCAmelCase_ = "\\n@INPROCEEDINGS{Papineni02bleu:a,\n author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu},\n title = {...
346
import numpy # List of input, output pairs _UpperCAmelCase : List[str] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) _UpperCAmelCase : Optional[Any] = (((515, 22, 13), 555), ((61, 35, 49), 150)) _UpperCAmelCase : Tuple = [2, 4, 1, 5...
236
0
import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImageProcessor from transformers.utils import l...
343
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils.t...
236
0
'''simple docstring''' import functools from typing import Any def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : List[Any], SCREAMING_SNAKE_CASE__ : int ) -> List[str]: # Validation if not isinstance(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__ ) or len...
125
import os import pytest from attr import dataclass _UpperCAmelCase : List[str] = "us-east-1" # defaults region @dataclass class __lowerCAmelCase : _a = 42 _a = '''arn:aws:iam::558105141721:role/sagemaker_execution_role''' _a = { ...
236
0
'''simple docstring''' a_ : int = range(2, 20 + 1) a_ : List[Any] = [10**k for k in range(ks[-1] + 1)] a_ : dict[int, dict[int, list[list[int]]]] = {} def __snake_case ( UpperCAmelCase_ : Any , UpperCAmelCase_ : Union[str, Any] , ...
55
from typing import Union import fire import torch from tqdm import tqdm def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase = "cpu", lowerCamelCase = None ): lowercase :Optional[Any] = torch.load(lowerCamelCase, map_location=lowerCamelCase ) for k, v in tqdm(state_dict.items...
236
0
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME _lowercase : Tuple = ["small", "medium", "large"] _lowercase : List[str] = "lm_head.decoder.weight" _lowercase : Dict = "lm_head.w...
93
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging logging...
236
0
'''simple docstring''' from __future__ import annotations class lowerCamelCase_ : '''simple docstring''' def __init__( self : Union[str, Any] , A : int ): _UpperCAmelCase : Optional[int] = data _UpperCAmelCase : N...
31
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase ): # Return True if there is node that has not iterated. lowercase :Union[str, Any] = [False] * len(lowerCamelCase ) lowercase :Union[str, Any] = [] queue.append(lowerCamelCase ...
236
0
'''simple docstring''' 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 a...
319
import os from math import logaa def UpperCAmelCase__ ( lowerCamelCase = "base_exp.txt" ): lowercase :float = 0 lowercase :str = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(lowerCamelCase ), lowerCamelCase ) ) ): lowercase , low...
236
0
'''simple docstring''' from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig lowerCamelCase : Tuple = { "susnato/ernie-m-base_pytorch": "https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json", "susnato/ernie-m-la...
2
def UpperCAmelCase__ ( lowerCamelCase, lowerCamelCase ): lowercase :List[str] = "" for word_or_phrase in separated: if not isinstance(lowerCamelCase, lowerCamelCase ): raise Exception("join() accepts only strings to be joined" ) joined += word_or_phrase + separa...
236
0
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, floats_tensor if is_flax_available...
214
import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTest...
236
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import tor...
94
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureExt...
236
0
'''simple docstring''' import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipe...
237
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def UpperCamelCase ( _lowerCamelCase : list[list[float]] ): A__ = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implem...
237
1
'''simple docstring''' def UpperCamelCase ( _lowerCamelCase : int , _lowerCamelCase : int , _lowerCamelCase : list[list[int]] ): def update_area_of_max_square(_lowerCamelCase : int , _lowerCamelCase : int ) -...
237
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCAmelCase ( metaclass=UpperCamelCase__ ): __lowercase = ["""note_seq"""] def __init__( self :Optional[Any] , *lowercase_ :List[Any] , **lowercase_ :List[str] ...
237
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCAmelCase : List[Any] ={"configuration_yolos": ["YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP", "YolosConfig", "YolosOnnxConfig"]} try: if ...
237
'''simple docstring''' # 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 ..controln...
237
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( ...
237
'''simple docstring''' import math import time from transformers import Trainer, 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_model as xm import torch_xla.debug.metrics as met cl...
237
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...
237
'''simple docstring''' def UpperCamelCase ( _lowerCamelCase : int | float | str ): try: A__ = float(_lowerCamelCase ) except ValueError: raise ValueError("Please enter a valid number" ) A__ = decimal - int(_lowerCamelCase ) ...
237
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 import Mode...
237
'''simple docstring''' import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as...
237
1
'''simple docstring''' from bisect import bisect from itertools import accumulate def UpperCamelCase ( _lowerCamelCase : Union[str, Any] , _lowerCamelCase : Tuple , _lowerCamelCase : Tuple , _lowerCamelCase : Any ): A_...
237
'''simple docstring''' 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.testi...
237
1
'''simple docstring''' import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": __lowerCAmelCase : Any =argparse.ArgumentParser() parser.add_argument( "--checkpoint_path", default=None, type=str, req...
237
'''simple docstring''' from __future__ import annotations import time import numpy as np __lowerCAmelCase : Optional[Any] =[8, 5, 9, 7] __lowerCAmelCase : Optional[int] =[ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] __lowerCAmelCase : List[...
237
1
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .to...
237
'''simple docstring''' from __future__ import annotations class UpperCAmelCase : def __init__( self :Optional[int] , lowercase_ :int )-> None: A__ = order # a_{0} ... a_{k} A__ = [1.0] + [0.0] * order # b_{0} ... b_{k} A__ = [...
237
1
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device __lowerCAmelCase : Optional[Any] =False class UpperCAmelCase ( ...
237
'''simple docstring''' import warnings warnings.warn( "memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: " "`from accelerate import find_executable_batch_size` to avoid this warning.", FutureWarning, )
237
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowerCAmelCase : Union[str, Any] ={ "configuration_wav2vec2": ["WAV_2_VEC_2_PRETRAINED_CONFIG_...
237
'''simple docstring''' import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class UpperCAmelCase ( Uppe...
237
1
'''simple docstring''' from typing import List import numpy as np def UpperCamelCase ( _lowerCamelCase : dict ): A__ = {key: len(_lowerCamelCase ) for key, value in gen_kwargs.items() if isinstance(_lowerCamelCase , _lowerCamelCase )} if len(...
237
'''simple docstring''' import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class UpperCAmelCase ( UpperCamelCase__ ): __...
237
1
'''simple docstring''' import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenize...
237
'''simple docstring''' import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, requi...
237
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import lo...
237
'''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_vision fr...
237
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) __lowerCAmelCase : Tuple ={"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARC...
237
'''simple docstring''' from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp...
237
1
'''simple docstring''' import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class UpperCAmelCase ( UpperCamelCase__ ): @require_torch def UpperCAmelCase_ ( self ...
237
'''simple docstring''' import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import AdamW from tor...
237
1
'''simple docstring''' def UpperCamelCase ( _lowerCamelCase : bytes ): return "".join([hex(_lowerCamelCase )[2:].zfill(2 ).upper() for byte in list(_lowerCamelCase )] ) def UpperCamelCase ( _lowerCamelCase : str ): # C...
237
'''simple docstring''' import functools def UpperCamelCase ( _lowerCamelCase : str , _lowerCamelCase : str ): A__ = len(_lowerCamelCase ) A__ = len(_lowerCamelCase ) @functools.cache def min_distance(_lowerCamelCase :...
237
1
'''simple docstring''' import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transf...
237
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( ...
237
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase : Tuple ={ "configuration_whisper": ["WHISPER_PRET...
237
'''simple docstring''' from __future__ import annotations def UpperCamelCase ( _lowerCamelCase : list[int | str] ): create_state_space_tree(_lowerCamelCase , [] , 0 , [0 for i in range(len(_lowerCamelCase ) )] ) def ...
237
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Tuple =logging.get_logger(__name__) __lowerCAmelCase : str ={ "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json", } clas...
237
'''simple docstring''' import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) __lowerCAmelCase : List[str] ={ "sample_size": 32, "in_channels": 3, "out_channels": 3, "layers_per_block": 2, ...
237
1
'''simple docstring''' import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCamelCase ( _lowerCamelCase : Optional[int] ): # ...
237
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black __lowerCAmelCase : Any =os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402...
237
1