code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
from __future__ import annotations from collections import Counter from random import random class lowerCAmelCase_ : def __init__( self ) -> str: UpperCamelCase : List[Any] = {} def snake_case_ ( self, SCREAMING_SNAKE_CASE_ ) -> ...
40
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Optional[Any] = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_AR...
121
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCAmelCase__ = {'''tokenization_byt5''': ['''ByT5Tokenizer''']} if TYPE_CHECKING: from .tokenization_byta import ByTaTokenizer else: import sys lowerCAmelCase__ = _LazyModule(__name__, globals...
41
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import ena...
121
0
'''simple docstring''' 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_devi...
42
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_space...
121
0
from io import BytesIO from typing import List, Union import requests from ..utils import add_end_docstrings, is_decord_available, is_torch_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_decord_available(): import numpy as np from decord import Vide...
43
def _lowerCAmelCase ( __magic_name__ :list ): if any(not isinstance(__magic_name__ , __magic_name__ ) or x < 0 for x in sequence ): raise TypeError('''Sequence must be list of non-negative integers''' ) for _ in range(len(__magic_name__ ...
121
0
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_avai...
44
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _lowerCAmelCase ( __magic_name__ :Optional[Any] ): UpperCAmelCase_ = os.path.join(args.tf_model_dir , '''parameters.jso...
121
0
from math import sqrt def A ( lowercase__ : int = 100_0000 ) -> int: UpperCamelCase__ :int = 0 UpperCamelCase__ :int = 0 UpperCamelCase__ :int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 , 2 * max_cuboid_size + 1 ): if sqrt...
45
def _lowerCAmelCase ( __magic_name__ :list[list[int]] , __magic_name__ :int , __magic_name__ :int , __magic_name__ :set ): UpperCAmelCase_, UpperCAmelCase_ = len(__magic_name__ ), len(grid[0] ) if ( min(__magic_name__ , __ma...
121
0
"""simple docstring""" import os import sys import unittest _lowerCAmelCase : Dict = 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_dumm...
46
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask _lowerCamelCase : List[Any] = logging.getLogger(__name__) class snake_case__ ( __snake_case ): ...
121
0
import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import GenerationTesterMixi...
47
def _lowerCAmelCase ( __magic_name__ :str ): UpperCAmelCase_ = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def _lowerCAmelCase ( __magic_name_...
121
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase__ : Optional[Any] = { "configuration_git": ["GIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "GitConfig", "GitVisionConfig"], "processing_git": ["GitP...
48
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : str = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', ...
121
0
"""simple docstring""" def lowercase__ ( snake_case_ :str ): assert column_title.isupper() __UpperCAmelCase = 0 __UpperCAmelCase = len(snake_case_ ) - 1 __UpperCAmelCase = 0 while index >= 0: __UpperCAmelCase = (ord(column_title[index] ...
49
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class snake_case__ : '''simple docstring''' __A = 42 __A = None __A = None _lowerCamelCas...
121
0
'''simple docstring''' import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartC...
50
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :int ): UpperCAmelCase_ = [True] * limit UpperCAmelCase_ = False UpperCAmelCase_ = False UpperCAmelCase_ = True for i in range(3 , int(limit**0.5 + 1 ) ...
121
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Union[str, Any] = logging.get_logger(__name__) a__ : List[Any] = { 'microsoft/biogpt': 'https://huggingface.co/microsoft/biogpt/resolve/main/config.j...
51
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO ) _lowerCamelCase : str = logging.getLogger(__name__) if __name__ ==...
121
0
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class __lowercase ( ctypes.Structure ): '''simple docstring''' ...
52
import os from math import logaa def _lowerCAmelCase ( __magic_name__ :str = "base_exp.txt" ): UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(__magic_name__ ) , __magic_name__ ) )...
121
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _snake_case : Tuple = { 'configuration_swiftformer': [ 'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SwiftFormerConfig', 'SwiftF...
53
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap _lowerCamelCase : Any = 'Usage of script: script_name <size_of_canvas:int>' _lowerCamelCase : Dict = [0] * 100 + [1] * 10 random.shuffle(choice...
121
0
import json import os import shutil import tempfile import unittest from transformers import BatchEncoding, CanineTokenizer from transformers.testing_utils import require_tokenizers, require_torch from transformers.tokenization_utils import AddedToken from transformers.utils import cached_property...
54
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :list[int | str] ): create_state_space_tree(__magic_name__ , [] , 0 , [0 for i in range(len(__magic_name__ ) )] ) def _lowerCAmelCase ( ...
121
0
import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class UpperCAmelCase : '''simple docstring''' snake_case_ = None def UpperCamelCase_ ( self : int ): __A = self.feature_extraction_cl...
55
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switchi...
121
0
'''simple docstring''' import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline...
56
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 _lowerCamelCase : Union[str, Any] = { 'tiny.en': 'https://openaipublic.azu...
121
0
import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_utils ...
57
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( __magic_name__ :Union[str, Any] , __magic_na...
121
0
"""simple docstring""" import argparse import json import subprocess def __lowerCAmelCase ( __UpperCamelCase : int , __UpperCamelCase : List[str] ): '''simple docstring''' snake_case_ : List[Any] = [] snak...
58
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Dict = { 'configuration_bloom': ['BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BloomConfig', 'BloomOnnxConfig'], } try: ...
121
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __A = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxConfig"]} try: if ...
59
_lowerCamelCase : dict[tuple[int, int, int], int] = {} def _lowerCAmelCase ( __magic_name__ :int , __magic_name__ :int , __magic_name__ :int ): # if we are absent twice, or late 3 consecutive days, # no further prize strings are possib...
121
0
import unittest import numpy as np from datasets import load_dataset 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 ...
60
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
0
import math import sys def _A ( lowerCAmelCase_ : str ): """simple docstring""" lowerCAmelCase__ = "" try: with open(lowerCAmelCase_ , "rb" ) as binary_file: lowerCAmelCase__ = binary_file.read() ...
61
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Acceler...
121
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case = logging.get_logger(__name__) snake_case = { """BAAI/AltCLIP""": """https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json""", # See al...
62
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Optional[Any] = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_AR...
121
0
import numpy # List of input, output pairs a : Tuple = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) a : List[str] = (((515, 22, 13), 555), ((61, 35, 49), 150)) a : Optional[Any] = ...
63
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import ena...
121
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotAvailable() exce...
64
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_space...
121
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image...
65
def _lowerCAmelCase ( __magic_name__ :list ): if any(not isinstance(__magic_name__ , __magic_name__ ) or x < 0 for x in sequence ): raise TypeError('''Sequence must be list of non-negative integers''' ) for _ in range(len(__magic_name__ ...
121
0
def __magic_name__ ( SCREAMING_SNAKE_CASE = 50 ) -> int: _lowercase : Optional[int] = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in...
66
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _lowerCAmelCase ( __magic_name__ :Optional[Any] ): UpperCAmelCase_ = os.path.join(args.tf_model_dir , '''parameters.jso...
121
0
from typing import Any import numpy as np def SCREAMING_SNAKE_CASE__ ( snake_case__ :np.ndarray ) -> bool: return np.array_equal(snake_case__ , matrix.conjugate().T ) def SCREAMING_SNAKE_CASE__ ( snake_case__ :np.ndarray , snake_case__ :np.ndarray ) ...
67
def _lowerCAmelCase ( __magic_name__ :list[list[int]] , __magic_name__ :int , __magic_name__ :int , __magic_name__ :set ): UpperCAmelCase_, UpperCAmelCase_ = len(__magic_name__ ), len(grid[0] ) if ( min(__magic_name__ , __ma...
121
0
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from trans...
68
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask _lowerCamelCase : List[Any] = logging.getLogger(__name__) class snake_case__ ( __snake_case ): ...
121
0
'''simple docstring''' import os import jsonlines import numpy as np from tqdm import tqdm a : int = 2_048 a : Optional[int] = 4_096 a : Dict = 42 a : Optional[int] = os.environ.pop('''PROCESS_TRAIN''', '''false''') a...
69
def _lowerCAmelCase ( __magic_name__ :str ): UpperCAmelCase_ = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def _lowerCAmelCase ( __magic_name_...
121
0
def _SCREAMING_SNAKE_CASE ( lowercase : dict ): '''simple docstring''' lowerCamelCase_ = set() # To detect a back edge, keep track of vertices currently in the recursion stack lowerCamelCase_ = set() return any( ...
70
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : str = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', ...
121
0
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : int ) -> str: """simple docstring""" UpperCAmelCase_ : list[list[str]] = [[] for _ in range(_SCREAMING_SNAKE_CASE )] UpperCAmelCase_ : Any ...
71
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class snake_case__ : '''simple docstring''' __A = 42 __A = None __A = None _lowerCamelCas...
121
0
'''simple docstring''' def UpperCamelCase ( lowercase_ : float , lowercase_ : float , lowercase_ : int ) -> float: '''simple docstring''' if principal <= 0: raise Exception('''Principal borrowed must be > 0''' ) if rate_per_annum < 0: raise Except...
72
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :int ): UpperCAmelCase_ = [True] * limit UpperCAmelCase_ = False UpperCAmelCase_ = False UpperCAmelCase_ = True for i in range(3 , int(limit**0.5 + 1 ) ...
121
0
import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn( 'The converted tokeni...
73
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO ) _lowerCamelCase : str = logging.getLogger(__name__) if __name__ ==...
121
0
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """vocab_file""": """vocab.json""", """merges_file""": """merges.txt""", } lo...
74
import os from math import logaa def _lowerCAmelCase ( __magic_name__ :str = "base_exp.txt" ): UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(__magic_name__ ) , __magic_name__ ) )...
121
0
'''simple docstring''' from __future__ import annotations import numpy as np def a__ ( lowerCAmelCase__ ) -> List[Any]: return np.maximum(0 , lowerCAmelCase__ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
75
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap _lowerCamelCase : Any = 'Usage of script: script_name <size_of_canvas:int>' _lowerCamelCase : Dict = [0] * 100 + [1] * 10 random.shuffle(choice...
121
0
"""simple docstring""" import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): a_ = yaml.safe_load( '\\nname: ""\nallow_empty: false\nallow_empty_text: t...
76
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :list[int | str] ): create_state_space_tree(__magic_name__ , [] , 0 , [0 for i in range(len(__magic_name__ ) )] ) def _lowerCAmelCase ( ...
121
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) A = { """configuration_deberta""": ["""DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """De...
77
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switchi...
121
0
'''simple docstring''' from math import pi, sqrt, tan def lowerCAmelCase_ ( snake_case_ : float ) -> float: '''simple docstring''' if side_length < 0: raise ValueError("surface_area_cube() only accepts non-negative values" ) return 6 * side_leng...
78
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 _lowerCamelCase : Union[str, Any] = { 'tiny.en': 'https://openaipublic.azu...
121
0
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Dict = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Tuple = { """google/realm-cc-news-pretrained-embedder""": ( """https://huggingface.co/go...
79
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( __magic_name__ :Union[str, Any] , __magic_na...
121
0
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 (...
80
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Dict = { 'configuration_bloom': ['BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BloomConfig', 'BloomOnnxConfig'], } try: ...
121
0
import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def lowerCAmelCase_ ( *__lowerCamelCase ): if not isinstance(__lowerCamelCase , __lowerCamelCase ): __snake_case : Optional[int] = ...
81
_lowerCamelCase : dict[tuple[int, int, int], int] = {} def _lowerCAmelCase ( __magic_name__ :int , __magic_name__ :int , __magic_name__ :int ): # if we are absent twice, or late 3 consecutive days, # no further prize strings are possib...
121
0
"""simple docstring""" import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available ...
82
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
0
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetCo...
83
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Acceler...
121
0
import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurat...
84
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Optional[Any] = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_AR...
121
0
from __future__ import annotations from typing import Any class snake_case : def __init__( self : Any , a_ : int , a_ : int , a_ : float = 0 )-> None: """simple docstring""" SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ : ...
85
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import ena...
121
0
import random from typing import Any def __snake_case ( __UpperCamelCase : list ): """simple docstring""" for _ in range(len(__UpperCamelCase ) ): A_ = random.randint(0 ,len(__UpperCamelCase ) - 1 ) A_ = random.rand...
86
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_space...
121
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Tuple = logging.get_logger(__name__) _lowerCamelCase : Optional[int] = { """microsoft/cvt-13""": """https://huggingface.co/microsoft/cvt-13/resolve/main/config.json""", # ...
87
def _lowerCAmelCase ( __magic_name__ :list ): if any(not isinstance(__magic_name__ , __magic_name__ ) or x < 0 for x in sequence ): raise TypeError('''Sequence must be list of non-negative integers''' ) for _ in range(len(__magic_name__ ...
121
0
"""simple docstring""" import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision,...
88
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _lowerCAmelCase ( __magic_name__ :Optional[Any] ): UpperCAmelCase_ = os.path.join(args.tf_model_dir , '''parameters.jso...
121
0
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> float: _lowercase : int = sorted(numsa + numsa ) _lowercase , _lowercase : List[str] = divmod(len(lowerCamelCase_ ) , 2 ) ...
89
def _lowerCAmelCase ( __magic_name__ :list[list[int]] , __magic_name__ :int , __magic_name__ :int , __magic_name__ :set ): UpperCAmelCase_, UpperCAmelCase_ = len(__magic_name__ ), len(grid[0] ) if ( min(__magic_name__ , __ma...
121
0
'''simple docstring''' import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() __UpperCAmelCase = logging.get_logger(__name__) def ...
90
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask _lowerCamelCase : List[Any] = logging.getLogger(__name__) class snake_case__ ( __snake_case ): ...
121
0
"""simple docstring""" from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def _snake_case ( snake_case__ : str , snake_case__ : float | Decimal , snake_case__ : float = 10**-10 ): A = a while True: A = D...
91
def _lowerCAmelCase ( __magic_name__ :str ): UpperCAmelCase_ = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def _lowerCAmelCase ( __magic_name_...
121
0
'''simple docstring''' from __future__ import annotations import math def _lowerCAmelCase ( __magic_name__ : int , __magic_name__ : int , __magic_name__ : bool , __magic_name__ : list[int] , __magic_name__ : float ) -> int: if de...
92
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : str = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', ...
121
0
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE ) ->Dict: """simple docstring""" if not head: return True # split the list to two parts lowerCAmelCase__ , lowerCAmelCase__ :List[Any] = head.next, head while fast and fast.next: lowerCAmelCas...
93
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class snake_case__ : '''simple docstring''' __A = 42 __A = None __A = None _lowerCamelCas...
121
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swinv2-tiny-...
94
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :int ): UpperCAmelCase_ = [True] * limit UpperCAmelCase_ = False UpperCAmelCase_ = False UpperCAmelCase_ = True for i in range(3 , int(limit**0.5 + 1 ) ...
121
0
"""simple docstring""" def snake_case ( A__ ): return sum(i for i in range(1 ,number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print('''Program to check whether a number is a Perfect number or not...''') lowerCamelCase_ = int(input('''Enter number...
95
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO ) _lowerCamelCase : str = logging.getLogger(__name__) if __name__ ==...
121
0
"""simple docstring""" from math import factorial, pi def a ( __UpperCAmelCase : float , __UpperCAmelCase : int = 3_0 ) -> float: if not isinstance(__UpperCAmelCase , (int, float) ): raise ValueError("""maclaurin_sin...
96
import os from math import logaa def _lowerCAmelCase ( __magic_name__ :str = "base_exp.txt" ): UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(__magic_name__ ) , __magic_name__ ) )...
121
0
__a = [ 'Audio', 'Array2D', 'Array3D', 'Array4D', 'Array5D', 'ClassLabel', 'Features', 'Sequence', 'Value', 'Image', 'Translation', 'TranslationVariableLanguages', ] from .audio import Audio from .features import ArrayaD, ArrayaD, ArrayaD, Array...
97
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap _lowerCamelCase : Any = 'Usage of script: script_name <size_of_canvas:int>' _lowerCamelCase : Dict = [0] * 100 + [1] * 10 random.shuffle(choice...
121
0
'''simple docstring''' 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_availab...
98
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :list[int | str] ): create_state_space_tree(__magic_name__ , [] , 0 , [0 for i in range(len(__magic_name__ ) )] ) def _lowerCAmelCase ( ...
121
0
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin class ...
99
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switchi...
121
0
from dataclasses import dataclass, field from typing import Optional @dataclass class __snake_case : '''simple docstring''' lowerCamelCase__ : Optional[str] = field( default="""codeparrot/codeparrot""" , metadata={"""help""": """Model name or path of model to be train...
100
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 _lowerCamelCase : Union[str, Any] = { 'tiny.en': 'https://openaipublic.azu...
121
0
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowercase (__SCREAMING_SNAKE_CASE ): """simple docstring""" _UpperCAmelCase = """ClapFeatureExtractor""" _UpperCAmelCase =...
101
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( __magic_name__ :Union[str, Any] , __magic_na...
121
0
"""simple docstring""" from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils im...
102
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Dict = { 'configuration_bloom': ['BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BloomConfig', 'BloomOnnxConfig'], } try: ...
121
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_i...
103
_lowerCamelCase : dict[tuple[int, int, int], int] = {} def _lowerCAmelCase ( __magic_name__ :int , __magic_name__ :int , __magic_name__ :int ): # if we are absent twice, or late 3 consecutive days, # no further prize strings are possib...
121
0
"""simple docstring""" from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = ...
104
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
0
import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('''.''') def __UpperCAmelCase ( lowerCamelCase_ : int ) -> Tuple: """simple docstring""" SCR...
105
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Acceler...
121
0
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor __snake_case :Union[str, Any] =logging.get_logger(__name__) class lowerCAmelCase__ ( _lowerCamelCase ): def __init__( self : int , *__UpperCamelCas...
106
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Optional[Any] = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_AR...
121
0
'''simple docstring''' from __future__ import annotations def _SCREAMING_SNAKE_CASE ( __snake_case : float , __snake_case : float , __snake_case : float ): if days_between_payments <= 0: raise ValueError('days_between_payments must be > 0' ) if d...
107
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import ena...
121
0
import inspect import unittest from transformers import MobileViTConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ......
108
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_space...
121
0
'''simple docstring''' import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTok...
109
def _lowerCAmelCase ( __magic_name__ :list ): if any(not isinstance(__magic_name__ , __magic_name__ ) or x < 0 for x in sequence ): raise TypeError('''Sequence must be list of non-negative integers''' ) for _ in range(len(__magic_name__ ...
121
0
from math import sqrt def __UpperCamelCase ( A ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return...
415
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _lowerCAmelCase ( __magic_name__ :Optional[Any] ): UpperCAmelCase_ = os.path.join(args.tf_model_dir , '''parameters.jso...
121
0
def A_ ( lowercase_ = 10 , lowercase_ = 1000 , lowercase_ = True ) -> List[str]: assert ( isinstance(lowercase_ , lowercase_ ) and isinstance(lowercase_ , lowercase_ ) and isinstance(lowercase_ , lowercase_ ) ), "Invalid type of value(...
326
def _lowerCAmelCase ( __magic_name__ :list[list[int]] , __magic_name__ :int , __magic_name__ :int , __magic_name__ :set ): UpperCAmelCase_, UpperCAmelCase_ = len(__magic_name__ ), len(grid[0] ) if ( min(__magic_name__ , __ma...
121
0
'''simple docstring''' import math def __a ( lowerCAmelCase__ : int ): a__ : str = [] a__ : List[Any] = 2 a__ : str = int(math.sqrt(lowerCAmelCase__ ) ) # Size of every segment a__ : Optional[int] = ...
688
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask _lowerCamelCase : List[Any] = logging.getLogger(__name__) class snake_case__ ( __snake_case ): ...
121
0
import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql import sql # noqa F40...
59
def _lowerCAmelCase ( __magic_name__ :str ): UpperCAmelCase_ = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def _lowerCAmelCase ( __magic_name_...
121
0
import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node _lowerCAmelCase : Optional[Any] = 4 _lowerCAmelCase : List[Any] = 3 ...
246
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : str = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', ...
121
0
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device a__ : Tuple = False class UpperCAmelCase_ ( unittest.TestCase ): ...
188
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class snake_case__ : '''simple docstring''' __A = 42 __A = None __A = None _lowerCamelCas...
121
0
'''simple docstring''' from PIL import Image def __UpperCamelCase( _A : Image , _A : int ): '''simple docstring''' UpperCAmelCase__ : Any = (2_59 * (level + 2_55)) / (2_55 * (2_59 - level)) def contrast(_A : int ) -> int: return int(1_28 + f...
614
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :int ): UpperCAmelCase_ = [True] * limit UpperCAmelCase_ = False UpperCAmelCase_ = False UpperCAmelCase_ = True for i in range(3 , int(limit**0.5 + 1 ) ...
121
0
def _lowerCamelCase ( lowerCamelCase_: list[list[int]] , lowerCamelCase_: int , lowerCamelCase_: int , lowerCamelCase_: set ): '''simple docstring''' A , A : Any = len(lowerCamelCase_ ), len(grid[0] ) if ( min(low...
256
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO ) _lowerCamelCase : str = logging.getLogger(__name__) if __name__ ==...
121
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _A : str = logging.get_logger(__name__) _A : Optional[Any] = { 'facebook/x...
427
import os from math import logaa def _lowerCAmelCase ( __magic_name__ :str = "base_exp.txt" ): UpperCAmelCase_ = 0 UpperCAmelCase_ = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(__magic_name__ ) , __magic_name__ ) )...
121
0
"""simple docstring""" from __future__ import annotations from dataclasses import dataclass @dataclass class snake_case : SCREAMING_SNAKE_CASE_ : List[Any] = 42 SCREAMING_SNAKE_CASE_ : Dict = None SCREAMING_SNAKE_CASE_ : Union[str, Any] = None ...
346
import random import sys import numpy as np from matplotlib import pyplot as plt from matplotlib.colors import ListedColormap _lowerCamelCase : Any = 'Usage of script: script_name <size_of_canvas:int>' _lowerCamelCase : Dict = [0] * 100 + [1] * 10 random.shuffle(choice...
121
0
"""simple docstring""" import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conv...
607
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :list[int | str] ): create_state_space_tree(__magic_name__ , [] , 0 , [0 for i in range(len(__magic_name__ ) )] ) def _lowerCAmelCase ( ...
121
0
# 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...
415
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switchi...
121
0
lowerCAmelCase_ = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} lowerCAmelCase_ = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def A_ ( lowercase_ , lowercase_ , lowercase_ ) -> Tuple: _snake_case : Optional[int] = True _snake_case : str ...
326
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 _lowerCamelCase : Union[str, Any] = { 'tiny.en': 'https://openaipublic.azu...
121
0
'''simple docstring''' from math import factorial def __a ( lowerCAmelCase__ : int = 100 ): return sum(map(lowerCAmelCase__ , str(factorial(lowerCAmelCase__ ) ) ) ) if __name__ == "__main__": print(solution(int(input('Enter the Number: ').strip())))
688
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( __magic_name__ :Union[str, Any] , __magic_na...
121
0
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, A...
59
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCamelCase : Dict = { 'configuration_bloom': ['BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BloomConfig', 'BloomOnnxConfig'], } try: ...
121
0
import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowe...
246
_lowerCamelCase : dict[tuple[int, int, int], int] = {} def _lowerCAmelCase ( __magic_name__ :int , __magic_name__ :int , __magic_name__ :int ): # if we are absent twice, or late 3 consecutive days, # no further prize strings are possib...
121
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
188
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
0
'''simple docstring''' def __UpperCamelCase( _A : int , _A : int ): '''simple docstring''' return base * power(_A , (exponent - 1) ) if exponent else 1 if __name__ == "__main__": print('Raise base to the power of exponent using recursion...') UpperCamelCase__ : U...
614
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Acceler...
121
0
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 from transformers import TFCam...
256
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Optional[Any] = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_AR...
121
0
'''simple docstring''' # Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # -...
427
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import ena...
121
0
"""simple docstring""" import os from math import logaa def a__ ( __SCREAMING_SNAKE_CASE = "base_exp.txt" ) -> Dict: __lowerCAmelCase: Optional[Any] = 0 __lowerCAmelCase: List[str] = 0 for i, line in enumerate(open(os.path.join(o...
346
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_space...
121
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase: Tuple =logging.get_logger(__name__) lowerCAmelCase: Any ={ 'microsoft/cvt-13': 'https://huggingface.co/microsoft/cvt-13/resolve/main/config.json', ...
607
def _lowerCAmelCase ( __magic_name__ :list ): if any(not isinstance(__magic_name__ , __magic_name__ ) or x < 0 for x in sequence ): raise TypeError('''Sequence must be list of non-negative integers''' ) for _ in range(len(__magic_name__ ...
121
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __magic_name__ =logging.get_logger(__name__) __magic_name__ ={'vocab_file': 'spm_char.model'...
415
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def _lowerCAmelCase ( __magic_name__ :Optional[Any] ): UpperCAmelCase_ = os.path.join(args.tf_model_dir , '''parameters.jso...
121
0
from typing import Union import fire import torch from tqdm import tqdm def A_ ( lowercase_ , lowercase_ = "cpu" , lowercase_ = None ) -> Any: _snake_case : Optional[Any] = torch.load(lowercase_ , map_location=lowercase_ ) for k, v in tqdm(state_dict.item...
326
def _lowerCAmelCase ( __magic_name__ :list[list[int]] , __magic_name__ :int , __magic_name__ :int , __magic_name__ :set ): UpperCAmelCase_, UpperCAmelCase_ = len(__magic_name__ ), len(grid[0] ) if ( min(__magic_name__ , __ma...
121
0
'''simple docstring''' __SCREAMING_SNAKE_CASE = { 'meter': 'm', 'kilometer': 'km', 'megametre': 'Mm', 'gigametre': 'Gm', 'terametre': 'Tm', 'petametre': 'Pm', 'exametre': 'Em', 'zettametre': 'Zm', 'yottametre': 'Ym', } # Exponent of the factor(meter) __SCREAMING_SNAK...
688
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask _lowerCamelCase : List[Any] = logging.getLogger(__name__) class snake_case__ ( __snake_case ): ...
121
0
def lowerCAmelCase_ ( __a ) -> Tuple: """simple docstring""" if length <= 0 or not isinstance(__a , __a ): raise ValueError("Length must be a positive integer." ) return [n * (2 * n - 1) for n in range(__a )] if __name__ == "__main__": print(...
59
def _lowerCAmelCase ( __magic_name__ :str ): UpperCAmelCase_ = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def _lowerCAmelCase ( __magic_name_...
121
0
import requests _lowerCAmelCase : Optional[Any] = 'YOUR API KEY' def a_ ( UpperCamelCase_ : str , UpperCamelCase_ : str = giphy_api_key ) -> List[Any]: """simple docstring""" lowerCamelCase = '+'.join(query.split() ) lowerCamel...
246
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : str = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', ...
121
0
import math def UpperCAmelCase_ ( _UpperCAmelCase :int ) -> int: '''simple docstring''' return math.sqrt(_UpperCAmelCase ) * math.sqrt(_UpperCAmelCase ) == num def UpperCAmelCase_ ( _UpperCAmelCase :int ) -> Tuple: '''simple docstring''' ...
188
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class snake_case__ : '''simple docstring''' __A = 42 __A = None __A = None _lowerCamelCas...
121
0
'''simple docstring''' import math import qiskit def __UpperCamelCase( _A : int = 1 , _A : int = 1 , _A : int = 1 ): '''simple docstring''' if ( isinstance(_A , _A ) or isinstance(_A , _A ) or isinstance(_A , _A )...
614
from __future__ import annotations def _lowerCAmelCase ( __magic_name__ :int ): UpperCAmelCase_ = [True] * limit UpperCAmelCase_ = False UpperCAmelCase_ = False UpperCAmelCase_ = True for i in range(3 , int(limit**0.5 + 1 ) ...
121
0
import unittest from transformers import AutoTokenizer, FalconConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common impor...
256
import argparse import logging import pickle from collections import Counter logging.basicConfig( format='%(asctime)s - %(levelname)s - %(name)s - %(message)s', datefmt='%m/%d/%Y %H:%M:%S', level=logging.INFO ) _lowerCamelCase : str = logging.getLogger(__name__) if __name__ ==...
121
0