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 typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : Union[str, Any] = { '''configuration_mctct''': ['''MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MCTCTConfig'''], '''feature_extraction_mctct''': ['''MCTCTFeat...
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 unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, AutoencoderKL, DDIMS...
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 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
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 logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, Compose, Normalize, RandomHorizontalFlip, ...
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.abc import Sequence def __SCREAMING_SNAKE_CASE ( a__ : Sequence[int] | None = None ) -> int: if nums is None or not nums: raise ValueError("""Input sequence should not be empty""" ) __A : Dict = nums[0] for i in range(1 ,len(a__ ) ): ...
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
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowerCamelCase_ (...
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 argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( BarkCoarseConfig, B...
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
def __SCREAMING_SNAKE_CASE ( a__ : str ) -> str: return " ".join( """""".join(word[::-1] ) if len(a__ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words('''Hey wollef sro...
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 numpy as np # Importing the Keras libraries and packages import tensorflow as tf from tensorflow.keras import layers, models if __name__ == "__main__": # Initialising the CNN # (Sequential- Building the model layer by layer) UpperCAmelCase_ : Optional[Any] = models.Sequential() # S...
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 contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def __SCREAMING_SNAKE_CASE ( a__ : int ) ->...
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 requests UpperCAmelCase_ : List[Any] = '''''' # <-- Put your OpenWeatherMap appid here! UpperCAmelCase_ : List[Any] = '''https://api.openweathermap.org/data/2.5/''' def __SCREAMING_SNAKE_CASE ( a__ : str = "Chicago" ,a__ : str = APPID ) -> dic...
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 from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CLIPTokenizerFast from u...
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 __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup UpperCAmelCase_ : List[Any] = '''https://www.indeed.co.in/jobs?q=mobile+app+development&l=''' def __SCREAMING_SNAKE_CASE ( a__ : str = "mumbai" ) -> Ge...
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 ) -> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
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
def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ) -> int: return number | (1 << position) def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ) -> int: return number & ~(1 << position) def __SCREAMING_SNAKE_CASE ( a__ : in...
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
def __SCREAMING_SNAKE_CASE ( a__ : str ) -> list: __A : int = [0] * len(a__ ) for i in range(1 ,len(a__ ) ): # use last results for better performance - dynamic programming __A : List[Any] = prefix_result[i - 1] while j > 0 and input_string...
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 os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTokenizer from transformers.models.mbart.modeling_mbart impo...
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 import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, is_vision_available from...
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
from __future__ import annotations def __SCREAMING_SNAKE_CASE ( a__ : list[float] ,a__ : list[float] ) -> float: __A : str = sorted(numsa + numsa ) __A , __A : Any = divmod(len(a__ ) ,2 ) if mod == 1: return all_numbers[div] else:...
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 argparse from collections import defaultdict import yaml UpperCAmelCase_ : List[str] = '''docs/source/en/_toctree.yml''' def __SCREAMING_SNAKE_CASE ( a__ : int ) -> Union[str, Any]: __A : Union[str, Any] = defaultdict(a__ ) __A : Dict = ...
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 torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class lowerCamelCase_ ( _lowercase ): _lowercase : Dict = '''M-CLIP''' def __init__( self : List[str] , __A : str=1024 , __A : Optional[Any]=76...
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
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax 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
def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : str ) -> Union[str, Any]: assert x is not None assert y is not None __A : str = len(a__ ) __A : Tuple = len(a__ ) # declaring the array for storing the dp values __A : Dict = [[0] * (n + ...
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 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
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
def __SCREAMING_SNAKE_CASE ( a__ : List[Any] ,a__ : Tuple ,a__ : Any ,a__ : Any ) -> Tuple: global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: __A : Any = mf_knapsack(i - 1 ,a__ ,a__ ,a__ ) else: __A : str...
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 argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __SCREAMING_SNAKE_CASE ( a__ : Any ,a__ : Optional[Any] ) ...
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 __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function UpperCAmelCase_ : Optional[Any] = 1.0_5457_1817e-34 # unit of ℏ : J * s UpperCAmelCase_ : Union[str, Any] = 3e8 # unit of c : m * s^-...
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 unittest from knapsack import greedy_knapsack as kp class lowerCamelCase_ ( unittest.TestCase ): def lowerCAmelCase_ ( self : Optional[Any] ): __A : str = [10, 20, 30, 40, 50, 60] __A : str = [2, 4, 6, 8, 10, 12] __A : List[Any] ...
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
from __future__ import annotations import os from collections.abc import Mapping UpperCAmelCase_ : List[str] = tuple[int, int] class lowerCamelCase_ : def __init__( self : Dict , __A : set[int] , __A : Mapping[EdgeT, int] ): ...
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 copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : Optional[Any] = { '''Intel/dpt-large''': '''https://huggingface.co/Intel/dpt-large/r...
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 colorsys from PIL import Image # type: ignore def __SCREAMING_SNAKE_CASE ( a__ : float ,a__ : float ,a__ : int ) -> float: __A : List[Any] = x __A : int = y for step in range(a__ ): # noqa: B007 __A : List[Any] = a * a - b * ...
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 typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, valid_i...
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 inspect import unittest from transformers import BitConfig 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_backbone_common import BackboneTesterMixin from ...test_conf...
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 def __SCREAMING_SNAKE_CASE ( ) -> int: __A : Optional[Any] = os.path.join(os.path.dirname(a__ ) ,"""num.txt""" ) with open(a__ ) as file_hand: return str(sum(int(a__ ) for line in file_hand ) )[:10] if __name__ == "__main__": print(...
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 argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() UpperCAmelCase_ : str = logging.get_logger(__name__) def ...
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 unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCAmelCase_ : Optional[int] = get_tests...
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_ : Dict = logging.get_logger(__name__) UpperCAmelCase_ : Tuple = { '''Visual-Attention-Network/van-base''': ( '''https://huggingface.co/Visual-Attention-Network/van-base/blob/ma...
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 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
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_torch_available UpperCAmelCase_ : str = { '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], } try: if not is_torch_available(): ...
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 copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCase_ : Dict = { '''facebook/mask2former-swin-small-coco-instance''': ( '''https://huggingface.co/facebook/mask2...
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__ : str ) -> bool: if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __A : Optional[int] = sorted(string.lower() ) return len(a__ ) == len(set(a__ ...
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 ) -> bool: 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...''') UpperCAmelCase_ : Op...
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 bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class lowerCamelCase_ ( _lowercase ): def __lt__( self : str , __A : Tuple ): return self[-1] < other[-1] def...
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
def __SCREAMING_SNAKE_CASE ( a__ : Union[str, Any] ) -> int: stooge(a__ ,0 ,len(a__ ) - 1 ) return arr def __SCREAMING_SNAKE_CASE ( a__ : Optional[int] ,a__ : Tuple ,a__ : str ) -> Any: if i >= h: return # If first elem...
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
UpperCAmelCase_ : str = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __SCREAMING_SNAKE_CASE ( a__ : Union[str, Any] ,a__ : str ,a__ : Any ,a__ : List[st...
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 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
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 warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class lowerCamelCase_ ( _lowercase ): _lowercase : Union[str, Any] ...
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
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
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 copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class lowerCamelCase_ ( _lowercase ): def __init__( self : int , __A : List[str] , __A : Opti...
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 string from math import logaa def __SCREAMING_SNAKE_CASE ( a__ : str ,a__ : str ) -> int: __A : Optional[int] = document.translate( str.maketrans("""""" ,"""""" ,string.punctuation ) ).replace("""\n""" ,"""""" ) __A : List[Any] ...
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 unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCAmelCase_ : List[Any] = get_tests_dir('''fixtures/test_sentencepiece_with_...
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 torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def __SCREAMING_SNAKE_CASE ( ) -> str: raise RuntimeError("""CUDA out of memory.""" ) class lowerCamel...
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 import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as ort ...
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 # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. UpperCAmelCase_ : int = 10 def __SCREAMING_SNAKE_CASE ( a__ : int ,a__ : int ,a__ : list[int]...
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
def __SCREAMING_SNAKE_CASE ( a__ : Tuple ,a__ : List[str] ) -> Tuple: print("""\nThe shortest path matrix using Floyd Warshall algorithm\n""" ) for i in range(a__ ): for j in range(a__ ): if dist[i][j] != float("""inf""" ): print(int(dist[i][j] ...
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 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
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 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
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 typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Any = {'''configuration_opt''': ['''OPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '...
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 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 UpperCAmelCase_ : Optional[int] = 4 UpperCAmelCase_ : List[str] = 3 class lowerC...
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 import torch from torch import nn from diffusers.models.activations import get_activation class lowerCamelCase_ ( unittest.TestCase ): def lowerCAmelCase_ ( self : Optional[int] ): __A : str = get_activation("""swish""" ) self....
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 argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Efficie...
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 time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging UpperCAmelCase_ : List[str] = logging.get_logger(__name__) UpperCAmelCase_ : Union[str, Any] = r''' Args: i...
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 from pathlib import Path def __SCREAMING_SNAKE_CASE ( ) -> Optional[int]: from torch.utils.cpp_extension import load __A : int = Path(a__ ).resolve().parent.parent.parent / """kernels""" / """deformable_detr""" __A : Any = [ root / filename for filen...
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 __future__ import annotations from random import choice def __SCREAMING_SNAKE_CASE ( a__ : str ) -> Optional[Any]: return choice(a__ ) def __SCREAMING_SNAKE_CASE ( a__ : list[int] ,a__ : int ) -> int: __A : List[str] = random_...
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 typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCAmelCase_ : Optional[Any] = { '''configuration_altclip''': [ '''ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AltCLIPConfig''', ...
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
from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention...
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 ,a__ : int ,a__ : int ) -> int: if exponent == 1: return base if exponent % 2 == 0: __A : int = _modexpt(a__ ,exponent // 2 ,a__ ) % modulo_value return (x * x) % modulo_value else: return (base * _modex...
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 math import factorial def __SCREAMING_SNAKE_CASE ( a__ : int = 100 ) -> int: return sum(map(a__ ,str(factorial(a__ ) ) ) ) if __name__ == "__main__": print(solution(int(input('''Enter the Number: ''').strip())))
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 gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, lo...
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 itertools import string from collections.abc import Generator, Iterable def __SCREAMING_SNAKE_CASE ( a__ : Iterable[str] ,a__ : int ) -> Generator[tuple[str, ...], None, None]: __A : Union[str, Any] = iter(a__ ) while True: __A : Union[str, Any] =...
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 tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase_ ( _lowercase ): _lowercase : str = (PNDMScheduler,) _lowercase : List[Any] = (('''num_inference_steps''', 50),) def low...
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
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : List[str] = { '''configuration_bert''...
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
UpperCAmelCase_ : int = '''0.18.2''' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_librosa_avai...
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 math import factorial def __SCREAMING_SNAKE_CASE ( a__ : int = 100 ) -> int: return sum(int(a__ ) for x in str(factorial(a__ ) ) ) if __name__ == "__main__": print(solution(int(input('''Enter the Number: ''').strip())))
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
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
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 gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepInverseScheduler, DPMS...
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 pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __SCREAMING_SNAKE_CASE ( a__ : Optional[int] ,a__ : Any ) ...
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 json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCAmelCase_ : Dict = logging.get_logger(__n...
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 inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common...
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 math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute_subprocess_async, get_...
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 unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inp...
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 json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCamelCase_ ( _lowercase , unittest.TestCas...
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_ : List[str] = { '''configuration_groupvit''': [ '''GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GroupViTConfig''', '''Gro...
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
class lowerCamelCase_ : def __init__( self : int ): __A : int = 0 __A : Union[str, Any] = 0 __A : Any = {} def lowerCAmelCase_ ( self : List[Any] , __A : Dict ): if vertex not in self.adjacency:...
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
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
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 Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_allow_in_graph cla...
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 from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokeni...
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 importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import version from .. import __vers...
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 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
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 json import os 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 Acce...
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 __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
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 os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py UpperCAmelCase_ : Tuple = '''.''' if __name__ == "__main__": UpperCAmelCase_ : Any = os.path.join(REPO_PATH, '''utils/documentatio...
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 Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def __SCREAMING_SNAKE_CASE ( a__ : Dict[str, torch.Tensor] ) -> Dict[str, torch.Tensor]: __A : int = [] __A : str = [] ...
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
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase_ : Union[str, Any] = {'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig''', '''YolosOnnxConfig''']} try: if...
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 datasets from .evaluate import evaluate UpperCAmelCase_ : str = '''\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={EMNLP}, year={2016...
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 from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, r...
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
from maths.prime_check import is_prime def __SCREAMING_SNAKE_CASE ( a__ : int ) -> int: if not isinstance(a__ ,a__ ): __A : Any = f"""Input value of [number={number}] must be an integer""" raise TypeError(a__ ) if is_prime(a__ ) and is_prime(number + 2...
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 gc import unittest import numpy as np import torch from diffusers import StableDiffusionKDiffusionPipeline from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu enable_full_determinism() @slow @require_torch_gpu class ...
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 warnings from functools import wraps from typing import Callable def __SCREAMING_SNAKE_CASE ( a__ : Callable ) -> Callable: @wraps(a__ ) def _inner_fn(*a__ : Union[str, Any] ,**a__ : Any ): warnings.warn( (f"""'{fn.__name__}' is experimental and...
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 typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, Flax...
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