code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' def lowerCamelCase ( UpperCAmelCase__ : list , UpperCAmelCase__ : list , UpperCAmelCase__ : int ) -> int: if len(UpperCAmelCase__ ) != len(UpperCAmelCase__ ): raise ValueError("""The length of profit and...
239
"""simple docstring""" def A ( snake_case :list[int] , snake_case :int ) -> bool: __UpperCamelCase = len(snake_case ) __UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by...
316
0
def lowercase_ ( _lowerCamelCase : int , _lowerCamelCase : int): return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
87
"""simple docstring""" import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelF...
316
0
"""simple docstring""" import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> Tuple: lowercase__: Optional[int] = [ '''decoder.version''', '''dec...
177
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokeniz...
316
0
"""simple docstring""" def A__ ( UpperCamelCase , UpperCamelCase ): if discount_rate < 0: raise ValueError("Discount rate cannot be negative" ) if not cash_flows: raise ValueError("Cash flows list cannot be empty" ) A = sum( ...
292
"""simple docstring""" import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL UpperCamelCase : Union[str, Any] = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") def ...
316
0
import argparse import json import os import re from collections import OrderedDict from os.path import basename, dirname import fairseq import torch from fairseq import hub_utils from fairseq.data.dictionary import Dictionary from transformers import FSMTConfig, FSMTForConditionalGeneration from transformers.models...
216
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path UpperCamelCase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) UpperCamelCase : list[int] = [ord(letter) for letter in string....
316
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_image, load_nump...
184
"""simple docstring""" UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_93_44, "knot": 1.8_52, } UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_77_77_77_78, "mph": 0.6_21_37_11_92, "knot": 0.5_39_95_68_03, } def A ( ...
316
0
"""simple docstring""" import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller _lowerCamelCase : str = 3 def lowercase_ ( _UpperCAmelCase ): """simple docstring""" print('''Generating prim...
167
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_param...
316
0
"""simple docstring""" from __future__ import annotations from math import pi def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> dict[str, float]: '''simple docstring''' if (inductance, frequency, reactance)....
136
"""simple docstring""" def A ( snake_case :int ) -> int: __UpperCamelCase = [1] __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 0, 0, 0 __UpperCamelCase = ugly_nums[ia] * 2 __UpperCamelCase = ugly_nums[ia] * 3 __UpperCamelCase ...
316
0
"""simple docstring""" import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings lowercase__ = logging...
290
"""simple docstring""" import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class __lowerCAmelCase ( __SCREAMING_SNAKE_CASE )...
316
0
"""simple docstring""" import argparse import os from accelerate.utils import ComputeEnvironment from .cluster import get_cluster_input from .config_args import cache_dir, default_config_file, default_yaml_config_file, load_config_from_file # noqa: F401 from .config_utils import _ask_field, _ask_options, _convert_c...
256
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxG...
316
0
snake_case__ : List[str] = "Input must be a string of 8 numbers plus letter" snake_case__ : Optional[int] = "TRWAGMYFPDXBNJZSQVHLCKE" def _a ( lowerCamelCase: str ) -> bool: '''simple docstring''' i...
117
"""simple docstring""" def A ( snake_case :list[int] , snake_case :list[int] ) -> None: __UpperCamelCase = len(snake_case ) print('The following activities are selected:' ) # The first activity is always selected __UpperCamelCase = 0 print(snake_case...
316
0
'''simple docstring''' import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_comm...
239
"""simple docstring""" def A ( snake_case :int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('The given input must be positive' ) # get the generated string sequence __UpperCamelCase = gray_code_sequence_string(snake_cas...
316
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { "studio-ousia/luke-base": "https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json", "studio-ousia/luke-large": "h...
87
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device ...
316
0
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> bool: if num < 0: return False lowercase__: Union[str, Any] = num lowercase__: Tuple = 0 while num > 0: lowercase__: List[str] = rev_num * 1_0 + (num % 1_0) num //= 1_0 ...
177
"""simple docstring""" def A ( snake_case :int = 1_0 , snake_case :int = 2_2 ) -> int: __UpperCamelCase = range(1 , snake_case ) __UpperCamelCase = range(1 , snake_case ) return sum( 1 for power in powers for base in bases if len(str(...
316
0
"""simple docstring""" def A__ ( UpperCamelCase ): if not head: return True # split the list to two parts A, A = head.next, head while fast and fast.next: A = fast.next.next A = slow.next A = slow.next A =...
292
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't b...
316
0
from __future__ import annotations import math def __UpperCamelCase ( lowerCAmelCase__ : list , lowerCAmelCase__ : list ): if len(lowerCAmelCase__ ) != 2 or len(a[0] ) != 2 or len(lowerCAmelCase__ ) != 2 or len(b[0] ) != 2: raise Exception('''Matrices are not 2x2''' ) __a ...
216
"""simple docstring""" 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, ...
316
0
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class _lowercase : """simple docstring""" def __init__( self : Any ): '''simple docstring''' lowerCamelCase__ : Lis...
184
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelT...
316
0
"""simple docstring""" from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from tr...
167
"""simple docstring""" import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def A ( snake_case :Union[str, Any] , snake_case :Any , snake_case :Union[str, Any] , snake_case :Any ) -> str: __U...
316
0
"""simple docstring""" import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common imp...
136
"""simple docstring""" import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings UpperCamelCase : str = lo...
316
0
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def __a ( _SCREAMING_SNAKE_CASE ) ->list[list[float]]: a__: Dict = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works f...
290
"""simple docstring""" from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar UpperCamelCase : List[str] = TypeVar("KEY") UpperCamelCase : List[str] = TypeVar("VAL") @dataclass(frozen=__SCREAMING_SNAKE_CASE , slots=__SCREAMING_SNAKE_CA...
316
0
"""simple docstring""" import copy import random from transformers import CLIPTokenizer class UpperCAmelCase_ ( __SCREAMING_SNAKE_CASE): def __init__( self : Optional[int] , *__UpperCamelCase : Optional[Any] , **__UpperCamelCase : Optional[int] ) ...
256
"""simple docstring""" def A ( snake_case :int , snake_case :int ) -> bool: return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
316
0
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_conf...
117
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __lowerCAmelCase ( __SCREAMING_SNAKE_...
316
0
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging _lowercase : Tuple = ...
239
"""simple docstring""" def A ( snake_case :list[int] , snake_case :int ) -> bool: __UpperCamelCase = len(snake_case ) __UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by...
316
0
import string from math import logaa def lowercase_ ( _lowerCamelCase : str , _lowerCamelCase : str): lowercase__ : int = document.translate( str.maketrans("" , "" , string.punctuation)).replace("\n" , "") lowercase__ : Any = document_...
87
"""simple docstring""" import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelF...
316
0
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> None: lowercase__: int = len(__UpperCAmelCase ) print('''The following activities are selected:''' ) # The first activity is always selected lowercase__: str = 0 print(...
177
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokeniz...
316
0
"""simple docstring""" class _UpperCAmelCase : def __init__( self :Union[str, Any] , __UpperCamelCase :Dict ): A = len(__UpperCAmelCase ) A = [0] * len_array if len_array > 0: A = array[0] for i in range(1...
292
"""simple docstring""" import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL UpperCamelCase : Union[str, Any] = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") def ...
316
0
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu lowercase__ =get_tests_dir() + "/test_dat...
216
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path UpperCamelCase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) UpperCamelCase : list[int] = [ord(letter) for letter in string....
316
0
from math import pi, sqrt def lowercase_ ( _A : float ): """simple docstring""" if num <= 0: raise ValueError("math domain error" ) if num > 171.5: raise OverflowError("math range error" ) elif num - int(_A ) not i...
184
"""simple docstring""" UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_93_44, "knot": 1.8_52, } UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_77_77_77_78, "mph": 0.6_21_37_11_92, "knot": 0.5_39_95_68_03, } def A ( ...
316
0
"""simple docstring""" from __future__ import annotations def lowercase_ ( _UpperCAmelCase , _UpperCAmelCase ): """simple docstring""" A_ : Tuple = [] A_ : Dict = [] A_ : Tuple = 0 A_ : int =...
167
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_param...
316
0
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase=7 ) -> Any: '''simple docstring''' lowercase_ ...
136
"""simple docstring""" def A ( snake_case :int ) -> int: __UpperCamelCase = [1] __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 0, 0, 0 __UpperCamelCase = ugly_nums[ia] * 2 __UpperCamelCase = ugly_nums[ia] * 3 __UpperCamelCase ...
316
0
"""simple docstring""" import cva import numpy as np class __snake_case : def __init__( self , lowercase , lowercase) -> str: '''simple docstring''' if k in (0.04, 0.06): a__: Optional[Any] = k a__: Dict = win...
290
"""simple docstring""" import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class __lowerCAmelCase ( __SCREAMING_SNAKE_CASE )...
316
0
"""simple docstring""" def lowercase ( ) -> Any: _UpperCamelCase = [] _UpperCamelCase = 1 while len(a__ ) < 1e6: constant.append(str(a__ ) ) i += 1 _UpperCamelCase = ''''''.join(a__ ) return ( in...
256
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxG...
316
0
from __future__ import annotations import queue class A_ : def __init__(self :Optional[Any] , _UpperCamelCase :Any )-> Optional[int]: __A = data __A = None __A = None def _a ( ) -> Tre...
117
"""simple docstring""" def A ( snake_case :list[int] , snake_case :list[int] ) -> None: __UpperCamelCase = len(snake_case ) print('The following activities are selected:' ) # The first activity is always selected __UpperCamelCase = 0 print(snake_case...
316
0
'''simple docstring''' import numpy as np def lowerCamelCase ( UpperCAmelCase__ : np.array ) -> np.array: return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
239
"""simple docstring""" def A ( snake_case :int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('The given input must be positive' ) # get the generated string sequence __UpperCamelCase = gray_code_sequence_string(snake_cas...
316
0
import math import sys def lowercase_ ( _lowerCamelCase : int): if number != int(_lowerCamelCase): raise ValueError("the value of input must be a natural number") if number < 0: raise ValueError("the value of input must not be a negative number") if number == 0: ...
87
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device ...
316
0
"""simple docstring""" import functools from typing import Any def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> bool: # Validation if not isinstance(__UpperCAmelCase , __UpperCAmelCase ) or len(__UpperCAmelCase ) == 0: raise ValueError('''the string sho...
177
"""simple docstring""" def A ( snake_case :int = 1_0 , snake_case :int = 2_2 ) -> int: __UpperCamelCase = range(1 , snake_case ) __UpperCamelCase = range(1 , snake_case ) return sum( 1 for power in powers for base in bases if len(str(...
316
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : int = logging.get_logger(__name__) _snake_case : Optional[int] = { "transfo-xl-wt103": "https://huggingface.co/transfo-xl-wt103/resolve/main/config.json", ...
292
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't b...
316
0
def __UpperCamelCase ( lowerCAmelCase__ : int , lowerCAmelCase__ : int , lowerCAmelCase__ : int ): if exponent == 1: return base if exponent % 2 == 0: __a : int = _modexpt(lowerCAmelCase__ , exponent // 2 , lowerCAmelCase__ ) % modulo_value return (x *...
216
"""simple docstring""" 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, ...
316
0
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGeneratio...
184
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelT...
316
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from trans...
167
"""simple docstring""" import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def A ( snake_case :Union[str, Any] , snake_case :Any , snake_case :Union[str, Any] , snake_case :Any ) -> str: __U...
316
0
"""simple docstring""" from __future__ import annotations UpperCAmelCase : Dict = 8.988E9 # units = N * m^s * C^-2 def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> dict[str, float]: ...
136
"""simple docstring""" import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings UpperCamelCase : str = lo...
316
0
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class __snake_case : a__ = 42 a__ = None a__ = None def __...
290
"""simple docstring""" from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar UpperCamelCase : List[str] = TypeVar("KEY") UpperCamelCase : List[str] = TypeVar("VAL") @dataclass(frozen=__SCREAMING_SNAKE_CASE , slots=__SCREAMING_SNAKE_CA...
316
0
"""simple docstring""" from __future__ import annotations from collections import deque class UpperCAmelCase_ : def __init__( self : int , __UpperCamelCase : Dict ) -> List[str]: _UpperCamelCase = [] self.adlist.append(...
256
"""simple docstring""" def A ( snake_case :int , snake_case :int ) -> bool: return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
316
0
import re import subprocess import sys snake_case__ : Union[str, Any] = subprocess.check_output('git merge-base main HEAD'.split()).decode('utf-8') snake_case__ : Any = subprocess.check_output(f'git diff --name-only {fork_point_sha}'.split()).decod...
117
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __lowerCAmelCase ( __SCREAMING_SNAKE_...
316
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : Optional[int] = { "google/switch-base-8": "https://huggingface.co/google/switch-base-8/blob/main/config.json...
239
"""simple docstring""" def A ( snake_case :list[int] , snake_case :int ) -> bool: __UpperCamelCase = len(snake_case ) __UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by...
316
0
def lowercase_ ( _lowerCamelCase : list[int] , _lowerCamelCase : int): lowercase__ : Optional[Any] = len(_lowerCamelCase) lowercase__ : Tuple = [[False] * (required_sum + 1) for _ in range(arr_len + 1)] # for each arr value, a sum of zero(0) ca...
87
"""simple docstring""" import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelF...
316
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class UpperCAmelCase (__SCREAMING_SNAKE_CASE ): """si...
177
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokeniz...
316
0
"""simple docstring""" import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRoberta...
292
"""simple docstring""" import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL UpperCamelCase : Union[str, Any] = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") def ...
316
0
def __UpperCamelCase ( lowerCAmelCase__ : str , lowerCAmelCase__ : int ): __a : Optional[int] = word.split() def justify(lowerCAmelCase__ : list , lowerCAmelCase__ : int , lowerCAmelCase__ : int ) -> str: __a : Optional[Any] = max_wid...
216
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path UpperCamelCase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) UpperCamelCase : list[int] = [ord(letter) for letter in string....
316
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension...
184
"""simple docstring""" UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_93_44, "knot": 1.8_52, } UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_77_77_77_78, "mph": 0.6_21_37_11_92, "knot": 0.5_39_95_68_03, } def A ( ...
316
0
"""simple docstring""" import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( ...
167
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_param...
316
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase : List[str] = {"configuration_encoder_decoder": ["EncoderDecoderConf...
136
"""simple docstring""" def A ( snake_case :int ) -> int: __UpperCamelCase = [1] __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 0, 0, 0 __UpperCamelCase = ugly_nums[ia] * 2 __UpperCamelCase = ugly_nums[ia] * 3 __UpperCamelCase ...
316
0
"""simple docstring""" from __future__ import annotations import bisect def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = 0 , _SCREAMING_SNAKE_CASE = -1 ) ->int: if hi < 0: a__: Tuple = len(_SCREAMING_SNAKE_CASE ) while lo < hi: ...
290
"""simple docstring""" import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class __lowerCAmelCase ( __SCREAMING_SNAKE_CASE )...
316
0
"""simple docstring""" 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, BlipaProcessor,...
256
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxG...
316
0
import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
117
"""simple docstring""" def A ( snake_case :list[int] , snake_case :list[int] ) -> None: __UpperCamelCase = len(snake_case ) print('The following activities are selected:' ) # The first activity is always selected __UpperCamelCase = 0 print(snake_case...
316
0
'''simple docstring''' import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import comput...
239
"""simple docstring""" def A ( snake_case :int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('The given input must be positive' ) # get the generated string sequence __UpperCamelCase = gray_code_sequence_string(snake_cas...
316
0
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerationTesterM...
87
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device ...
316
0
"""simple docstring""" from functools import reduce __A = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "668966489504452...
177
"""simple docstring""" def A ( snake_case :int = 1_0 , snake_case :int = 2_2 ) -> int: __UpperCamelCase = range(1 , snake_case ) __UpperCamelCase = range(1 , snake_case ) return sum( 1 for power in powers for base in bases if len(str(...
316
0
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAva...
292
"""simple docstring""" # this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.: # python ./utils/get_modified_files.py utils src tests examples # # it uses git to find the forking point and which files were modified - i.e. files not under git won't b...
316
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase__ ( __SCREAMING_SNAKE_CASE ): _SCREAMING_SNAKE_CASE : str = ["image_processor", "tokenizer"] _SCREAMING_SNAKE_CASE : List[str]...
216
"""simple docstring""" 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, ...
316
0
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...
184
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelT...
316
0
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing imp...
167
"""simple docstring""" import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def A ( snake_case :Union[str, Any] , snake_case :Any , snake_case :Union[str, Any] , snake_case :Any ) -> str: __U...
316
0
"""simple docstring""" def _SCREAMING_SNAKE_CASE (__lowerCAmelCase , __lowerCAmelCase ) -> int: '''simple docstring''' return int((input_a, input_a).count(0 ) == 0 ) def _SCREAMING_SNAKE_CASE () -> None: '''simple docst...
136
"""simple docstring""" import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings UpperCamelCase : str = lo...
316
0
"""simple docstring""" def __a ( _SCREAMING_SNAKE_CASE = 1000000 ) ->int: a__: int = 1 a__: Union[str, Any] = 1 a__: Dict = {1: 1} for inputa in range(2 , _SCREAMING_SNAKE_CASE ): a__: Optional[Any] = 0 a__: Dict = inputa...
290
"""simple docstring""" from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar UpperCamelCase : List[str] = TypeVar("KEY") UpperCamelCase : List[str] = TypeVar("VAL") @dataclass(frozen=__SCREAMING_SNAKE_CASE , slots=__SCREAMING_SNAKE_CA...
316
0
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params...
256
"""simple docstring""" def A ( snake_case :int , snake_case :int ) -> bool: return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
316
0
def _a ( lowerCamelCase: Any ) -> List[Any]: '''simple docstring''' __A = len(lowerCamelCase ) __A = sum(lowerCamelCase ) __A = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i in rang...
117
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __lowerCAmelCase ( __SCREAMING_SNAKE_...
316
0
'''simple docstring''' from typing import Any class __magic_name__ : def __init__( self : List[str] , lowercase_ : Optional[int] ): lowercase_ : Optional[Any] = data lowercase_ : Optional[Any] = None def ...
239
"""simple docstring""" def A ( snake_case :list[int] , snake_case :int ) -> bool: __UpperCamelCase = len(snake_case ) __UpperCamelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of zero(0) can be formed by...
316
0
from heapq import heappop, heappush import numpy as np def lowercase_ ( _lowerCamelCase : np.ndarray , _lowerCamelCase : tuple[int, int] , _lowerCamelCase : tuple[int, int] , _lowerCamelCase : bool , ): lowercase__ , lowercase__ : Optional[i...
87
"""simple docstring""" import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelF...
316
0
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> int: if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(__UpperCAmelCase , __UpperCAmelCase ): raise TypeError('''Input value must be a \'int\' type''' ) return bin(...
177
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokeniz...
316
0
"""simple docstring""" import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available _snake_case : Dict = logging.getLogg...
292
"""simple docstring""" import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL UpperCamelCase : Union[str, Any] = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") def ...
316
0
from ....configuration_utils import PretrainedConfig from ....utils import logging lowercase__ =logging.get_logger(__name__) lowercase__ ={ "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ), } class UpperCamelCa...
216
"""simple docstring""" from __future__ import annotations import string from itertools import cycle, product from pathlib import Path UpperCamelCase : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) UpperCamelCase : list[int] = [ord(letter) for letter in string....
316
0
def lowercase_ ( _A : Optional[Any] , _A : List[Any] ): """simple docstring""" print("\nThe shortest path matrix using Floyd Warshall algorithm\n" ) for i in range(_A ): for j in range(_A ): if dist[i][j] !...
184
"""simple docstring""" UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_93_44, "knot": 1.8_52, } UpperCamelCase : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_77_77_77_78, "mph": 0.6_21_37_11_92, "knot": 0.5_39_95_68_03, } def A ( ...
316
0
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase ( _...
167
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_param...
316
0
"""simple docstring""" import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def _SCREAMING_SNAKE_CASE (__lowerCAmelCase ) -> int: '''simple docstring''' lowercase_ = [ ...
136
"""simple docstring""" def A ( snake_case :int ) -> int: __UpperCamelCase = [1] __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 0, 0, 0 __UpperCamelCase = ugly_nums[ia] * 2 __UpperCamelCase = ugly_nums[ia] * 3 __UpperCamelCase ...
316
0
"""simple docstring""" def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->str: a__: Any = len(_SCREAMING_SNAKE_CASE ) a__: Any = len(_SCREAMING_SNAKE_CASE ) a__: Optional[int] = ( first_str_length if first_str_length > second_str_length else...
290
"""simple docstring""" import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class __lowerCAmelCase ( __SCREAMING_SNAKE_CASE )...
316
0
"""simple docstring""" def lowercase ( a__ : int , a__ : int ) -> int: while b: _UpperCamelCase , _UpperCamelCase = b, a % b return a def lowercase ( a__ : int , a__ : int ) -> int: return a if b == 0 else euclidean_...
256
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxG...
316
0
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import C...
117
"""simple docstring""" def A ( snake_case :list[int] , snake_case :list[int] ) -> None: __UpperCamelCase = len(snake_case ) print('The following activities are selected:' ) # The first activity is always selected __UpperCamelCase = 0 print(snake_case...
316
0
'''simple docstring''' from __future__ import annotations def lowerCamelCase ( UpperCAmelCase__ : list[int] , UpperCAmelCase__ : int ) -> bool: if len(UpperCAmelCase__ ) == 0: return False lowercase_ : List[Any] = ...
239
"""simple docstring""" def A ( snake_case :int ) -> list: # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError('The given input must be positive' ) # get the generated string sequence __UpperCamelCase = gray_code_sequence_string(snake_cas...
316
0
import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor UpperCamelCase = logging.get_logger(__name__) class snake_case_ ( __SCREAMING_SNAKE_CASE ): def __init__( self : List[Any] , *lowercase_...
87
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device ...
316
0
import inspect import unittest from transformers import MobileNetVaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTeste...
317
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor a__ = logging.get_logger(__name__) class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' def __init__( self : Any , ...
317
1
import qiskit def lowercase ( SCREAMING_SNAKE_CASE__ : int = 2 ) -> qiskit.result.counts.Counts: _snake_case : Optional[int] = qubits # Using Aer's simulator _snake_case : Optional[Any] = qiskit.Aer.get_backend("""aer_simulator""" ) # Creating a Qu...
317
import warnings from ...utils import logging from .image_processing_videomae import VideoMAEImageProcessor a__ = logging.get_logger(__name__) class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' def __init__( self : str , ...
317
1
def lowercase ( SCREAMING_SNAKE_CASE__ : int ) -> int: if divisor % 5 == 0 or divisor % 2 == 0: return 0 _snake_case : str = 1 _snake_case : Tuple = 1 while repunit: _snake_case : Tuple = (10 * repunit + 1) % divisor repunit_index += 1 r...
317
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor a__ = logging.get_logger(__name__) class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' def __init__( self : List[Any] , ...
317
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available a__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: a__ = ["""M...
317
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def lowercase ( SCREAMING_SNAKE_CASE__ : Optional[int] ) -> int: return getitem, k def lowercase ( SCREAMING_SNAKE_CASE__ : Tuple , S...
317
1
from ...configuration_utils import PretrainedConfig from ...utils import logging a__ = logging.get_logger(__name__) a__ = { """facebook/vit-mae-base""": """https://huggingface.co/facebook/vit-mae-base/resolve/main/config.json""", # See all ViT MAE models at https://huggingface.co/models...
317
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' @require_torch ...
317
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging a__ = logging.get_logger(__name__) a__ = """▁""" a__ = ...
317
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) a__ = pytest.mark.integration @pytest.mark.parametrize("""path""" , ["""paws""",...
317
1
def lowercase ( SCREAMING_SNAKE_CASE__ : Union[str, Any] , SCREAMING_SNAKE_CASE__ : Optional[int] ) -> List[Any]: _snake_case : Any = """""" for i in table: res += inp[i - 1] return res def lowercase ( SCREAMING_SNAKE_CASE__ : List[str] )...
317
import pprint import requests a__ = """https://zenquotes.io/api""" def lowercase ( ) -> list: return requests.get(API_ENDPOINT_URL + """/today""" ).json() def lowercase ( ) -> list: return requests.get(API_ENDPOINT_URL + """/random""" ).json() ...
317
1
def lowercase ( SCREAMING_SNAKE_CASE__ : int ) -> list[int]: if num <= 0: raise ValueError("""Input must be a positive integer""" ) _snake_case : Dict = [True] * (num + 1) _snake_case : Tuple = 2 while p * p <= num: if primes[p]: for i in rang...
317
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indic...
317
1
import torch from diffusers import StableDiffusionPipeline a__ = """path-to-your-trained-model""" a__ = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""") a__ = """A photo of sks dog in a bucket""" a__ = pipe(prompt, num_inference_steps=50, guida...
317
from ..utils import DummyObject, requires_backends class snake_case ( metaclass=SCREAMING_SNAKE_CASE_ ): '''simple docstring''' snake_case_ : Optional[Any] = ["""torch"""] def __init__( self : Union[str, Any] , *lowerC...
317
1
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' @require_torch ...
317
from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a__ = logging.get_logger(__name__) a__ = { """google/efficientnet-b7""": ...
317
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=SCREAMING_SNAKE_CASE_ ) class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple...
317
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE_ ) class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' ...
317
1
def lowercase ( SCREAMING_SNAKE_CASE__ : int = 3 , SCREAMING_SNAKE_CASE__ : int = 7 , SCREAMING_SNAKE_CASE__ : int = 1_000_000 ) -> int: _snake_case : Dict = 0 _snake_case : Tuple = 1 for current_denominator in range(1 , limit + 1 ): _snak...
317
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a__ = { """configuration_wav2vec2""": ["""WAV_2_VEC_2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Wav2Vec2Config"""], ...
317
1
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py a__ = """\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, title = {BLEU: a Method for Automatic Evaluati...
317
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataStructu...
317
1
def lowercase ( SCREAMING_SNAKE_CASE__ : int = 1_000_000 ) -> int: _snake_case : Optional[int] = set(range(3 , SCREAMING_SNAKE_CASE__ , 2 ) ) primes.add(2 ) for p in range(3 , SCREAMING_SNAKE_CASE__ , 2 ): if p not in primes: continue primes.differen...
317
import torch from torch import nn class snake_case ( nn.Module ): '''simple docstring''' def __init__( self : int , lowerCAmelCase : Tuple , lowerCAmelCase : int , lowerCAmelCase : Any , lowerCAmelCase : T...
317
1
from typing import List import numpy as np def lowercase ( SCREAMING_SNAKE_CASE__ : dict ) -> int: _snake_case : Union[str, Any] = {key: len(SCREAMING_SNAKE_CASE__ ) for key, value in gen_kwargs.items() if isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE_...
317
from ...processing_utils import ProcessorMixin class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' snake_case_ : int = ["""image_processor""", """feature_extractor"""] snake_case_ : List[Any] = """T...
317
1
from ....utils import logging a__ = logging.get_logger(__name__) class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' def __init__( self : List[str] , lowerCAmelCase : Tuple , lowerCAmelCase : Dict=None , ...
317
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
317
1
import random from .binary_exp_mod import bin_exp_mod def lowercase ( SCREAMING_SNAKE_CASE__ : Optional[int] , SCREAMING_SNAKE_CASE__ : Dict=1_000 ) -> Union[str, Any]: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd _snake_case...
317
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a__ = logging.get_logger(__name__) a__ = { """xlm-roberta-base""": """https://huggingface.co/xlm-roberta-base/re...
317
1
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_...
317
import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast from dat...
317
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 a__ = """.""" if __name__ == "__main__": a__ = os.path.join(REPO_PATH, """utils/documentation_tests.txt""") a__ = [] a__ = [] ...
317
from __future__ import annotations from typing import TypedDict class snake_case ( SCREAMING_SNAKE_CASE_ ): '''simple docstring''' snake_case_ : str snake_case_ : int def lowercase ( SCREAMING_SNAKE_CASE__ : st...
317
1
import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available, logging ...
317
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_mo...
317
1
import math def lowercase ( SCREAMING_SNAKE_CASE__ : int ) -> list: _snake_case : Optional[int] = [True] * n _snake_case : Union[str, Any] = False _snake_case : List[Any] = False _snake_case : Union[str, Any] = True for i in r...
317
def lowercase ( SCREAMING_SNAKE_CASE__ : str ) -> list: _snake_case : Optional[Any] = [0] * len(SCREAMING_SNAKE_CASE__ ) for i in range(1 , len(SCREAMING_SNAKE_CASE__ ) ): # use last results for better performance - dynamic programming _snake_case : Optiona...
317
1