code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" import argparse import torch from huggingface_hub import hf_hub_download from transformers import AutoTokenizer, RobertaPreLayerNormConfig, RobertaPreLayerNormForMaskedLM from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCase : Tuple = ...
291
'''simple docstring''' import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOCK_REC...
1
0
"""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/lice...
11
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorch...
11
1
def _lowerCAmelCase ( )->Union[str, Any]: '''simple docstring''' return [ a * b * (1_000 - a - b) for a in range(1 , 999 ) for b in range(lowercase__ , 999 ) if (a * a + b * b == (1_000 - a - b) ** 2) ][0] if __name__ == ...
159
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def _UpperCamelCase ( *lowercase__ , lowercase__ = None , lowercase__=True , lowercase__=2 ): from .. import __version__ __SCREAMING_SNAKE_CASE ...
9
0
"""simple docstring""" import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE...
69
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL i...
69
1
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 ConfigTes...
51
'''simple docstring''' import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_mo...
206
0
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow a__ = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ '''text-classification''', '...
15
import argparse import os import re import packaging.version a__ = '''examples/''' a__ = { '''examples''': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''), '''init''': (re.compile(R'''^__version__\s+=\s+"([^"]+)"\s*$''', re.MULT...
15
1
"""simple docstring""" from collections import defaultdict from math import ceil, sqrt def _snake_case ( UpperCamelCase : int = 1000000 , UpperCamelCase : int = 10 ): UpperCAmelCase : defaultdict = defaultdict(UpperCamelCase ) for outer_width in range(3 , (t_limit...
109
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets lowerCAmelCase_ = datasets.logging.get_logger(__name__) lowerCAmelCase_ = '''\ @inproceedings{bleurt, title={BLEURT: Learning Robust Metrics for Text Generation}, author={Thibault Se...
279
0
'''simple docstring''' import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify,...
367
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class __SCREAMING_SNAKE_CASE : '''simple docstring''' lowerCamelCase_ :int lowerCamelCase_ :int class ...
274
0
# 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 # # Unless required by a...
11
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_sentencepiece_...
11
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json''', } class ...
296
"""simple docstring""" import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class ...
296
1
"""simple docstring""" import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class UpperCamelCase ( lowerCAmelCase__ ): ...
69
"""simple docstring""" 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, ) if is_sentencepiece_available(): from ..ta.token...
69
1
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision import transforms from transformers import BitImageProcessor, FocalNetConfig, FocalNetForImageClassification from transformers.image_utils import IMAGEN...
371
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling_...
219
0
import argparse import json import logging import os import sys from unittest.mock import patch from transformers.testing_utils import TestCasePlus, get_gpu_count, slow SCREAMING_SNAKE_CASE :List[str] = [ os.path.join(os.path.dirname(__file__), dirname) for dirname in [ 'text-classif...
15
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 @dataclass class UpperCAmelCase ( _...
15
1
from timeit import timeit def _UpperCamelCase (a__ :int ): """simple docstring""" if number < 0: raise ValueError("""the value of input must not be negative""" ) UpperCamelCase__ = 0 while number: number &= n...
87
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_u...
87
1
from collections import deque from math import floor from random import random from time import time class _lowercase : """simple docstring""" def __init__( self : Tuple ): '''simple docstring''' lowerCamelCase_...
184
from collections import deque class A : '''simple docstring''' def __init__( self : List[str] , __lowerCAmelCase : str , __lowerCAmelCase : int , __lowerCAmelCase : int ) -> None: """simple docstring""" ...
274
0
'''simple docstring''' import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, ...
287
'''simple docstring''' def a__ ( lowercase : int, lowercase : int ) -> int: """simple docstring""" return x if y == 0 else greatest_common_divisor(lowercase, x % y ) def a__ ( lowercase : int, lowercase : int ) -> int: """simple docstrin...
287
1
# Author: OMKAR PATHAK, Nwachukwu Chidiebere # Use a Python dictionary to construct the graph. from __future__ import annotations from pprint import pformat from typing import Generic, TypeVar SCREAMING_SNAKE_CASE_ = TypeVar("""T""") class UpperCamelCase__ ( Generic[T] )...
296
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_ = { """configuration_llama""": ["""LLAMA_PRETRAINED_CONFI...
296
1
import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from transfo...
352
import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def lowerCamelCase__ ( a__ : Dict ) -> List[Any]: UpperCamelCase_ = {} UpperCamelCase_ ...
261
0
'''simple docstring''' import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization i...
104
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switching between c...
219
0
'''simple docstring''' class UpperCamelCase__ : """simple docstring""" def __init__( self , snake_case__ ): '''simple docstring''' _lowerCAmelCase : Tuple = set_counts _lowerCAmelCase : ...
357
'''simple docstring''' import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class UpperCamelCase__ : """simple docstring""" __magic_name__ = None __magic_name__ ...
25
0
from collections import Counter import numpy as np from sklearn import datasets from sklearn.model_selection import train_test_split UpperCamelCase = datasets.load_iris() UpperCamelCase = np.array(data['''data''']) UpperCamelCase = np.array(data['''target''']) UpperCa...
87
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def lowercase_ ( _lowerCamelCase : str , _lowerCamelCase : List[Any] , _lowerCamelCase ...
87
1
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipelin...
191
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : Union[str, Any] = { '''configuration_bigbird_pegasus''': [ '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BigBirdPegasusC...
191
1
from __future__ import annotations def _a ( lowerCamelCase, lowerCamelCase, lowerCamelCase, lowerCamelCase ): # noqa: E741 while r - l > 1: lowerCamelCase : Any = (l + r) // 2 if v[m] >= key: lowerCamelCase : List[str] = m else: lowerCamelCase : Dict ...
287
# Copyright 2021 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 # # Unless required by app...
287
1
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sa...
294
'''simple docstring''' __lowercase : Optional[Any] = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} __lowercase : List[str] = ['a', 'b', 'c', 'd', 'e'] def lowerCamelCase (_SCREAMING_SNAKE_CASE : List[Any] , _SCREAMING_SNAKE_CASE : A...
294
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__:Optional[int] = { """configuration_clipseg""": [ """CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CLIPSegConfig""", ...
261
"""simple docstring""" import operator def _lowerCamelCase( a , a = False , a = None ): __a = operator.lt if reverse else operator.gt __a = solution or [] if not arr: return solution __a = [arr.pop(0 )] for i, i...
261
1
'''simple docstring''' def __UpperCAmelCase ( a_: int = 10, a_: int = 1_000, a_: bool = True ): assert ( isinstance(a_, a_ ) and isinstance(a_, a_ ) and isinstance(a_, a_ ) ), "Invalid type of value(s) specified to function!" if min_val > max_val...
17
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from itertools import chain from typing import Optional, Union import datasets import numpy as np import torch from datasets import load_dataset import transformers from transformers import ( AutoConfig, ...
17
1
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean snake_case_ : str = 0 snake_case_ : Union[str, Any] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0...
51
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.m...
25
0
def UpperCAmelCase_( a__ ): """simple docstring""" return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
19
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers.utils...
19
1
"""simple docstring""" import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_avai...
191
"""simple docstring""" import qiskit def __lowerCamelCase ( a_ : int , a_ : int ) -> qiskit.result.counts.Counts: __SCREAMING_SNAKE_CASE :Tuple = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the ...
191
1
'''simple docstring''' from __future__ import annotations import csv import requests from bsa import BeautifulSoup def snake_case_ ( __SCREAMING_SNAKE_CASE : str = "" ): """simple docstring""" lowercase_ : Union[str, Any] = url or '...
264
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require...
264
1
"""simple docstring""" def lowerCAmelCase__ ( UpperCamelCase__ ): '''simple docstring''' _a : List[Any] = len(UpperCamelCase__ ) while cur > 1: # Find the maximum number in arr _a : str = arr.index(max(arr[0:cur] )...
294
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available...
294
1
import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import Tokenizer...
197
from math import sqrt def lowerCAmelCase( __lowerCamelCase ): __a = 0 for i in range(1 , int(sqrt(__lowerCamelCase ) + 1 ) ): if n % i == 0 and i != sqrt(__lowerCamelCase ): total += i + n // i elif i == sqrt(__lowerCam...
197
1
"""simple docstring""" def _A ( UpperCamelCase_ : int = 10, UpperCamelCase_ : int = 1000, UpperCamelCase_ : bool = True) -> int: '''simple docstring''' assert ( isinstance(UpperCamelCase_, UpperCamelCase_) and isinstance(UpperCamelCase_, UpperC...
17
"""simple docstring""" from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, Stabl...
17
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) A : str = { '''configuration_blip''': [ '''BLIP_PRETRAINED_CONFIG_ARCHIVE...
370
'''simple docstring''' def lowerCAmelCase__ ( lowerCamelCase : int = 10 ): if not isinstance(lowerCamelCase ,lowerCamelCase ) or n < 0: raise ValueError('Invalid input' ) _A : Optional[Any] = 10**n _A : List[str] = 2...
227
0
import math __A =1_0 __A =7 __A =BALLS_PER_COLOUR * NUM_COLOURS def lowerCamelCase_ ( lowerCamelCase__ = 2_0 ): lowerCamelCase_ = math.comb(lowerCamelCase__ , lowerCamelCase__ ) lowerCamelCase_ = math.comb(NUM_BALLS - BALLS_PER_COLOUR , lowerCamelCase__ ) lowerC...
19
# Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position __A ='''2.13.1''' import platform import pyarrow from packaging import version if version.parse(platform.python_version()) < version.parse('''3.7'''): raise ImportWarning( ...
19
1
"""simple docstring""" import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE_ ( snake_case : Any , snake_case : str ...
80
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : int )-> list[int]: if num <= 0: raise ValueError('Input must be a positive integer' ) _lowerCamelCase = [True] * (num + 1) _lowerCamelCase = 2 while p * p <= num: ...
80
1
"""simple docstring""" import warnings from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : Optional[Any] = logging.get_logger(__name__) lowercase__ : Union[str, Any] = { '''xlnet-base-cased''': '''https://huggingface.co/xlnet-base-cased...
264
"""simple docstring""" from __future__ import annotations def __lowercase ( _a , _a , _a , ): if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('''You cannot supply more or less than 2 values''' ) elif stress < 0: raise ValueError('''Stress cann...
264
1
from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, RequestCounter, ...
119
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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, OPENAI_...
119
1
"""simple docstring""" import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_downlo...
197
"""simple docstring""" from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class _A : def A__ ( self , __lowerCAmelCase ): """simple docstri...
197
1
class A : def __init__( self, UpperCamelCase__ = "", UpperCamelCase__ = False ): """simple docstring""" lowerCAmelCase_ = {} # A node will be a leaf if the tree contains its word lowerCAmelCase_ = is_leaf lowerCAmelC...
351
from ...configuration_utils import PretrainedConfig from ...utils import logging _A = logging.get_logger(__name__) _A = { '''EleutherAI/gpt-neox-20b''': '''https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json''', # See all GPTNeoX models at https://huggingfac...
167
0
'''simple docstring''' import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): A_ = yaml.safe_load( "\\nname: \"\"\nallow_empty: false\nallow_empty_text: true\nsubsect...
139
_lowercase: Dict = [ (1000, "M"), (900, "CM"), (500, "D"), (400, "CD"), (100, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] def a( A : str ) -> int: """simple docs...
227
0
def __A ( __lowerCamelCase ) -> list[int]: a = [0 for i in range(len(__lowerCamelCase ) )] # initialize interval's left pointer and right pointer a , a = 0, 0 for i in range(1 , len(__lowerCamelCase ) ): # case when current index...
347
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : int = { "shi-labs/n...
347
1
'''simple docstring''' import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def _UpperCamelCase ( ) -> List[Any]: '''simple docstring''' UpperCamelCase__ = ...
80
'''simple docstring''' from __future__ import annotations def _UpperCamelCase ( __A ) -> float: '''simple docstring''' UpperCamelCase__ = 0.00 UpperCamelCase__ = 0 for resistor in resistors: if resistor <= 0: ...
80
1
import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_comm...
371
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HAS...
116
0
from ..utils import DummyObject, requires_backends class lowerCAmelCase_ ( metaclass=a__ ): UpperCAmelCase__ : List[str] = ["onnx"] def __init__( self, *SCREAMING_SNAKE_CASE_, **SCREAMING_SNAKE_CASE_ ) -> List[Any]: requires_backends(self, ['o...
119
import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transformers.utils import loggi...
119
1
'''simple docstring''' import argparse import json from tqdm import tqdm def __lowercase ( ) -> str: '''simple docstring''' _A = argparse.ArgumentParser() # Required parameters parser.add_argument( "--src_path" , type=__lowercase ...
351
'''simple docstring''' def __lowercase ( __lowercase ) -> int: '''simple docstring''' if not isinstance(__lowercase , __lowercase ): raise ValueError("multiplicative_persistence() only accepts integral values" ) if num < 0: raise ValueError(...
174
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils impo...
107
"""simple docstring""" import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging _lowerCamelCase ...
167
0
from __future__ import annotations lowerCamelCase_ : Optional[Any] = list[tuple[int, int]] lowerCamelCase_ : int = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0,...
367
def lowerCAmelCase( __lowerCamelCase ): if not all(char in '01' for char in bin_string ): raise ValueError('Non-binary value was passed to the function' ) if not bin_string: raise ValueError('Empty string was passed to the function' ) __a = ...
197
0
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE ) -> list[int]: snake_case_ = [0 for i in range(len(_SCREAMING_SNAKE_CASE ) )] # initialize interval's left pointer and right pointer snake_case_ , snake_case_ = 0, 0 for i in range(1 , len(_SC...
347
"""simple docstring""" from ..utils import DummyObject, requires_backends class __A (metaclass=snake_case__): '''simple docstring''' __lowercase: List[Any] = ["""sentencepiece"""] def __init__( self : int , *UpperCAmelCase_ : Any ...
347
1
from torch import nn def lowerCamelCase_ ( _a : Optional[Any] ): '''simple docstring''' if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise Value...
354
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_format, ) fr...
59
0
"""simple docstring""" from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class _SCREAMING_SNAKE_CASE : def __lowerCAmelCase ( self , __A ) -> int: raise No...
84
def __UpperCamelCase ( _lowerCAmelCase = 100_0000 ) -> int: """simple docstring""" A : str = limit + 1 A : Tuple = [0] * limit for first_term in range(1 , _lowerCAmelCase ): for n in range(_lowerCAmelCase , _lowerCAmelCa...
116
0
"""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 =logging.get_logger(__name__) UpperCAmelCase ...
369
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE ) class lowerCamelCase__ ( SCREAMING_SNAKE_CASE ): ...
77
0
"""simple docstring""" import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline lowerCAmelCase__ = { '''n_samples''': 64, '''horizon''': 32, '''num_inference_steps''': 20, '''n_guide_steps''': 2, # can set to 0 for faster sampling, does ...
108
'''simple docstring''' from collections.abc import Generator def __magic_name__( ): __lowerCAmelCase , __lowerCAmelCase = 0, 1 while True: __lowerCAmelCase , __lowerCAmelCase = b, a + b yield b def __magic_name__( low...
174
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """transfo-xl-wt103""": """https://huggingface.co/transfo-xl-wt103/resolve/main/config.json""", } class _snake_case ...
366
from pathlib import Path import fire def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): lowercase__ = Path(SCREAMING_SNAKE_CASE_ ) lowercase__ = Path(SCREAMING_SNAKE_CASE_ ) dest_dir.mkdir(exist_ok=SCREAMING_SNAK...
224
0
from __future__ import annotations def _A ( SCREAMING_SNAKE_CASE__ : list[list[int]] ): 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(lowerCAmelCase__ ) ): ...
259
"""simple docstring""" from __future__ import annotations from collections.abc import Callable __lowerCAmelCase : str =list[list[float | int]] def UpperCAmelCase__ ( lowerCAmelCase__ :Matrix , lowerCAmelCase__ :Matrix ) -> Matrix: '''simple d...
197
0
from __future__ import annotations UpperCAmelCase_ = { 'A': ['B', 'C', 'E'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F', 'G'], 'D': ['B'], 'E': ['A', 'B', 'D'], 'F': ['C'], 'G': ['C'], } class lowercase__ : '''simple docstring''' de...
357
from __future__ import annotations import bisect def lowerCAmelCase_ ( __UpperCAmelCase: list[int] , __UpperCAmelCase: int , __UpperCAmelCase: int = 0 , __UpperCAmelCase: int = -1 ) -> int: if hi < 0: UpperCamelCase__ : ...
247
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase = {'''configuration_fnet''': ['''FNET_PRETRAINED_CONFIG_ARCHIVE_MAP''...
69
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 = {"""configuration_xglm""": ["""...
59
0
from __future__ import annotations def lowerCamelCase__ ( a__ : list , a__ : int ) -> Optional[Any]: # Checks if the entire collection has been sorted if len(a__ ) <= 1 or n <= 1: return insert_next(a__ , n - 1 ) rec_inserti...
261
from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('''To use the rich extension, install rich with `pip install rich`''')
261
1
"""simple docstring""" def _snake_case ( lowercase__ : dict ) -> set: '''simple docstring''' lowerCAmelCase_ :Any = set() # edges = list of graph's edges lowerCAmelCase_ :List[Any] = get_edges(lowercase__ ) # While there are st...
84
"""simple docstring""" import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, ...
77
0
def UpperCamelCase ( _a ) -> Any: '''simple docstring''' lowercase_ :str = [0] * len(_a ) lowercase_ :List[str] = [] lowercase_ :Dict = [1] * len(_a ) for values in graph.values(): for i in v...
252
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings("ignore", category=UserWarning, module="torch.optim.lr_scheduler") class UpperCamelCas...
252
1
'''simple docstring''' import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester ...
237
"""simple docstring""" from __future__ import annotations def UpperCamelCase_ ( lowerCAmelCase__ : list[int] , lowerCAmelCase__ : int ) -> bool: """simple docstring""" if len(lowerCAmelCase__ ) == 0: return False lowerCAme...
224
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=_lowerCamelCase ) class a ( _lowerCamelCase ): snake_case_ = field(default="image-classif...
366
'''simple docstring''' import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class ...
72
0
'''simple docstring''' from __future__ import annotations def snake_case_ ( _lowerCAmelCase : float , _lowerCAmelCase : float , _lowerCAmelCase : float ) -> dict[str, float]: if (voltage, current, resistance).count(0 ) != 1: ...
23
"""simple docstring""" from ...processing_utils import ProcessorMixin class UpperCAmelCase_ ( A_ ): lowercase__ = ['''image_processor''', '''feature_extractor'''] lowercase__ = '''TvltImageProcessor''' lowercase__ = '''TvltFeatureExtracto...
247
0
from __future__ import annotations import pandas as pd def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :list[int] , SCREAMING_SNAKE_CASE :list[int] , SCREAMING_SNAKE_CASE :int ) -> list[int]: __lowerCAmelCase : int = [0] * no_of_processes __lowerCAmelCase : ...
232
from math import isqrt def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int ) -> list[int]: __lowerCAmelCase : Tuple = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , SCREAMING_SNAKE_CASE , SCR...
232
1
"""simple docstring""" import unittest from transformers import AutoConfig, AutoTokenizer, BertConfig, TensorType, is_flax_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, slow if is_flax_available(): import jax from transformers.models.auto.modeling_flax_auto import...
261
"""simple docstring""" import random def _lowerCamelCase( a , a , a ): __a = a[left_index] __a = left_index + 1 for j in range(left_index + 1 , a ): if a[j] < pivot: __a , __a = a[i], a[j] ...
261
1
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging A_ : str = logging.get_logger(__name__) A_ : Optio...
364
"""simple docstring""" # Note: if you intend to run this script make sure you look under scripts/fsmt/ # to locate the appropriate script to do the work correctly. There is a set of scripts to: # - download and prepare data and run the conversion script # - perform eval to get the best hparam into the config # -...
316
0
# 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 be considered # since t...
252
def __lowerCamelCase ( lowerCamelCase__ : Any , lowerCamelCase__ : Optional[int] ): '''simple docstring''' return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def __lowerCamelCase ( lowerCamelCase__ : List[str] , lowerCamelCase__ ...
252
1
"""simple docstring""" from __future__ import annotations def UpperCamelCase_ ( lowerCAmelCase__ : list[int] , lowerCAmelCase__ : list[int] , lowerCAmelCase__ : list[int] , lowerCAmelCase__ : list[list[str]] , lowerCAmelCase__ ...
289
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ : List[Any] = logging.get_logger(__name__) lowercase__ : List[str] = { """s-JoL/Open-Llama-V1""": """https://huggingface.co/s-JoL/Open-Llam...
289
1
'''simple docstring''' import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def UpperCAmelCase_ ( *__lowerCamelCase : Optional[Any] ,__lowerCamelCase : Optional[Union[Dict, Any]] = None ,__lowerCamelCase : ...
223
"""simple docstring""" def snake_case_ ( A_ : list[list] ): '''simple docstring''' _lowerCamelCase : Optional[int] = current_set.copy() for row_index, row in enumerate(A_ ): _lowerCamelCase : Tuple = row[0] ...
72
0
"""simple docstring""" from __future__ import annotations def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase = None , _UpperCamelCase = None , _UpperCamelCase = False , ): __lowerCAmelCase : Union[str, Any] = cipher_alphabet or [chr(_UpperCamelCase ) for i in range(97 , ...
182
"""simple docstring""" # Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def __lowerCAmelCase (_UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): __lowerCAmelCase : str = { 'en': 'Machine learning is great, isn\'t it?', 'ru': 'Машинное об...
182
1
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) ...
232
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path lowercase : Optional[int] = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import dataclasses # ...
232
1
import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging _lowerCAmelCase : str = logging.get_logger(__name__) _lowerCAmelCase : List[str] = r"\n Args:\n input_ids (...
359
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : Any = logging.get_logger(__name__) _lowerCAmelCase : int = { "caidas/swin2sr-classicalsr-x2-64": ( "https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/...
308
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
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, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel...
359
"""simple docstring""" import math import unittest from transformers import BioGptConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_...
296
0
"""simple docstring""" def __UpperCAmelCase ( lowercase ,lowercase ,lowercase = 0 ,lowercase = 0 ): """simple docstring""" _UpperCAmelCase = right or len(lowercase ) - 1 if left > right: return -1 elif list_data[left] == key: return left elif list_da...
289
"""simple docstring""" import math class a : def lowerCAmelCase_ ( self : Tuple , __lowerCAmelCase : list[list[float]] , __lowerCAmelCase : list[int] ): _UpperCAmelCase = 0.0 _UpperCAmelCase = 0.0 for i in range(len(__lowerCAm...
289
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowerCamelCase = {'configuration_vit_mae': ['VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMAEConfig']} ...
370
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 DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils import logg...
177
0
import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : Opti...
182
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('''dataset_size''' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('''input_in_memory_max_size''' , ['''default''', 0, 100 * 2**20, 900 * 2**20] ) def A ( _low...
182
1
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_availabl...
84
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from transformers.file_utils ...
84
1
"""simple docstring""" import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append(""".""") def _snake_case ( lowercase__ ): _lowerCamelCase : T...
96
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase_ = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ], } tr...
308
0
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 _UpperCamelCase = '''src/diffusers''' # Matches is_xxx_available() _UpperCamelCase = re.compile(R'''is\_([a...
335
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowercase ( _UpperCamelCase , unittest.TestC...
335
1
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_availab...
23
from pathlib import Path import fire def __lowercase ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> List[str]: '''simple docstring''' SCREAMING_SNAKE_CASE = Path(_SCREAMING_SNAKE_CASE ) SCREAMING_SNAKE_CASE = ...
296
0
"""simple docstring""" __UpperCamelCase = '''0.18.2''' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, ...
312
"""simple docstring""" import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_i...
312
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : Any = { """configuration_git""": ["""GIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GitConfig""", """GitVisionConfig"""], """processing_git""": ["""G...
95
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> int: 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] lowercase__...
177
0
"""simple docstring""" from collections.abc import Callable class _A : """simple docstring""" def __init__( self : Union[str, Any] , __UpperCAmelCase : Callable | None = None): # Stores actual heap items. a : lis...
355
"""simple docstring""" import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def lowercase ( A_ , A_ , A_ , A_=5 )-> Union[str, Any]: '''simple docstring''' assert masked_input.count("<mask>" ) == 1 a ...
226
0
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( 'The `inpainting.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionInpaintPipeline` instead.' ) ...
84
"""simple docstring""" import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def _snake_case ( lowercase__ : Optional[int] ) -> Union[str, Any]: '''simple docstring''' lowerCAmelCase_ :List[Any] = ...
84
1
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.util...
356
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__A ) class snake_case_ ( __A ): # `task` is not a ClassVar since we want it to be part of the `asdict` output f...
333
0
"""simple docstring""" 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 SCREAMING_SNAKE_CASE_ : int = 'src/diffusers' # Matches is_xxx_available() SCREAMIN...
335
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : Dict ): # noqa: E741 A__ = len(UpperCAmelCase_ ) A__ = 0 A__ = [0] * n A__ = [False] * n A__ = [False] * n def dfs(UpperCAmelCase_ : ...
335
1
'''simple docstring''' import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp f...
358
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if i...
55
0
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging __a :Optional[int...
312
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 _a ( snake_case_ ): """simple doc...
312
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _UpperCAmelCase : List[str] = { """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoder...
366
'''simple docstring''' from ..utils import DummyObject, requires_backends class a__ ( metaclass=__A ): """simple docstring""" __UpperCamelCase : int = ['torch', 'scipy'] def __init__(self , *__lowercase , **__lowercase ): ...
9
0
import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def __SCREAMING_SNAKE_CASE ( UpperCamelCase__ , UpperCamelCase__=1 ) -> List[str]: '''simple docstring''' if n_shave_prefix_segments >= 0: return ".".join(pa...
273
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 accelerate import ...
226
0
from jiwer import compute_measures import datasets SCREAMING_SNAKE_CASE :Any = '\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER and WIL: improved evalu...
124
# Copyright 2021 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 # # Unless required by app...
124
1
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://huggingf...
244
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : Any = logging.get_logger(__name__) A_ : Optional[Any] = { 'google/pegasus-large': 'https://huggingface.co/google/pegasus-large/resolve/main/config.json', # See all PEGASUS models at https...
333
0
'''simple docstring''' import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn( 'The con...
136
'''simple docstring''' def __lowerCamelCase ( __snake_case : int ) -> bool: """simple docstring""" if p < 2: raise ValueError("""p should not be less than 2!""" ) elif p == 2: return True A__ : Any =4 A__ : ...
136
1
'''simple docstring''' 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__ : List[Any] =log...
70
'''simple docstring''' import os def __snake_case ( UpperCAmelCase_ : str = "matrix.txt" ): with open(os.path.join(os.path.dirname(UpperCAmelCase_ ) , UpperCAmelCase_ ) ) as in_file: lowerCamelCase_ = in_file.read() lowerCamelCase_ = [[int(UpperCAme...
55
0
"""simple docstring""" from __future__ import annotations def lowercase__( __SCREAMING_SNAKE_CASE : str ): return [ord(lowerCamelCase_ ) - 96 for elem in plain] def lowercase__( __SCREAMING_SNAKE_CASE : list[int] ): return "".join(chr(elem + 96 ) for el...
358
"""simple docstring""" class UpperCamelCase : def __init__( self ,__UpperCamelCase ) -> None: '''simple docstring''' lowercase_ : int = set_counts lowercase_ : List[Any] = max(__UpperCamelCase ) lower...
321
0
"""simple docstring""" import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ =...
241
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 _lowercase ( unittest.TestCase ): '''simple docstring''' def __magi...
9
0
'''simple docstring''' from __future__ import annotations from random import random from typing import Generic, TypeVar _lowerCamelCase = TypeVar("""KT""") _lowerCamelCase = TypeVar("""VT""") class _snake_case (Generic[KT, VT]): def __init__( self ,_sn...
67
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { """uw-madison/mra-base-512-4""": """https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.j...
67
1
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase : Union[str, Any] = logging.get_logger(__name__) l...
124
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __lo...
124
1
"""simple docstring""" from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase = { 'snap-research/efficientformer-l1-300': ( 'https://huggingface.co/...
357
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __UpperCamelCase = { '''configuration_mvp''': ['''MVP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MvpConfig''', '''MvpOnnxCon...
38
0