code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torch_tpu_available...
360
import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def _a ( lowerCAmelCase )-> float: return np.dot(lowerCAmelCase , lowerCAmelCase ) class lowercase_ : def __init__( self : int , *, ...
360
1
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 compute_effective_axis_dimension from ...utils im...
706
from string import ascii_uppercase __SCREAMING_SNAKE_CASE : Any = {char: i for i, char in enumerate(ascii_uppercase)} __SCREAMING_SNAKE_CASE : str = dict(enumerate(ascii_uppercase)) def snake_case (__lowercase , __lowercase ) -> str: '''simple docstring''' ...
580
0
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsm...
519
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase_ : Optional[Any] = {"""configurati...
512
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...
137
"""simple docstring""" import math def lowerCamelCase__ ( _lowerCamelCase : int ) -> bool: assert isinstance(_lowerCamelCase , _lowerCamelCase ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2...
137
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _a : Tuple = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SqueezeBertConfig', ...
213
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int = 1000 ) -> int: _lowerCAmelCase : Optional[int] = 2**power _lowerCAmelCase : str = str(_lowerCamelCase ) _lowerCAmelCase : Optional[int] = list(_lowerCamelCase ) _lowerCAmelC...
213
1
from math import isclose, sqrt def __UpperCAmelCase ( __A , __A , __A ) -> tuple[float, float, float]: '''simple docstring''' UpperCAmelCase__ = point_y / 4 / point_x UpperCAmelCase__ = 2 * normal_gradient / (1 + normal_grad...
717
import csv import tweepy # Twitter API credentials A = "" A = "" A = "" A = "" def __UpperCAmelCase ( __A ) -> None: '''simple docstring''' UpperCAmelCase__ = tweepy.OAuthHandler(__A , __A ) auth...
277
0
__A : Tuple = {str(digit): digit**5 for digit in range(1_0)} def __a ( A__ : int ): return sum(DIGITS_FIFTH_POWER[digit] for digit in str(A__ ) ) def __a ( ): return sum( number for number in range(1000 , 1000...
16
from numpy import exp, pi, sqrt def UpperCAmelCase ( a_ , a_ = 0.0 , a_ = 1.0 ) -> int: """simple docstring""" return 1 / sqrt(2 * pi * sigma**2 ) * exp(-((x - mu) ** 2) / (2 * sigma**2) ) if __name__ == "__main__": import doctest doctest.testmod()
55
0
def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = len(lowerCamelCase ) for i in range(lowerCamelCase ): for j in range(i + 1 , lowerCamelCase ): if numbers[j] < numbers[i]: __lowercase , __lowercase = numbers[...
717
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) def snake_case ( lowerCamelCase ...
53
0
'''simple docstring''' import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dat...
71
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_...
140
0
class __snake_case : def __init__( self ) -> List[str]: '''simple docstring''' snake_case__ : str = 0 snake_case__ : int = 0 snake_case__ : int = {} d...
699
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ : Any = {'''configuration_xglm''': [''...
699
1
import re from ..models.auto import AutoProcessor from ..models.vision_encoder_decoder import VisionEncoderDecoderModel from ..utils import is_vision_available from .base import PipelineTool if is_vision_available(): from PIL import Image class A ( UpperCAmelCase_ ): '''si...
15
"""simple docstring""" from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig,...
690
0
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 : '''simple docstring''' _snake_case = 42 _snake_case =...
15
import math def A__ ( __A ): '''simple docstring''' assert isinstance(__A , __A ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or not numbe...
15
1
import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identified_filename, infer_...
481
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ : int = logging.get_logger(__name__) lowerCamelCase__ : str = { "studio-ousia/luke-base": "https://huggingface.co/studio-ousia/luke-base/resolve/main...
698
0
import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, id...
713
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase_ = { "configuration_m2m_100": ["M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP", "M2M100Config", "M2M100OnnxConfig"], "tokenization_m2m_100": ["M2M1...
586
0
def A__ ( __A : int , __A : List[str] , __A : Tuple , __A : Dict , __A : int , __A : Any ) ->Optional[int]: if index == r: for j in range(__A ): print(data[j] , end=''' ''' ) ...
184
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def A__ ( __A : Any , __A : Dict , __A : Optional[...
184
1
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def UpperCamelCase ( __lowerca...
717
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class UpperCAmelCase ( __A ): '''simple docstring''' ...
70
0
import random import unittest import torch from diffusers import IFInpaintingPipeline 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 import ( TEXT_GUIDED_IMAGE_INPA...
81
import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING from ...tokenization_uti...
106
0
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processor import AttnAddedKVProc...
711
import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL lowerCAmelCase : Tuple =version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") def A__ ( ...
15
0
def SCREAMING_SNAKE_CASE ( snake_case , snake_case ) -> int: return x if y == 0 else greatest_common_divisor(snake_case , x % y ) def SCREAMING_SNAKE_CASE ( snake_case , snake_case ) -> int: return (x * y) // greatest_common_divisor(snake_cas...
375
def SCREAMING_SNAKE_CASE ( snake_case , snake_case ) -> bool: __lowercase = len(snake_case ) + 1 __lowercase = len(snake_case ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # length i of input_string matches with...
375
1
'''simple docstring''' def __UpperCAmelCase ( __magic_name__ ,__magic_name__ )-> str: """simple docstring""" return "\n".join( F'''{number} * {i} = {number * i}''' for i in range(1 ,number_of_terms + 1 ) ) if __name__ == "__main__"...
713
'''simple docstring''' import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py __lowerCamelCase : ...
656
0
'''simple docstring''' def _lowercase ( __A ,__A ): '''simple docstring''' if not (isinstance(__A ,__A ) and isinstance(__A ,__A )): raise ValueError("""longest_common_substring() takes two strings for inputs""" ) __UpperCamelCase = len(__A ...
601
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCAmelCase__ ( metaclass=UpperCAmelCase_): __SCREAMING_SNAKE_CASE = ['''torch''', '''scipy'''] def __init__( self , *lowercase , **lowercase ) -> int: requires_bac...
601
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ =logging.get_logger(__name__) lowercase__ ={ 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class UpperCamelCase__ ( __lowercase ): _SCRE...
717
import argparse import re import requests import torch # git clone https://github.com/salesforce/BLIP.git from models.blip import blip_decoder from models.blip_itm import blip_itm from models.blip_vqa import blip_vqa from PIL import Image from torchvision import transforms from torchvision.transforms.functional impo...
326
0
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _lowercase: Union[str, Any] = logging.get_logger(__name...
192
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_common imp...
192
1
'''simple docstring''' def _snake_case ( A , A , A ) -> float: return round(float(moles / volume ) * nfactor ) def _snake_case ( A , A , A ) -> float: return round(float((moles * 0.0_821 * temperature) / (volume) ) ) ...
715
'''simple docstring''' def _snake_case ( A , A ) -> bool: lowerCAmelCase__ = len(A ) + 1 lowerCAmelCase__ = len(A ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # length i of input_string matches with pr...
98
0
'''simple docstring''' import cmath import math def _A ( UpperCAmelCase ,UpperCAmelCase ,UpperCAmelCase ,UpperCAmelCase ): '''simple docstring''' A__ = math.radians(UpperCAmelCase ) A__ = math.radians(UpperCAmelCase ) ...
531
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class A( UpperCamelCase , unittest.TestCase ): '''simple docstring''' Upp...
70
0
import flax.linen as nn import jax import jax.numpy as jnp class _UpperCamelCase ( nn.Module ): UpperCAmelCase_ = 42 UpperCAmelCase_ = jnp.floataa def UpperCAmelCase_ ( self :Optional[int] ) -> int: UpperCAmelCase__ = nn.Conv( ...
364
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class _UpperCamelCase ( lowerCAmelCase ): # to overwrite at feature extractactor specific tests ...
364
1
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_verbosity_...
85
"""simple docstring""" import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class UpperCamelCase__ ( unittest.TestCase ): """simple docstri...
104
0
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def lowercase__ ( ): with offline(OfflineSimulationMode.CONNECTION_T...
713
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Tuple = logging.get_logger(__name__) _lowercase : Optional[int] = { 'google/realm-cc-news-pretrained-embedder': ( 'https://huggingface....
397
0
'''simple docstring''' from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=__lowerCAmelCase) class lowerCAmelCase ( __lowerCAmelCase): # `task` is not a ClassVar since we ...
24
'''simple docstring''' # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unle...
683
0
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...
583
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCamelCase = { "configuration_luke": ["LUKE_PRETRAINED_CONFIG_ARCHIVE_MAP", "LukeConfig"], "tokenization_luke": ["LukeTokenizer"], } try: if not is_torch_available(): raise ...
583
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase_ = {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTCo...
60
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, RandomHorizontalFl...
568
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE = { 'microsoft/trocr-base-handwritten': ( 'https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json' ), ...
153
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, DPMSo...
153
1
'''simple docstring''' from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer ...
152
'''simple docstring''' import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParser, ...
152
1
from itertools import permutations def lowerCamelCase__ (_UpperCAmelCase): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False SCREAMING_SNAKE_CASE = [7, 11, 13, 17] for i, test in enumerate(SCR...
703
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path a_ : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) a_ : list[int] = [ord(letter) for letter in string.ascii_lowe...
444
0
import os import unittest from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _lower...
613
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) a : List[str] = { """configuration_efficientformer""": [ """EFFICIENTFORMER_PRETRAINED_CONFIG_ARCHIVE_MA...
613
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase : str = logging.get_logger(__name__) lowerCAmelCase : Union[str, Any] = { """xlm-r...
146
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class ...
146
1
'''simple docstring''' 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_bac...
466
'''simple docstring''' from __future__ import annotations from typing import TypedDict class SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE_ ): snake_case__ = 42 snake_case__ = 42 def _UpperCAmelCase ( __A : str ): ...
466
1
'''simple docstring''' import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python ...
706
'''simple docstring''' from __future__ import annotations def _a ( lowerCAmelCase_ , lowerCAmelCase_ = None , lowerCAmelCase_ = None ): """simple docstring""" if start is None: _snake_case : Optional[Any] = 0 if end is None: ...
47
0
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __lowerCamelCase = False class UpperCAmelCa...
467
'''simple docstring''' from __future__ import annotations from collections.abc import Sequence from typing import Literal def a__ ( UpperCamelCase_ : str, UpperCamelCase_ : str ): UpperCAmelCase__ :Any = list(UpperCamelCase_ ) UpperCAmelCase__ :O...
467
1
import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py __lowerCamelCase : List[Any] = "src/diffusers" # Matches is_xxx_available() __lowerCamelCase : List[Any] ...
716
import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum @slow class __magic_name...
457
0
'''simple docstring''' import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cuda, r...
378
'''simple docstring''' import math import sys def UpperCAmelCase_ ( __lowercase : str ) -> str: '''simple docstring''' _UpperCAmelCase = "" try: with open(__lowercase , "rb" ) as binary_file: _UpperCAmelCase = binary_file.read...
236
0
from __future__ import annotations def lowercase_ ( A__ ) -> str: """simple docstring""" for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in range(1 , len(UpperCAmelCase__ ) ): matr...
714
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, TFAutoMod...
294
0
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def UpperCamelCase__( UpperCamelCase__ : Any )->Union[str, Any]: A__ = FileLock(str(tmpdir / '''foo.lock''' ) ) A__ = FileLock(str(tmpdir / '''foo.lock''' ...
190
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class __lowercase ( unittest.TestCase ): ...
604
0
"""simple docstring""" import math def lowercase_ ( ): """simple docstring""" A_ : Dict = input('''Enter message: ''' ) A_ : Optional[int] = int(input(f"""Enter key [2-{len(_UpperCAmelCase ) - 1}]: """ ) ) A_ : str = input('''Encryption/Decrypt...
361
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _lowerCamelCase : List[str] = logging.get_logger(__name__) _lowerCamelCase : str = { ...
361
1
'''simple docstring''' import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class SCREAMING_SNAKE_CASE__ ( _UpperCamelCase ): def A ( self : Optional[Any] , a_ : str ): ""...
69
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) de...
647
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase : Any = { """configuration_informer""": [ """INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InformerConfig"""...
151
def UpperCamelCase_ ( __a = 3 , __a = 7 , __a = 1_000_000 ) -> int: a__ : List[Any] = 0 a__ : int = 1 for current_denominator in range(1 , limit + 1 ): a__ : Optional[Any] = current_denominator * numerator /...
151
1
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingPipeline 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 import ...
18
import numpy as np def __lowerCAmelCase( _SCREAMING_SNAKE_CASE ) -> np.array: """simple docstring""" return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
27
0
import math def _lowercase ( _UpperCAmelCase , _UpperCAmelCase = 0 , _UpperCAmelCase = 0 ) -> list: lowerCamelCase =end or len(_UpperCAmelCase ) for i in range(_UpperCAmelCase , _UpperCAmelCase ): lowerCamelCase =i lowerCamelCase =a...
269
import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_checkpoint UpperCAmelCase__ ...
269
1
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # #...
152
'''simple docstring''' def __UpperCamelCase ( UpperCAmelCase ): lowercase__ : Optional[int] = 0 lowercase__ : int = len(UpperCAmelCase ) for i in range(n - 1 ): for j in range(i + 1 , UpperCAmelCase ): if arr[i] > arr[j]: num_inversions += 1 ret...
152
1
import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, Dict, Iterable, List, Literal, NewType,...
709
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer,...
699
0
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class __lowercase ( tf.keras.optimizers.schedules.LearningRateSchedule ): ...
377
'''simple docstring''' import json import sys def a__ ( _SCREAMING_SNAKE_CASE : Optional[Any] , _SCREAMING_SNAKE_CASE : int ) -> Tuple: """simple docstring""" with open(_SCREAMING_SNAKE_CASE , encoding="utf-8" ) as f: UpperCAmelCase_ : ...
71
0
"""simple docstring""" def lowerCAmelCase_ ( lowercase_ : str ): '''simple docstring''' __SCREAMING_SNAKE_CASE : List[str] = [0] * len(lowercase_ ) for i in range(1 , len(lowercase_ ) ): # use last results for better performance - dynamic programming __SCREA...
718
"""simple docstring""" from math import isqrt def lowerCAmelCase_ ( lowercase_ : int ): '''simple docstring''' return all(number % divisor != 0 for divisor in range(2 , isqrt(lowercase_ ) + 1 ) ) def lowerCAmelCase_ ( lowercase_ : int = 10**6 ): '''...
401
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging A = logging.get_logger(__name__) A = {"""vocab_file""": """spie...
77
"""simple docstring""" def lowerCAmelCase_ (_SCREAMING_SNAKE_CASE :str ) -> int: assert column_title.isupper() a_ : int = 0 a_ : Tuple = len(_SCREAMING_SNAKE_CASE ) - 1 a_ : Union[str, Any] = 0 while index >= 0: ...
473
0
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin lowerCamelCase : Union[str, Any] = """ Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf ori...
168
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCamelCase : Tuple = {"""configuration_deit""": ["""DEIT_PRE...
168
1
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel lowerCAmelCase_ = { 'text_branch': 'text_model', 'audio_branch': 'audio_model.audio_encoder', 'attn': 'a...
560
"""simple docstring""" # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
560
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _a = { "configuration_falcon": ["FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP", "FalconConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAva...
29
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class __A ...
29
1
import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def __UpperCAmelCase ( lowerCamelCase_ : dict ) -> tu...
105
from math import pow, sqrt def _A( *UpperCamelCase__ : float ) -> bool: '''simple docstring''' __lowercase = len(UpperCamelCase__ ) > 0 and all(value > 0.0 for value in values ) return result def _A( UpperCamelCase__ : f...
332
0
'''simple docstring''' def A__ ( A_ ) -> Dict: return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], 8: [5, 7], ...
706
'''simple docstring''' import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class Upp...
602
0
"""simple docstring""" import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _lowerCAmelCase : Optional[int] = [ # tf -> hf ("""/""", """."""), ("""...
46
import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor __lowerCamelCase : Optional[Any] = logging.get_logger(__name__) class A__ ( __snake_case ): def __init__( self , *A_ , **A_ ): '''simple docstring''' ...
629
0
from timeit import timeit def UpperCamelCase ( snake_case__ : int ): '''simple docstring''' if number < 0: raise ValueError("""the value of input must not be negative""" ) __snake_case :List[str] = 0 while...
291
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_availab...
291
1
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent __lowercase : Union[str, Any] = {'''UserAgent''': UserAgent().random} def lowercase ( __A : Optional[Any] ) -> dict: '''simple docstri...
36
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { """microsoft/swinv2-tiny-patch4-window8-256""": ( """https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-256/reso...
420
0
def _lowerCAmelCase ( UpperCamelCase__: List[str] , UpperCamelCase__: Any ) -> str: """simple docstring""" return "\n".join( f'{number} * {i} = {number * i}' for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multipli...
713
from sklearn.metrics import recall_score import datasets _lowercase : Any = "\nRecall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:\nRecall = TP / (TP + FN)\nWhere TP is the true positives and FN is the false negativ...
546
0
"""simple docstring""" from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 UpperCAmelCase = { # 1536-bit 5: { '''prime''': ...
677
'''simple docstring''' import argparse from pathlib import Path import torch from packaging import version from torch.onnx import export from diffusers import AutoencoderKL _lowerCAmelCase = version.parse(version.parse(torch.__version__).base_version) < version.parse("1.11") ...
161
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random...
477
"""simple docstring""" from argparse import ArgumentParser from .env import EnvironmentCommand def lowercase__( ): lowercase_ : List[Any] = ArgumentParser('Diffusers CLI tool' , usage='diffusers-cli <command> [<args>]' ) lowercase_ : int = parser.add_su...
477
1
def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : int ): UpperCamelCase_ : Optional[int] = [[] for _ in range(_SCREAMING_SNAKE_CASE )] UpperCamelCase_ : List[Any] = key - 1 if key <= 0: raise ValueError("""Height ...
635
"""simple docstring""" import argparse 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 accelera...
273
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class _a ( metaclass=lowercase_ ): '''simple docstring''' UpperCamelCase__ = ["""torch""", """transformers""", """onnx"""] def __init__( self , *UpperCAmelCase_ , **Up...
708
"""simple docstring""" import gc import unittest import numpy as np import torch from torch.backends.cuda import sdp_kernel from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) from diffusers.utils import randn_tensor, slow, torch_device from diffuse...
120
0
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration __snake_case :Tuple =HfArgumentParser(InitializationArguments) __snake_case :Optional[int] =parser.parse_args() # Load codeparrot tok...
106
'''simple docstring''' import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot f...
369
0
from math import sqrt def snake_case_ ( _SCREAMING_SNAKE_CASE ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # All primes number are in forma...
707
import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils import ROUGE_KEYS logg...
655
0
'''simple docstring''' def UpperCamelCase_ ( A__ : int , A__ : int ): '''simple docstring''' return int((input_a, input_a).count(1 ) != 0 ) def UpperCamelCase_ ( ): '''simple docstring''' assert or_g...
275
'''simple docstring''' def UpperCamelCase__ ( _lowercase : List[Any] ) -> Dict: return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7: [6, 8], ...
523
0
def UpperCAmelCase ( _lowerCamelCase , _lowerCamelCase = 0 ): A : List[str] = length or len(_lowerCamelCase ) A : str = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]: A , A ...
17
import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import Gra...
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 or...
198
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class...
301
0
UpperCAmelCase__ = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "huggingfa...
718
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiec...
362
0
'''simple docstring''' from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass lowercase_ = (3, 9, -11, 0, 7, 5, 1, -1) lowercase_ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class __A : '''simple docstring''' ...
11
import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageClassifierOutp...
6
0
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...te...
713
"""simple docstring""" import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess...
628
0
import fire from utils import calculate_rouge, save_json def SCREAMING_SNAKE_CASE_ ( _snake_case :Dict , _snake_case :Tuple , _snake_case :List[str]=None , **_snake_case :Tuple ) -> List[str]: _A = [x.strip() for x in open(_snake_case ).readlines()] _A = ...
2
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format="""%(message)s""") def _A ( SCREAMING_SNAKE_CASE ): return input_array.reshape((input_array.size, 1) ) def _A ( SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE ,SC...
113
0
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging a_ : Optional[Any] = logging.get_logger(__name__) def _SCREAMING_SNAKE_CASE ( snake_case_ : List[Any] ): __magic_name__ ...
709
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available a_ : Union[str, Any] = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxConfig'], } try: if not is_to...
678
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_numpy, slow, torch_...
321
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'BridgeTower/bridgetower-base': 'https://huggingface.co/BridgeTower/bridgetower-base/blob/main/conf...
321
1
import os import re import shutil import sys import tempfile import unittest import black UpperCamelCase_ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_copies # noqa: E402 # ...
708
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup UpperCamelCase_ = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/deformable_detr/cuda/ms_deform_im2col_...
510
0
from decimal import Decimal, getcontext from math import ceil, factorial def UpperCamelCase__ ( UpperCAmelCase_ ) -> List[Any]: '''simple docstring''' if not isinstance(lowercase__ , lowercase__ ): raise TypeError('''Undefined for non-integers''' ...
322
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __lowercase : Tuple =logging.get...
54
0
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() snake_case__ : List[Any] = logging.get_logger(__name__) def lowerCamelCase__ ( _lowerCamelCase , _lowe...
592
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class _a ( unittest.TestCase ): """simple docstring""" def SCREAMING_SNAK...
592
1
"""simple docstring""" def lowercase_ ( _snake_case ): if not grid or not grid[0]: raise TypeError("""The grid does not contain the appropriate information""" ) for cell_n in range(1 ,len(grid[0] ) ): grid[0][cell_n] += grid[0][cell_n - 1] SC...
223
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ : Any = logging.get_logger(__n...
223
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a_ : Union[str, Any] = { '''configuration_vision_encoder_decoder''': ['''VisionEncoderD...
719
"""simple docstring""" from __future__ import annotations import unittest from transformers import LEDConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor from ....
263
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class _a ( lowerCAmelCase__ ): '''simple docstring''' lowerCamelCase_ : s...
520
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase = { 'configuration_ctrl': ['CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CTRLConfig'], 'tokenization_ctrl': ['CTRLTokenizer'], } try: i...
520
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase_ : Dict = { """configuration_biogpt""": ["""BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BioGptConfig"""], """tokeniz...
709
'''simple docstring''' def __A ( UpperCAmelCase ,UpperCAmelCase ,UpperCAmelCase=False ) -> Optional[int]: '''simple docstring''' if isinstance(UpperCAmelCase ,UpperCAmelCase ) and isinstance(UpperCAmelCase ,UpperCAmelCase ): ...
204
0
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _lowerCAmelCase = [ # tf -> hf ("/", "."), ("layer_", "layers."), ("kernel", "weight"), ("beta", "bias")...
10
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def _snake_case ( __snake_case , __snake_case ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(__snake_case , __snake_case ) ) ) def _snake_case ( __snake_cas...
10
1
import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _UpperCame...
371
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def lowerCAmelCase_ ( UpperCamelCase_ , UpperCamelCase_=() , UpperCamelCase_=None , UpperCamelCase_="no" , ...
371
1
"""simple docstring""" import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase_ = logging.get_logger(__name__) class _SCREAMING_SNAKE_CASE( A ): ...
498
"""simple docstring""" from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ....
498
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set_verbosity...
218
from __future__ import annotations def snake_case_ (__A : list[int] , __A : int ) -> list[int]: __lowerCAmelCase : List[Any] = 0 __lowerCAmelCase : Optional[Any] = len(__A ) - 1 while i < j: if nums[i] + nums[j] == target...
218
1
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IM...
15
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets A : Dict = '\\n@inproceedings{popovic-2015-chrf,\n title = "chr{F}: character n-gram {F}-score for automatic {MT} evaluation",\n author = "Popovi{\'c}, Maja",\n booktitle = "Proceedin...
15
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.utils import floats_tensor, lo...
714
import argparse import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Distributed...
232
0
'''simple docstring''' def _a( UpperCamelCase__ : Any, UpperCamelCase__ : List[str] ): '''simple docstring''' if discount_rate < 0: raise ValueError('''Discount rate cannot be negative''' ) if not cash_flows: r...
296
"""simple docstring""" import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": lowerCAmelCase__ = argparse.ArgumentParser( description=( 'Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for T...
621
0
'''simple docstring''' import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStr...
195
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_...
195
1
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase_ : str , UpperCAmelCase_ : str ) -> str: assert x is not None assert y is not None __lowerCamelCase : List[str] = len(SCREAMING_SNAKE_CASE_ ) __lowerCamelC...
13
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config.json""", # See all PEGASUS models at https://h...
514
0
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common import ConfigTeste...
25
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __lowerCamelCase : Tuple = { """configuration_roberta_prelayernorm""": [ """ROBERTA_PRELAYERNORM_PRETRAIN...
25
1
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def UpperCAmelCase ( UpperCAmelCase__ : str): lowerCamelCase , lowerCamelCase : Tuple = analyze_text(UpperCA...
320
'''simple docstring''' import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diff...
320
1
"""simple docstring""" import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_toke...
703
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPM...
663
0
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for tuning th...
486
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { 'google/fnet-base': 'https://huggingface.co/google/fnet-base/resolve/main/config.json', 'google/fnet-large': 'https://huggingfa...
486
1
from ...configuration_utils import PretrainedConfig class lowerCamelCase ( lowercase__ ): '''simple docstring''' lowerCAmelCase_ : Dict = 'bert-generation' def __init__( self , lowerCAmelCase=5_0358 , lowerCAmelCase=1024 , lowerCAmelCase=24 ...
23
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def snake_case__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) ...
23
1
"""simple docstring""" from math import sqrt def lowercase ( lowerCAmelCase__ : int ) -> Any: assert isinstance(snake_case__ , snake_case__ ) and ( number >= 0 ), "'number' must been an int and positive" __a = True # 0 and 1 are none prime...
695
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase = { '''configuration_xlm_roberta_xl''': [ '''XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMRobertaXLConfig''', '''XLM...
91
0
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __lowerCAmelCase ( A ...
639
import unittest from knapsack import knapsack as k class __lowerCAmelCase ( unittest.TestCase ): def _lowerCamelCase ( self : Optional[Any]) -> Any: """simple docstring""" _UpperCAmelCase = 0 _UpperCAmelCase = [0] _UpperCAme...
639
1