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
import sys def __SCREAMING_SNAKE_CASE ( a__ : List[Any] ) -> int: __A : Union[str, Any] = len(a__ ) __A : Any = [[0 for x in range(a__ )] for x in range(a__ )] __A : Optional[Any] = [[0 for x in range(a__ )] for x in range(a__ ...
17
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowerCamelCase_ ( _lowercase ): _lowercase : Union[str, Any] = '''EncodecFeatureExtractor''' _lowercase : Any = ('''T5Tokenizer''', ...
17
1
import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": UpperCAmelCase_ : str = argparse.ArgumentParser() parser.add_argument( '''--checkpoint_path''', default=None, type=str...
17
def __SCREAMING_SNAKE_CASE ( a__ : int ) -> int: if not isinstance(a__ ,a__ ): raise TypeError("""Input value must be an 'int' type""" ) __A : Union[str, Any] = 0 while number: position += 1 number >>= 1 return position if __name__ == "__main__": ...
17
1
import fire from utils import calculate_rouge, save_json def __SCREAMING_SNAKE_CASE ( a__ : Any ,a__ : Tuple ,a__ : Any=None ,**a__ : Dict ) -> Optional[Any]: __A : int = [x.strip() for x in open(a__ ).readlines()] __A : List[str] = [x.str...
17
UpperCAmelCase_ : dict[tuple[int, int, int], int] = {} def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : int ) -> int: # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late == 3 or absent == 2: retu...
17
1
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class lowerCamelCase_ ( unittest.TestCase ): def lowerCAmelCase_ ( self : Optional[Any] ): debug_launcher(test_script.main ...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : int , __A : Tuple , __A : List[Any] ): __A : Optional[int] = None __A : Any = None __A : int = graph self._normalize_graph(__A , ...
17
1
from typing import TYPE_CHECKING from ..utils import _LazyModule UpperCAmelCase_ : int = { '''config''': [ '''EXTERNAL_DATA_FORMAT_SIZE_LIMIT''', '''OnnxConfig''', '''OnnxConfigWithPast''', '''OnnxSeq2SeqConfigWithPast''', '''PatchingSpec''', ], '''...
17
from __future__ import annotations from collections.abc import Sequence from typing import Literal def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : str ) -> str | Literal[False]: __A : Tuple = list(a__ ) __A : Optional[int] = list(a__ ) __A : int ...
17
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : Any = logging.get_logger(__name__) UpperCAmelCase_ : str = { ...
17
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( a__ : List[str] ,a__ : Dict ,a__ : Union[str, Any] ,a__ : Any ) -> Optional[int]: # noqa: E741 while r - l > 1: __A : Any = (l + r) // 2 if v[m] >= key: __A : Optional[int] = ...
17
1
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 ): _lowercase : Optional[datasets.Features] = None ...
17
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
17
1
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 UpperCAmelCase_ : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase_ : str ...
17
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : str = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.co/micro...
17
1
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def __SCREAMING_SNAKE_CASE ( a__ : str ) -> List[s...
17
import fire from utils import calculate_rouge, save_json def __SCREAMING_SNAKE_CASE ( a__ : Any ,a__ : Tuple ,a__ : Any=None ,**a__ : Dict ) -> Optional[Any]: __A : int = [x.strip() for x in open(a__ ).readlines()] __A : List[str] = [x.str...
17
1
import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table import array_cast from ..util...
17
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __SCREAMING_SNAKE_CASE ( a__ : Optional[Any] ,a__ : Union[str, Any] ,a__ : Optiona...
17
1
def __SCREAMING_SNAKE_CASE ( a__ : int = 1000000 ) -> int: __A : Optional[Any] = [i - 1 for i in range(limit + 1 )] for i in range(2 ,limit + 1 ): if phi[i] == i - 1: for j in range(2 * i ,limit + 1 ,a__ ): phi[j] -= phi[j] // i return sum(...
17
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : int = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InformerConfig''', ...
17
1
from __future__ import annotations from cmath import sqrt def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : int ) -> tuple[complex, complex]: if a == 0: raise ValueError("""Coefficient 'a' must not be zero.""" ) __A : str = b * b - 4 * a * c _...
17
import math class lowerCamelCase_ : def __init__( self : Union[str, Any] , __A : List[str]=0 ): # a graph with Node 0,1,...,N-1 __A : List[str] = n __A : List[str] = [ [math.inf for j in range(0 , __A )] for i in ran...
17
1
import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert import BertConfig from tra...
17
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : complex ,a__ : str = "x" ,a__ : float = 10**-10 ,a__ : int = 1 ,) -> complex: __A : Tuple = symbols(a__ ) __A : ...
17
1
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( a__ : List[str] ,a__ : Dict ,a__ : Union[str, Any] ,a__ : Any ) -> Optional[int]: # noqa: E741 while r - l > 1: __A : Any = (l + r) // 2 if v[m] >= key: __A : Optional[int] = ...
17
from math import sqrt def __SCREAMING_SNAKE_CASE ( a__ : int = 1000000 ) -> int: __A : int = 0 __A : int = 0 __A : int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 ,2 * max_cuboid_size + 1 ): if sqrt(sum_short...
17
1
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class lowerCamelCase_ ( unittest.TestCase ): _lowercase : List[str] = JukeboxTokenizer _lowercase : Any = { '''artist''': '''Zac Brown Band''', '''g...
17
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format,...
17
1
import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accelerate.test_utils import require_mu...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : Tuple , __A : Optional[int] , __A : int ): __A : List[str] = name __A : Optional[int] = value __A : Optional[Any] = weight def __repr_...
17
1
def __SCREAMING_SNAKE_CASE ( a__ : list ,a__ : list ,a__ : int ,a__ : int ,a__ : int ) -> int: if index == number_of_items: return 0 __A : Optional[int] = 0 __A : List[Any] = 0 __A : int = knapsack(a__ ,a__ ,a__ ,a__ ,...
17
UpperCAmelCase_ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr": 4_186_800...
17
1
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(): imp...
17
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase_ : Optional[Any] = { '''configuration_wav2vec2''': ['''WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
17
1
import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import GradientAccumulator, create_optimize...
17
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from da...
17
1
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from da...
17
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
17
1
from __future__ import annotations import typing from collections import Counter def __SCREAMING_SNAKE_CASE ( a__ : int ) -> typing.Counter[int]: __A : typing.Counter[int] = Counter() for base in range(1 ,max_perimeter + 1 ): for perpendicular in range(a__ ,max_p...
17
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __SCREAMING_SNAKE_CASE ( ) -> Tuple: __A : List[Any] = ArgumentParser( description=( """PyTorch TPU distributed t...
17
1
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class lowerCamelCase_ ( unittest.TestCase ): def lowerCAmelCase_ ( self ...
17
from collections.abc import Sequence def __SCREAMING_SNAKE_CASE ( a__ : Sequence[float] ,a__ : float ) -> float: return sum(c * (x**i) for i, c in enumerate(a__ ) ) def __SCREAMING_SNAKE_CASE ( a__ : Sequence[float] ,a__ : float ) -...
17
1
import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class lowerCamelCase_ ( tf.keras.layers.Layer ): def __init__( self : ...
17
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowerCamelCase_ ( _lowercase ): _lowercase : Union[str, Any] = '''EncodecFeatureExtractor''' _lowercase : Any = ('''T5Tokenizer''', ...
17
1
def __SCREAMING_SNAKE_CASE ( a__ : int ) -> list[int]: if num <= 0: raise ValueError("""Input must be a positive integer""" ) __A : Any = [True] * (num + 1) __A : Optional[int] = 2 while p * p <= num: if primes[p]: for i in range(p * p ,num + 1 ...
17
def __SCREAMING_SNAKE_CASE ( a__ : int ) -> int: if not isinstance(a__ ,a__ ): raise TypeError("""Input value must be an 'int' type""" ) __A : Union[str, Any] = 0 while number: position += 1 number >>= 1 return position if __name__ == "__main__": ...
17
1
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging UpperCAmelCase_ : Dict = logging.get_logger(__name...
17
UpperCAmelCase_ : dict[tuple[int, int, int], int] = {} def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : int ) -> int: # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late == 3 or absent == 2: retu...
17
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.set_verbosity_info() UpperCAme...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : int , __A : Tuple , __A : List[Any] ): __A : Optional[int] = None __A : Any = None __A : int = graph self._normalize_graph(__A , ...
17
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ : Any = { '''configuration_data2vec_audio''': ['''DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Data2VecAudioConfig'''], '''configuratio...
17
from __future__ import annotations from collections.abc import Sequence from typing import Literal def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : str ) -> str | Literal[False]: __A : Tuple = list(a__ ) __A : Optional[int] = list(a__ ) __A : int ...
17
1
def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : int ) -> float: __A : List[Any] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total def __SCREAMING_SNAKE_CASE ( ) -> in...
17
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( a__ : List[str] ,a__ : Dict ,a__ : Union[str, Any] ,a__ : Any ) -> Optional[int]: # noqa: E741 while r - l > 1: __A : Any = (l + r) // 2 if v[m] >= key: __A : Optional[int] = ...
17
1
import os import tempfile import unittest from transformers import DistilBertConfig, 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 ModelTesterMixin, ids_tensor, ...
17
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
17
1
def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ) -> int: while a != 0: __A , __A : Tuple = b % a, a return b def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ) -> int: if gcd(a__ ,a__ ) != 1: __A : U...
17
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : str = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.co/micro...
17
1
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def __SCREAMING_SNAKE_CASE ( a__ : Any ) -> Any: __A : Union[str, Any] = FileLock(str(tmpdir / """foo.lock""" ) ) __A : Optional[int] = FileLock(str(tmpdir / """fo...
17
import fire from utils import calculate_rouge, save_json def __SCREAMING_SNAKE_CASE ( a__ : Any ,a__ : Tuple ,a__ : Any=None ,**a__ : Dict ) -> Optional[Any]: __A : int = [x.strip() for x in open(a__ ).readlines()] __A : List[str] = [x.str...
17
1
import operator as op UpperCAmelCase_ : Union[str, Any] = '''scaler.pt''' UpperCAmelCase_ : int = '''pytorch_model''' UpperCAmelCase_ : Optional[Any] = '''random_states''' UpperCAmelCase_ : Dict = '''optimizer''' UpperCAmelCase_ : Dict = '''sched...
17
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __SCREAMING_SNAKE_CASE ( a__ : Optional[Any] ,a__ : Union[str, Any] ,a__ : Optiona...
17
1
class lowerCamelCase_ : def __init__( self : Dict , __A : int , __A : Tuple , __A : List[Any] ): __A : Optional[int] = None __A : Any = None __A : int = graph self._normalize_graph(__A , ...
17
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : int = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InformerConfig''', ...
17
1
import math class lowerCamelCase_ : def __init__( self : Union[str, Any] , __A : List[str]=0 ): # a graph with Node 0,1,...,N-1 __A : List[str] = n __A : List[str] = [ [math.inf for j in range(0 , __A )] for i in ran...
17
import math class lowerCamelCase_ : def __init__( self : Union[str, Any] , __A : List[str]=0 ): # a graph with Node 0,1,...,N-1 __A : List[str] = n __A : List[str] = [ [math.inf for j in range(0 , __A )] for i in ran...
17
1
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def __SCREAMING_SNAKE_CASE ( a__ : Any ,a__ : Optional[int]=False ) -> Optional[Any]: __A : Tuple = OmegaConf.load(a__ ) if display: print(yaml.du...
17
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : complex ,a__ : str = "x" ,a__ : float = 10**-10 ,a__ : int = 1 ,) -> complex: __A : Tuple = symbols(a__ ) __A : ...
17
1
def __SCREAMING_SNAKE_CASE ( a__ : list ,a__ : int = 0 ) -> list: __A : Optional[Any] = length or len(a__ ) __A : Dict = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]: __A , __A : Dict = list_data[i + 1]...
17
from math import sqrt def __SCREAMING_SNAKE_CASE ( a__ : int = 1000000 ) -> int: __A : int = 0 __A : int = 0 __A : int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 ,2 * max_cuboid_size + 1 ): if sqrt(sum_short...
17
1
from collections import deque from .hash_table import HashTable class lowerCamelCase_ ( _lowercase ): def __init__( self : List[Any] , *__A : str , **__A : Union[str, Any] ): super().__init__(*__A , **__A ) def l...
17
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format,...
17
1
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokeni...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : Tuple , __A : Optional[int] , __A : int ): __A : List[str] = name __A : Optional[int] = value __A : Optional[Any] = weight def __repr_...
17
1
import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase_ ( _lowercase ): _lowercase : str = (DDPMParallelScheduler,) def lowerCAmelCase_ ( self : List[Any] , **__A : ...
17
UpperCAmelCase_ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr": 4_186_800...
17
1
from queue import PriorityQueue from typing import Any import numpy as np def __SCREAMING_SNAKE_CASE ( a__ : dict ,a__ : str ,a__ : set ,a__ : set ,a__ : dict ,a__ : dict ,a__ : PriorityQueue ,a__ : dict ,a__ : float | int ,) -> float...
17
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase_ : Optional[Any] = { '''configuration_wav2vec2''': ['''WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
17
1
import pytest UpperCAmelCase_ : Optional[int] = '''__dummy_dataset1__''' UpperCAmelCase_ : str = ''' import json import os import datasets REPO_URL = "https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/" URLS = {"train": REPO_URL + "wikiann-bn-train.jsonl", ...
17
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from da...
17
1
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class lowerCamelCase_ : @property def lowerCAmelCase_ ( self ...
17
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
17
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : List[Any] = { '''SenseTime/deformable-detr''': '''https://huggingface.co/sense...
17
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __SCREAMING_SNAKE_CASE ( ) -> Tuple: __A : List[Any] = ArgumentParser( description=( """PyTorch TPU distributed t...
17
1
import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn # noqa: F401 # Here to hav...
17
from collections.abc import Sequence def __SCREAMING_SNAKE_CASE ( a__ : Sequence[float] ,a__ : float ) -> float: return sum(c * (x**i) for i, c in enumerate(a__ ) ) def __SCREAMING_SNAKE_CASE ( a__ : Sequence[float] ,a__ : float ) -...
17
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Any = { '''configuration_roberta''': ['''ROBERTA_PRETRAINED_CONFIG_ARCH...
17
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowerCamelCase_ ( _lowercase ): _lowercase : Union[str, Any] = '''EncodecFeatureExtractor''' _lowercase : Any = ('''T5Tokenizer''', ...
17
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : int = { '''microsoft/git-base''': '''https://huggingface.co/microsoft/git-base/res...
17
def __SCREAMING_SNAKE_CASE ( a__ : int ) -> int: if not isinstance(a__ ,a__ ): raise TypeError("""Input value must be an 'int' type""" ) __A : Union[str, Any] = 0 while number: position += 1 number >>= 1 return position if __name__ == "__main__": ...
17
1
import math def __SCREAMING_SNAKE_CASE ( a__ : list ,a__ : int = 0 ,a__ : int = 0 ) -> list: __A : Optional[int] = end or len(a__ ) for i in range(a__ ,a__ ): __A : List[Any] = i __A : Optional[int] = array[i] while temp_ind...
17
UpperCAmelCase_ : dict[tuple[int, int, int], int] = {} def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : int ) -> int: # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late == 3 or absent == 2: retu...
17
1
from sklearn.metrics import recall_score import datasets UpperCAmelCase_ : Dict = ''' Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true positives and FN is the false ...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : int , __A : Tuple , __A : List[Any] ): __A : Optional[int] = None __A : Any = None __A : int = graph self._normalize_graph(__A , ...
17
1
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format,...
17
from __future__ import annotations from collections.abc import Sequence from typing import Literal def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : str ) -> str | Literal[False]: __A : Tuple = list(a__ ) __A : Optional[int] = list(a__ ) __A : int ...
17
1
import math def __SCREAMING_SNAKE_CASE ( a__ : int ) -> str: __A : Optional[int] = 0 __A : List[str] = 0 while num > 0: __A : Optional[int] = num % 8 __A : List[Any] = octal + (remainder * math.floor(math.pow(10 ,a__ ) )) counte...
17
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( a__ : List[str] ,a__ : Dict ,a__ : Union[str, Any] ,a__ : Any ) -> Optional[int]: # noqa: E741 while r - l > 1: __A : Any = (l + r) // 2 if v[m] >= key: __A : Optional[int] = ...
17
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Tuple = logging.get_logger(__name__) class lowerCamelCase_ ( _lowercase ): _lowercase : Optional[int] = '''encoder-decoder''' _lowercase : str = ...
17
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
17
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) UpperCAmelCase_ : Dict = {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''V...
17
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : str = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.co/micro...
17
1
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCamelCase_ ( _lowercase , unittest.TestCase ): _lo...
17
import fire from utils import calculate_rouge, save_json def __SCREAMING_SNAKE_CASE ( a__ : Any ,a__ : Tuple ,a__ : Any=None ,**a__ : Dict ) -> Optional[Any]: __A : int = [x.strip() for x in open(a__ ).readlines()] __A : List[str] = [x.str...
17
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : str = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.co/micro...
17
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __SCREAMING_SNAKE_CASE ( a__ : Optional[Any] ,a__ : Union[str, Any] ,a__ : Optiona...
17
1
import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_info() UpperCAmelCase_ : Any = loggin...
17
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : int = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InformerConfig''', ...
17
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase_ : Optional[Any] = { '''s-JoL/Open-Llama-V1''': '''https://huggingface.co/s-JoL/Open-Llama-V1/blob/main/config.json''', } ...
17
import math class lowerCamelCase_ : def __init__( self : Union[str, Any] , __A : List[str]=0 ): # a graph with Node 0,1,...,N-1 __A : List[str] = n __A : List[str] = [ [math.inf for j in range(0 , __A )] for i in ran...
17
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Optional[int] = logging.get_logger(__name__) UpperCAmelCase_ : Optional[int] = { '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/config....
17
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : complex ,a__ : str = "x" ,a__ : float = 10**-10 ,a__ : int = 1 ,) -> complex: __A : Tuple = symbols(a__ ) __A : ...
17
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers @require_torch cla...
17
from math import sqrt def __SCREAMING_SNAKE_CASE ( a__ : int = 1000000 ) -> int: __A : int = 0 __A : int = 0 __A : int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 ,2 * max_cuboid_size + 1 ): if sqrt(sum_short...
17
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCAmelCase_ : Any = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: U...
17
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format,...
17
1
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, ConditionalDetrForSegmentation, ...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : Tuple , __A : Optional[int] , __A : int ): __A : List[str] = name __A : Optional[int] = value __A : Optional[Any] = weight def __repr_...
17
1
def __SCREAMING_SNAKE_CASE ( a__ : list ) -> list: if len(a__ ) <= 1: return [tuple(a__ )] __A : int = [] def generate(a__ : int ,a__ : list ): if k == 1: res.append(tuple(arr[:] ) ) return generate(k - 1 ,a__ ...
17
UpperCAmelCase_ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr": 4_186_800...
17
1
from __future__ import annotations import requests UpperCAmelCase_ : Optional[Any] = set( '''approved_at_utc approved_by author_flair_background_color author_flair_css_class author_flair_richtext author_flair_template_id author_fullname author_premium can_mod_post category clicked content_categori...
17
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase_ : Optional[Any] = { '''configuration_wav2vec2''': ['''WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
17
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import ( AutoProcessor, BertTokenizerFast, ...
17
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from da...
17
1
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.uti...
17
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
17
1
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase_ : def __init__( self : Dict , __A : Optional[Any]=2 , __A : Union[str, Any]=3 , __A ...
17
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __SCREAMING_SNAKE_CASE ( ) -> Tuple: __A : List[Any] = ArgumentParser( description=( """PyTorch TPU distributed t...
17
1
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( a__ : list[list[int]] ) -> int: # preprocessing the first row for i in range(1 ,len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in range(1 ,len(a__ ) ...
17
from collections.abc import Sequence def __SCREAMING_SNAKE_CASE ( a__ : Sequence[float] ,a__ : float ) -> float: return sum(c * (x**i) for i, c in enumerate(a__ ) ) def __SCREAMING_SNAKE_CASE ( a__ : Sequence[float] ,a__ : float ) -...
17
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCAmelCase_ : Dict = {'''processing_layoutxlm''': ['''LayoutXLMProcessor''']...
17
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowerCamelCase_ ( _lowercase ): _lowercase : Union[str, Any] = '''EncodecFeatureExtractor''' _lowercase : Any = ('''T5Tokenizer''', ...
17
1
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def __SCREAMING_SNAKE_CASE ( a__ : Optional[int] ) -> int: monkeypatch.setattr("""datasets.utils.deprecation_utils._emitted_deprecation_warnings""" ,set() ) @pytest.fixture def ...
17
def __SCREAMING_SNAKE_CASE ( a__ : int ) -> int: if not isinstance(a__ ,a__ ): raise TypeError("""Input value must be an 'int' type""" ) __A : Union[str, Any] = 0 while number: position += 1 number >>= 1 return position if __name__ == "__main__": ...
17
1
import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgumentParser, TrainingArguments ...
17
UpperCAmelCase_ : dict[tuple[int, int, int], int] = {} def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : int ) -> int: # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late == 3 or absent == 2: retu...
17
1
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('''ignore''', category=UserWarning, module='''torch.optim.lr_scheduler''') class lowerCamelCase_ : ...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : int , __A : Tuple , __A : List[Any] ): __A : Optional[int] = None __A : Any = None __A : int = graph self._normalize_graph(__A , ...
17
1
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCase_ : Union[str, Any] = logging.get_logger(__name__)...
17
from __future__ import annotations from collections.abc import Sequence from typing import Literal def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : str ) -> str | Literal[False]: __A : Tuple = list(a__ ) __A : Optional[int] = list(a__ ) __A : int ...
17
1
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : complex ,a__ : str = "x" ,a__ : float = 10**-10 ,a__ : int = 1 ,) -> complex: __A : Tuple = symbols(a__ ) __A : ...
17
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( a__ : List[str] ,a__ : Dict ,a__ : Union[str, Any] ,a__ : Any ) -> Optional[int]: # noqa: E741 while r - l > 1: __A : Any = (l + r) // 2 if v[m] >= key: __A : Optional[int] = ...
17
1
def __SCREAMING_SNAKE_CASE ( a__ : int = 100 ) -> int: __A : Union[str, Any] = n * (n + 1) * (2 * n + 1) / 6 __A : List[str] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(f"""{solution() = }""") ...
17
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
17
1
from manim import * class lowerCamelCase_ ( _lowercase ): def lowerCAmelCase_ ( self : str ): __A : Optional[Any] = Rectangle(height=0.5 , width=0.5 ) __A : Any = Rectangle(height=0.4_6 , width=0.4_6 ).set_stroke(...
17
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : str = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.co/micro...
17
1
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def __SCREAMING_SNAKE_CASE ( a__ : int ) -> str: def wrapper(*a__ : List[Any] ,**a__ : str ): __A : List[Any] = ...
17
import fire from utils import calculate_rouge, save_json def __SCREAMING_SNAKE_CASE ( a__ : Any ,a__ : Tuple ,a__ : Any=None ,**a__ : Dict ) -> Optional[Any]: __A : int = [x.strip() for x in open(a__ ).readlines()] __A : List[str] = [x.str...
17
1
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table import ...
17
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __SCREAMING_SNAKE_CASE ( a__ : Optional[Any] ,a__ : Union[str, Any] ,a__ : Optiona...
17
1
from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configurat...
17
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : int = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InformerConfig''', ...
17
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, Stab...
17
import math class lowerCamelCase_ : def __init__( self : Union[str, Any] , __A : List[str]=0 ): # a graph with Node 0,1,...,N-1 __A : List[str] = n __A : List[str] = [ [math.inf for j in range(0 , __A )] for i in ran...
17
1
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def __SCREAMING_SNAKE_CASE ( a__ : Dataset ,a__ : Dict[str, str] ) -> Union[str, Any]: __A : ...
17
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : complex ,a__ : str = "x" ,a__ : float = 10**-10 ,a__ : int = 1 ,) -> complex: __A : Tuple = symbols(a__ ) __A : ...
17
1
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __SCREAMING_SNAKE_CASE ( a__ : int = 3 ) -> qiskit.result.counts.Counts: if isinstance(a__ ,a__ ): raise TypeError("""number of qubits must be...
17
from math import sqrt def __SCREAMING_SNAKE_CASE ( a__ : int = 1000000 ) -> int: __A : int = 0 __A : int = 0 __A : int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 ,2 * max_cuboid_size + 1 ): if sqrt(sum_short...
17
1
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets UpperCAmelCase_ : List[str] = '''\ @inproceedings{popovic-2015-chrf, title = "chr{F}: character n-gram {F}-score for automatic {MT} evaluation", author = "Popovi{\'c}, Maja", booktitle = "Proc...
17
from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format,...
17
1
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import HuggingFace...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : Tuple , __A : Optional[int] , __A : int ): __A : List[str] = name __A : Optional[int] = value __A : Optional[Any] = weight def __repr_...
17
1
class lowerCamelCase_ : def __init__( self : Dict , __A : Tuple , __A : Optional[int] , __A : int ): __A : List[str] = name __A : Optional[int] = value __A : Optional[Any] = weight def __repr_...
17
UpperCAmelCase_ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr": 4_186_800...
17
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Any = logging.get_logger(__name__) UpperCAmelCase_ : Dict = { '''RWKV/rwkv-4-169m-pile''': '''https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json''', '''RWKV/rwkv...
17
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase_ : Optional[Any] = { '''configuration_wav2vec2''': ['''WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
17
1
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=_lowercase ) class lowerCamelCase_ ( _lowercase ): _lowercase : str = field(default='''image-class...
17
import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import IterableDatasetDict from da...
17
1
from __future__ import annotations from fractions import Fraction def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ) -> bool: return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def __SCREAMING_SNAKE_CASE ( a__ : in...
17
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
17
1
from __future__ import annotations import math def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : bool ,a__ : list[int] ,a__ : float ) -> int: if depth < 0: raise ValueError("""Depth cannot be less than 0""" ) if not scores: raise ValueEr...
17
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __SCREAMING_SNAKE_CASE ( ) -> Tuple: __A : List[Any] = ArgumentParser( description=( """PyTorch TPU distributed t...
17
1
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCAmelCase_ : int = ...
17
from collections.abc import Sequence def __SCREAMING_SNAKE_CASE ( a__ : Sequence[float] ,a__ : float ) -> float: return sum(c * (x**i) for i, c in enumerate(a__ ) ) def __SCREAMING_SNAKE_CASE ( a__ : Sequence[float] ,a__ : float ) -...
17
1
import datasets UpperCAmelCase_ : str = '''\ @InProceedings{conneau2018xnli, author = "Conneau, Alexis and Rinott, Ruty and Lample, Guillaume and Williams, Adina and Bowman, Samuel R. and Schwenk, Holger ...
17
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class lowerCamelCase_ ( _lowercase ): _lowercase : Union[str, Any] = '''EncodecFeatureExtractor''' _lowercase : Any = ('''T5Tokenizer''', ...
17
1
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=_lowercase ) class lowerCamelCase_ ( _lowercase ): # `task` is not a ClassVar since we want it to be part of the `asdict` outpu...
17
def __SCREAMING_SNAKE_CASE ( a__ : int ) -> int: if not isinstance(a__ ,a__ ): raise TypeError("""Input value must be an 'int' type""" ) __A : Union[str, Any] = 0 while number: position += 1 number >>= 1 return position if __name__ == "__main__": ...
17
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : int = logging.get_logger(__name__) UpperCAmelCase_ : Dict = { '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/co...
17
UpperCAmelCase_ : dict[tuple[int, int, int], int] = {} def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : int ) -> int: # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible if late == 3 or absent == 2: retu...
17
1
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_ : Optional[int] = logging.get_logger(__name__) def __SCREAMING_SNAKE_CASE ( a__ ...
17
class lowerCamelCase_ : def __init__( self : Dict , __A : int , __A : Tuple , __A : List[Any] ): __A : Optional[int] = None __A : Any = None __A : int = graph self._normalize_graph(__A , ...
17
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase_ : Optional[Any] = { '''configuration_wav2vec2''': ['''WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
17
from __future__ import annotations from collections.abc import Sequence from typing import Literal def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : str ) -> str | Literal[False]: __A : Tuple = list(a__ ) __A : Optional[int] = list(a__ ) __A : int ...
17
1
from __future__ import annotations UpperCAmelCase_ : Any = list[list[int]] # assigning initial values to the grid UpperCAmelCase_ : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0,...
17
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( a__ : List[str] ,a__ : Dict ,a__ : Union[str, Any] ,a__ : Any ) -> Optional[int]: # noqa: E741 while r - l > 1: __A : Any = (l + r) // 2 if v[m] >= key: __A : Optional[int] = ...
17
1
import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils impor...
17
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( '''The `inpainting.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionInpaintPipeline` instead.''' )
17
1
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor UpperCAmelCase_ : List[Any] = logging.get_logger(__name__) class lowerCamelCase_ ( _lowercase ): def __init__( self : Union[str, Any] , *__A :...
17
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : str = { '''microsoft/unispeech-large-1500h-cv''': ( '''https://huggingface.co/micro...
17
1
from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class lowerCamelCase_ : _lowercase : int _lowercase : int class lowerCamelCase_ : def __init__( self : Tuple ...
17
import fire from utils import calculate_rouge, save_json def __SCREAMING_SNAKE_CASE ( a__ : Any ,a__ : Tuple ,a__ : Any=None ,**a__ : Dict ) -> Optional[Any]: __A : int = [x.strip() for x in open(a__ ).readlines()] __A : List[str] = [x.str...
17
1
UpperCAmelCase_ : Optional[int] = { 0: '''0''', 1: '''1''', 2: '''2''', 3: '''3''', 4: '''4''', 5: '''5''', 6: '''6''', 7: '''7''', 8: '''8''', 9: '''9''', 10: '''a''', 11: '''b''', 12: '''c''', 13: '''d''', 14: '''e''', 15: '''f''', } def ...
17
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __SCREAMING_SNAKE_CASE ( a__ : Optional[Any] ,a__ : Union[str, Any] ,a__ : Optiona...
17
1
from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__name__) # TODO Update this UpperCAmelCase_ : Union[str, Any] = { '''facebook/esm-1b''...
17
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : int = { '''configuration_informer''': [ '''INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''InformerConfig''', ...
17
1
import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenization_transfo_xl import CORPUS_NAM...
17
import math class lowerCamelCase_ : def __init__( self : Union[str, Any] , __A : List[str]=0 ): # a graph with Node 0,1,...,N-1 __A : List[str] = n __A : List[str] = [ [math.inf for j in range(0 , __A )] for i in ran...
17
1