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
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline __UpperCAmelCase =logging.get_logger(__name__) # pylint: disable=invalid-name class lowerCAmelCase...
337
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase = { '''configuration_mask2former''': [ '''MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''M...
118
0
def __UpperCamelCase ( lowerCAmelCase__ : int = 1_0**9 ): __a : Any = 1 __a : List[Any] = 2 __a : List[str] = 0 __a : Optional[int] = 0 __a : Dict = 0 while perimeter <= max_perimeter...
326
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def __UpperCamelCase ( lowerCAmelCase__ ...
326
1
"""simple docstring""" import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def _snake_case ( snake_case__ : str , snake_case__ : Any , snake_case__ : Any )...
91
from __future__ import annotations import unittest from transformers import is_tf_available, is_torch_available from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, SMALL_MODEL_IDENTIFIER, is_pt_tf_cross_test, slow if is_tf_available(): from transformers import ( AutoConf...
416
0
import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": _lowerCamelCase = argparse.ArgumentParser( description=( """Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned""" """ Distilla...
718
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = """https://o...
447
0
'''simple docstring''' from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=a_ ) class lowerCAmelCase_ ( a_ ): __UpperCAmelCase = field(default='language-modeling' , ...
349
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : Optional[Any] = { """configuration_megatron_bert""": ["""MEGATRON_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MegatronBertConfig"""], } tr...
349
1
'''simple docstring''' import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
716
'''simple docstring''' import os import numpy import onnx def __A ( _SCREAMING_SNAKE_CASE : List[Any] , _SCREAMING_SNAKE_CASE : List[Any] ): """simple docstring""" __SCREAMING_SNAKE_CASE : int = a.nam...
564
0
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a = False class _A ( unittest.TestCase ): pas...
518
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) a = { "configuration_speecht5": [ "SPEECHT5_PRETRAINED_CONFIG_ARCHIVE_MAP", "SPEECHT5_PRETRAINE...
518
1
def lowercase ( _a ) -> int: return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def lowercase ( _a ) -> bool: UpperCAmelCase_: Any = 0 UpperCAmelCase_: List[str] = number while duplicate > 0: UpperCAmelCase_: List[Any] =...
704
from __future__ import annotations _lowerCAmelCase = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _lowerCAmelCase = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def lowercase ( _a ) -> list[float]: UpperCAmelCase_: Dict = [] U...
306
0
'''simple docstring''' import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotConfig, is_flax_available from transformers.testing_utils import jax_device, require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_mo...
3
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _lowerCAmelCase ( lowercase_ ): """simple do...
654
0
"""simple docstring""" def lowercase_ ( _lowerCamelCase: int ) -> int: '''simple docstring''' __lowerCamelCase : Any = abs(_lowerCamelCase ) __lowerCamelCase : List[str] = 0 while n > 0: res += n % 10 n //= ...
366
"""simple docstring""" import gc import threading import time import psutil import torch class _snake_case : def __init__( self : str ): __lowerCamelCase : Optional[Any] = psutil.Process() __lowerCamelCase : List[Any] = False ...
366
1
'''simple docstring''' import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import fl...
209
"""simple docstring""" from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAtte...
153
0
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline 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_GUID...
716
from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowerCAmelCase : _SCREAMING_SNAKE_CASE : torch.Tensor # [batch_size x 3] _SCREAMING_SNAKE_CASE : torch.Tensor # [batch_size x 3] _SCREAMING_SNAKE_CAS...
476
0
import gc import threading import time import psutil import torch class A_ : def __init__( self ): '''simple docstring''' UpperCAmelCase = psutil.Process() UpperCAmelCase = False def _lowercase ( self ): '''simpl...
130
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProcessing ...
130
1
'''simple docstring''' from typing import List, Optional, Union import numpy as np import PIL.Image from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ...
706
'''simple docstring''' # Copyright 2021 The HuggingFace 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-...
695
0
import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerat...
257
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class UpperCamelCase ( lowercase__ ): '''simple do...
257
1
"""simple docstring""" 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...
545
"""simple docstring""" import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING UpperCAmelCas...
545
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) A = { '''configuration_layoutlmv2''': ['''LAYOUTLMV2_PRE...
52
"""simple docstring""" import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCAmelCase__ ...
616
0
"""simple docstring""" import math import qiskit def UpperCAmelCase ( snake_case : int = 1 , snake_case : int = 1 , snake_case : int = 1 ): if ( isinstance(snake_case , snake_case ) or isinstance(snake_case , ...
439
"""simple docstring""" from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils i...
439
1
"""simple docstring""" import argparse import os import re __lowerCAmelCase : Any = '''src/diffusers''' # Pattern that looks at the indentation in a line. __lowerCAmelCase : Any = re.compile(R'''^(\s*)\S''') # Pattern that matches `"ke...
58
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorState, PartialState ...
587
0
'''simple docstring''' from manim import * class __SCREAMING_SNAKE_CASE (lowerCamelCase_ ): """simple docstring""" def UpperCamelCase__ ( self : str ): _a = Rectangle(height=0.5 , width=0.5 ) _a ...
521
'''simple docstring''' lowerCAmelCase_ : Optional[Any] = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def _lowerCamelCase ( lowercase : Union[str, Any] , ...
521
1
'''simple docstring''' import logging import os from .state import PartialState class __lowerCAmelCase ( logging.LoggerAdapter ): """simple docstring""" @staticmethod def snake_case__ ( lowerCAmelCase__ : Tuple ) -> List[Any]: '''simp...
98
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: int , lowerCAmelCase: int ) -> Dict: if b == 0: return 1 if (b % 2) == 0: return actual_power(lowerCAmelCase , int(b / 2 ) ) * actual_power(lowerCAmelCase , int(b / 2 ) ) else: return a * actual_power(low...
300
0
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _lowercase ( __a ): """simple docstring""" lowercase__ = ['''image_processor''', '''tokenizer'''] lowercase__ ...
700
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { '''YituTech/c...
296
0
import argparse import math import traceback import dateutil.parser as date_parser import requests def __lowerCAmelCase ( A ): UpperCAmelCase_ = {} UpperCAmelCase_ = job["started_at"] UpperCAmelCase_ = job["completed_at"] UpperCAmelCase_ ...
162
def __lowerCAmelCase ( A , A , A , A ): # Return True if there is node that has not iterated. UpperCAmelCase_ = [False] * len(A ) UpperCAmelCase_ = [] queue.append(A ) UpperCAmelCase_ = True while queue: UpperCAmelCase_ ...
162
1
"""simple docstring""" def __lowercase ( lowerCamelCase_ : int = 1000000 ): SCREAMING_SNAKE_CASE__ = limit + 1 SCREAMING_SNAKE_CASE__ = [0] * limit for first_term in range(1 , lowerCamelCase_ ): for n in range(lowerCamelCase_ , ...
112
"""simple docstring""" from __future__ import annotations def __lowercase ( lowerCamelCase_ : list , lowerCamelCase_ : int , lowerCamelCase_ : int , lowerCamelCase_ : int ): SCREAMING_SNAKE_CASE__ = [] SCREAMING_SNAKE_CASE__ ...
112
1
'''simple docstring''' import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_tr...
526
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor i...
526
1
"""simple docstring""" 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 _A ( _UpperCAmelCase ): """simple docstr...
702
"""simple docstring""" import re def SCREAMING_SNAKE_CASE ( snake_case): return [char.split() for char in re.split(R'''[^ a-z A-Z 0-9 \s]''', str_)] def SCREAMING_SNAKE_CASE ( snake_case): __snake_case = split_input(str_) return "".j...
93
0
from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder UpperCAmelCase = datasets.utils.logging.get_logger(__name__) class snake_case__ ( folder_based_builder.FolderBasedBuilderConf...
666
from ...configuration_utils import PretrainedConfig UpperCAmelCase = { "google/tapas-base-finetuned-sqa": ( "https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json" ), "google/tapas-base-finetuned-wtq": ( "https://huggingface.co/google/tapas...
666
1
import unittest from datasets import load_dataset from transformers.pipelines import pipeline from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow @is_pipeline_test @require_torch class lowerCamelCase ( unittest.TestCase ): @require_torch def snake...
714
from manim import * class lowerCamelCase ( SCREAMING_SNAKE_CASE ): def snake_case_ ( self : int ) -> Tuple: _a : Optional[int] = Rectangle(height=0.5 , width=0.5 ) _a : Dict = Rectangle(height=0.25 , width=0...
249
0
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, ...
76
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : list[int] , _SCREAMING_SNAKE_CASE : list[int] ) -> tuple[float, float]: """simple docstring""" if not len(_SCREAMING_SNAKE_CASE ) == len(_SCREAMING_SNAKE_CASE ) == 3: raise ValueError("Please...
71
0
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def __lowerCamelCase ( _...
715
'''simple docstring''' import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def __lowerCamelCase ( __snake_case : i...
687
0
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class __a ( SCREAMING_SNAKE_CASE ): @require_torch def UpperCamelCase ( self : List[str])-> Union[str, Any]...
354
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging lowercase_ = logging.get_logger(__name__) ...
354
1
'''simple docstring''' import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class __a ( _snake_case ): ...
13
'''simple docstring''' import os import string import sys a = 1 << 8 a = { "tab": ord("\t"), "newline": ord("\r"), "esc": 27, "up": 65 + ARROW_KEY_FLAG, "down": 66 + ARROW_KEY_FLAG, "right": 67 + ARROW_KEY_FLAG, "left": 68 + ARROW_KEY_FLAG, "mod_int": 91...
13
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Union[str, Any] = { '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/...
452
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Tuple = logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Union[str, Any] = { '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/...
452
1
'''simple docstring''' def _a ( __lowerCAmelCase : int , __lowerCAmelCase : int ): """simple docstring""" return abs(__lowerCAmelCase ) if a == 0 else greatest_common_divisor(b % a , __lowerCAmelCase ) def _a ( __lowerCAmelCase : int , ...
502
'''simple docstring''' from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fa...
502
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline...
250
"""simple docstring""" from typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class _lowerCamelCase ( a_ ): def __init__( self : Optio...
299
0
'''simple docstring''' import argparse import os import subprocess from packaging.version import Version, parse from accelerate.commands.config.config_args import default_config_file, load_config_from_file __A : Dict = 'Run commands across TPU VMs for initial setup before running `accelerate ...
703
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, pre...
126
0
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TFCamembertModel ...
31
"""simple docstring""" import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _A = logging.get_logger(__name__) class _lowerCamelCase ( a_ ): def __init__( self : str , *UpperCamelCase : int , **Upper...
299
0
'''simple docstring''' class UpperCAmelCase_ : """simple docstring""" def __init__( self : List[Any] , UpperCAmelCase : list ) -> None: '''simple docstring''' lowercase : Union[str, Any] =set_counts lowercase : Any =max(Up...
8
'''simple docstring''' import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC SCREAMING_SNAKE_CASE = parse(importlib.metadata.version('torch')) def lowercase_ ( __A : Union[str, Version] , ...
8
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 UpperCAmelCase =logging.get_logger...
617
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging __a: Optional[int] = logging.get_logger(__name__) __a: Any = { """t5-small""": """https://huggingface.co/t5-small/re...
152
0
'''simple docstring''' import math from numpy import inf from scipy.integrate import quad def UpperCAmelCase_ ( lowercase__ ): '''simple docstring''' if num <= 0: raise ValueError("math domain error" ) return quad(lowerca...
41
'''simple docstring''' from __future__ import annotations def UpperCAmelCase_ ( lowercase__ ): '''simple docstring''' a_ =str(lowercase__ ) return len(lowercase__ ) == 9 and set(lowercase__ ) == set("123456789" )...
41
1
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokeni...
17
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets lowercase_ : Tuple = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classif...
572
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
713
import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import classes from unilm.w...
458
0
"""simple docstring""" import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput lowerCAmelCase__ ="scheduler_config.json" class A__( __magic_name__ ): lowerCAmel...
482
"""simple docstring""" def _a ( UpperCAmelCase__ ) -> int: if not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ) or number < 0: raise ValueError('''Input must be a non-negative integer''' ) __SCREAMING_SNAKE_CASE = 0 while number: ...
482
1
'''simple docstring''' class a : def __init__( self , __magic_name__ , __magic_name__ , __magic_name__ ) -> Optional[Any]: _a = None _a = None _a = graph self._normalize_graph(__magic...
532
'''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/...
532
1
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { """funnel-transformer/small""": """https://huggingface.co/funnel-transformer/small/resolve/main/config.json"""...
99
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Optional[Any] = { """configuration_swinv2""": ["""SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Swinv2Config"""], } try: if not ...
328
0
lowercase_ = [ '''Audio''', '''Array2D''', '''Array3D''', '''Array4D''', '''Array5D''', '''ClassLabel''', '''Features''', '''Sequence''', '''Value''', '''Image''', '''Translation''', '''TranslationVariableLanguages''', ] from .audio import Au...
336
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def lowerCAmelCase ( UpperCAmelCase, UpperCAmelCase, UpperCAmelCase, UpperCAmelCase, UpperCAmelCase = None, UpperCAmel...
336
1
import random from .binary_exp_mod import bin_exp_mod def a__ ( lowercase__ , lowercase__=1_0_0_0 ): '''simple docstring''' if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd UpperCAmelCase_ ...
54
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ : str = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_...
578
0
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, nest...
193
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'microsoft/wavlm-base': 'https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json', # See all WavLM models at htt...
193
1
import argparse import collections import os import re 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 utils/check_table.py snake_case__ : str = 'src/transformers' snake_c...
278
from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class __A( a ): def __lt__( self , _snake_case ) -> Dict: '''simple docstring''' return self[-1] < other[-1]...
219
0
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def __A...
156
'''simple docstring''' import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel lowerCAmelCase_ : List[Any] = { '''text_branch''': '''text_model''', '''audio_branch''': '''audio_model.audio_encode...
156
1
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def _A ( _lowercase ) -> Tuple: """simple docstring""" monkeypatch.setattr('datasets.utils.deprecation_utils._emitted_deprecation_warnings' , set() ) @pytest....
1
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline _lowerCAmelCase = logging.get_logger(__name__) # pylint: disable=invalid-name ...
259
0
'''simple docstring''' def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : int ,lowerCAmelCase_ : list[int] ,lowerCAmelCase_ : int ) -> int: """simple docstring""" def count_of_possible_combinations(lowerCAmelCase_ : int ) -> int...
720
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : int ) -> str: ""...
153
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : List[Any] = logging.get_logger(__name__) UpperCAmelCase_ : Dict = { 'funnel-transformer/small': 'https://huggingface.co/funnel-transformer/small/resolve/main/co...
44
'''simple docstring''' class UpperCAmelCase__ : def __init__( self : Any,__A : Any,__A : Any,__A : Any ): _lowerCamelCase : List[Any] = name _lowerCamelCase : Union[str, Any] = value _lowerCamelCase : str ...
44
1
'''simple docstring''' import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness _snake_case = '\\n@misc{chen2021evaluating,\...
704
'''simple docstring''' import math import unittest def snake_case_ (UpperCamelCase : int ): '''simple docstring''' assert isinstance(UpperCamelCase , UpperCamelCase ) and ( number >= 0 ), "'number' must been an int and positive" ...
377
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : List[str] = logging.get_logger(__name__) __UpperCamelCase : str = {'ctrl': 'https://huggingface.co/ctrl/resolve/main/config.json'} class lowercase__ ( UpperCamelCase_): ...
248
"""simple docstring""" 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 Model...
506
0
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def _lowercase ( UpperCAmelCase_): """simple docstring""" return getitem, k def _lowercase ( UpperCAmelCase_ , UpperCAmelCase_): """simple docs...
705
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def _lowercase ( UpperCAmelCase_): """simple docstring""" if "img_encoder.pos_embed" in name: snake_case__ : Dict = ...
127
0
"""simple docstring""" import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mas...
355
'''simple docstring''' import requests def lowerCAmelCase_ ( snake_case_ : str , snake_case_ : str ) -> None: '''simple docstring''' UpperCAmelCase_ = {"Content-Type": "application/json"} UpperCAmelCase_ = requests.post(snake...
78
0
'''simple docstring''' import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils ...
718
'''simple docstring''' from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTe...
145
0
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature ...
262
import collections import inspect import unittest from transformers import SwinvaConfig 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 Confi...
68
0
"""simple docstring""" import argparse import struct import unittest class lowercase__ : '''simple docstring''' def __init__( self : Tuple , _UpperCAmelCase : bytes ) -> None: '''simple docstring''' ...
14
"""simple docstring""" 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, ...
14
1
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": __lowerCAmelCase = input('Enter image url: ').strip() print(F'''Downloading image from {url} ...''') __lowerCAmelCase = BeautifulSoup(requests.get(url).content, 'html....
201
import os def a ( a = "matrix.txt" ) ->int: '''simple docstring''' with open(os.path.join(os.path.dirname(a ) , a ) ) as in_file: SCREAMING_SNAKE_CASE = in_file.read() SCREAMING_SNAKE_CASE = [[int(a ) for cell in row.split(''',''' )] for row in data.strip()...
201
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase : Any = { '''configuration_autoformer''': [ '''AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''AutoformerC...
77
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import load_numpy, ...
77
1
'''simple docstring''' from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def SCREAMING_SNAKE_CASE ( lowerCAmelCase__ : List[Any] , lowerCAmelCase__ : int) -> ...
125
'''simple docstring''' import math A = 10 A = 7 A = BALLS_PER_COLOUR * NUM_COLOURS def SCREAMING_SNAKE_CASE ( lowerCAmelCase__ : int = 20) -> str: '''simple docstring''' _lowercase : Union[str, Any] = math.comb(lowerCAmel...
125
1
"""simple docstring""" def _snake_case ( snake_case__ : list[list[int]] , snake_case__ : int , snake_case__ : int , snake_case__ : set ): A , A = len(snake_case__ ), len(grid[0] ) if ( min(snake_case__ , snake_case__ ) < 0 ...
721
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) _lowercase = { '''configuration_clip''': [...
22
0
'''simple docstring''' def lowerCamelCase ( __lowerCamelCase : str , __lowerCamelCase : str ) ->str: if not (isinstance(__lowerCamelCase , __lowerCamelCase ) and isinstance(__lowerCamelCase , __lowerCamelCase )): raise ValueError("""longest_common_...
314
'''simple docstring''' from __future__ import annotations import os from collections.abc import Mapping lowercase_ = tuple[int, int] class a_ : '''simple docstring''' def __init__( self , A , A ) -> None: _SCREAMING_SNAKE_CASE = ...
314
1
'''simple docstring''' 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_configu...
35
'''simple docstring''' from __future__ import annotations def lowercase__ ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase )-> tuple[float, list[float]]: UpperCamelCase = list(range(len(__UpperCamelCase ) ) ) UpperCame...
35
1
'''simple docstring''' def lowerCAmelCase_ ( a : list , a : int , a : int = 0 , a : int = 0 ): a__ = right or len(a ) - 1 if left > right: return -1 elif list_data[left] == key: return left ...
394
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Any = logging.get_logger(__name__) __A : Union[str, Any] = { 'tanreinama/GPTSAN-2.8B-spout_is_uniform': ( 'https://huggingface.co/tanreinama/GPTSAN-2....
394
1
import re from filelock import FileLock try: import nltk __A = True except (ImportError, ModuleNotFoundError): __A = False if NLTK_AVAILABLE: with FileLock('''.lock''') as lock: nltk.download('''punkt''', quiet=True) def _S...
710
'''simple docstring''' from functools import lru_cache @lru_cache def _SCREAMING_SNAKE_CASE ( A : int ) -> int: """simple docstring""" if num < 0: raise ValueError('Number should not be negative.' ) return 1 if num in (0, 1) ...
61
0
import csv import tweepy # Twitter API credentials SCREAMING_SNAKE_CASE__ = '''''' SCREAMING_SNAKE_CASE__ = '''''' SCREAMING_SNAKE_CASE__ = '''''' SCREAMING_SNAKE_CASE__ = '''''' def A ( __UpperCamelCase ) -> None: # authorize twitter, initialize tweepy A__ ...
9
SCREAMING_SNAKE_CASE__ = { '''A''': ['''B''', '''C''', '''E'''], '''B''': ['''A''', '''D''', '''E'''], '''C''': ['''A''', '''F''', '''G'''], '''D''': ['''B'''], '''E''': ['''A''', '''B''', '''D'''], '''F''': ['''C'''], '''G''': ['''C'''], } def A ( __UpperCamelCase , ...
9
1
def SCREAMING_SNAKE_CASE__ ( __A=28_123 ) -> Optional[Any]: _snake_case = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1 ): sum_divs[k * i] += k + i _snake_case = set() _snake_case...
712
'''simple docstring''' import torch from transformers import CamembertForMaskedLM, CamembertTokenizer def SCREAMING_SNAKE_CASE__ ( __A , __A , __A , __A=5 ) -> Dict: # Adapted from https://github.com/pytorch/fairseq/blob/master/fairseq/models/roberta/hub_inte...
542
0
lowerCamelCase ="\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" lowerCamelCase =[{"type": "code", "content": I...
285
from typing import Any def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , ): _validation( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , ) ...
285
1
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable UpperCamelCase__ : Union[str, Any] = {'''configuration_dpt''': ['''DPT_PRETRAINE...
701
'''simple docstring''' import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class _UpperCamelCase ( low...
178
0
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowerCAmelCase_ (lowercase__ : s...
668
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Optional[int] = logging.get_logger(__name__) _UpperCAmelCase : str = { "vocab_file": "vocab.json"...
668
1
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 @s...
698
__A : dict[str, float] = { "joule": 1.0, "kilojoule": 1_0_0_0, "megajoule": 1_0_0_0_0_0_0, "gigajoule": 1_0_0_0_0_0_0_0_0_0, "wattsecond": 1.0, "watthour": 3_6_0_0, "kilowatthour": 3_6_0_0_0_0_0, "newtonmeter": 1.0, "calorie_nutr": 4_1_8_6.8, "kilocalorie_nutr":...
698
1
from sklearn.metrics import mean_squared_error import datasets lowerCamelCase_ = """\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n and Thirion, B. and Grisel, O. and Blondel, M...
318
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging __magic_name__ = logging...
155
0
import colorsys from PIL import Image # type: ignore def a__ ( lowercase__ , lowercase__ , lowercase__ ): '''simple docstring''' UpperCAmelCase_ : List[Any] =x UpperCAmelCase_ : List[Any] =y for step in ran...
700
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar __lowercase : Optional[int] =TypeVar("""T""") def a__ ( lowercase__ ): '''simple docstring''' return (position - 1) // 2 def a__ ...
550
0
'''simple docstring''' def a ( __a , __a ) -> str: '''simple docstring''' if not (isinstance(__a , __a ) and isinstance(__a , __a )): raise ValueError('''longest_common_substring() takes two strings for inputs''' ) UpperCamelCase__ :str ...
189
'''simple docstring''' from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, S...
189
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision from transformers.utils im...
708
from itertools import count def UpperCamelCase( lowercase_ = 50 ) -> int: '''simple docstring''' snake_case_ = [1] * min_block_length for n in count(lowercase_ ): fill_count_functions.append(1 ) for block_length in range(lowercase_ , n + 1 ...
161
0
from __future__ import annotations def __UpperCamelCase ( A ): UpperCamelCase__ = 0.00 UpperCamelCase__ = 0 for resistor in resistors: if resistor <= 0: UpperCamelCase__ = f"Resistor at index {index} has a negative or...
415
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
415
1
'''simple docstring''' 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, ...
398
'''simple docstring''' from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging __A : str = logging.get_logger(__name__) __A : str = { "huggingface/autoformer-tourism-monthly":...
398
1
'''simple docstring''' import os from tempfile import TemporaryDirectory from unittest import TestCase import pytest from absl.testing import parameterized from datasets import config from datasets.arrow_reader import HF_GCP_BASE_URL from datasets.builder import DatasetBuilder from datasets.dataset_dict import ...
107
'''simple docstring''' import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase_ (snake_case__ ): '''simple docstring''' __UpperCamelCase: Union[str, Any] = (DDPMScheduler,) def _A ( self : ...
244
0
import string def UpperCamelCase ( _A : str )-> None: """simple docstring""" for key in range(len(string.ascii_uppercase ) ): A__ = "" for symbol in message: if symbol in string.ascii_uppercase: ...
711
import importlib import inspect 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_config_docstrings.py UpperCAmelCase_ : Optional[Any] = "src/transformers" # This is to make sure the transform...
232
0
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 ...tes...
485
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE = logging.get_logger(__name__) SCREAMING_SNAKE_CASE = { 'junnyu/roformer_...
485
1
'''simple docstring''' def A_ ( _lowerCAmelCase : str , _lowerCAmelCase : int ): """simple docstring""" _lowerCamelCase : list[list[str]] = [[] for _ in range(snake_case_ )] _lowerCamelCase : Optional[int] = key - 1 if k...
702
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import H...
11
0
"""simple docstring""" from collections.abc import Callable def lowercase (_lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): __lowerCAmelCase = a __lowerCAmelCase = b if function(__lowerCAmelCase ) == 0: # one of the a or b is a root for the function ...
465
def _lowerCAmelCase ( __lowerCAmelCase = 200 ) -> int: """simple docstring""" snake_case__ : Optional[int] = [1, 2, 5, 10, 20, 50, 100, 200] snake_case__ : List[Any] = [0] * (pence + 1) snake_case__ : str = 1 # base case: 1 w...
252
0
"""simple docstring""" import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("dataset_size" , [None, 4_00 * 2**20, 6_00 * 2**20] ) @pytest.mark.parametrize("input_in_memory_max_size" , ["default", 0, 1_00 * 2**20, 9_00 * 2*...
292
"""simple docstring""" snake_case_ : str = [ """DownloadConfig""", """DownloadManager""", """DownloadMode""", """StreamingDownloadManager""", ] from .download_config import DownloadConfig from .download_manager import DownloadManager, DownloadMode from .streaming_download_manag...
292
1
'''simple docstring''' from __future__ import annotations def _SCREAMING_SNAKE_CASE (A ) -> list[int]: """simple docstring""" lowercase__ = 2 lowercase__ = [] while i * i <= n: if n % i: i += 1 else: ...
460
'''simple docstring''' from __future__ import annotations lowerCamelCase : List[str] = [] def _SCREAMING_SNAKE_CASE (A , A , A ) -> bool: """simple docstring""" for i in range(len(A ) ): if board[row][i] == 1: retu...
460
1
# Copyright 2023 The HuggingFace 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 applica...
714
from importlib import import_module from .logging import get_logger _SCREAMING_SNAKE_CASE : Optional[int] = get_logger(__name__) class UpperCAmelCase__ : """simple docstring""" def __init__( self : Optional[int] , __lowerCamelCase : Optional[Any] , __lowerCam...
472
0
'''simple docstring''' from collections.abc import Sequence from queue import Queue class a__ : def __init__( self , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase=None , _UpperCamelCase=None ): """simple docstring"...
245
'''simple docstring''' import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() _snake_case = logging.get_logger(__name__) def _A ( snake_case ) -> str: _lowercase ...
245
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { "facebook/data2vec-vision-base-ft": ( ...
704
def _SCREAMING_SNAKE_CASE ( __lowercase : str = "The quick brown fox jumps over the lazy dog" , ) -> bool: """simple docstring""" __A = set() # Replace all the whitespace in our sentence __A = input_str.replace(""" """ , """""" ) for a...
199
0
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __a = logging.getLogger(__name__) __a ...
30
from functools import reduce __a = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '12540698747158523863050715693290963295227443043557' '66896648950445244523161731856...
30
1
from abc import ABC, abstractmethod from argparse import ArgumentParser class lowercase__ ( UpperCamelCase_): @staticmethod @abstractmethod def __A ( UpperCamelCase__ : ArgumentParser ): '''simple docstring''' raise ...
34
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 ( IMAGENET...
34
1
"""simple docstring""" from collections import defaultdict def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase ) -> bool: '''simple docstring''' _lowerCamelCase : str = first_str.lower().strip() _lowerCamelCase : Any = second_str.low...
46
from graphs.minimum_spanning_tree_kruskal import kruskal def lowerCamelCase_ ( ): '''simple docstring''' UpperCamelCase__ = 9 UpperCamelCase__ = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], ...
240
0
from __future__ import annotations def a ( A__ : list[list[int]] ) -> int: """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 , l...
380
import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, DPR_CO...
380
1
'''simple docstring''' import numpy class SCREAMING_SNAKE_CASE__ : def __init__( self : Any , a_ : numpy.ndarray , a_ : numpy.ndarray ): """simple docstring""" __snake_case = input_array # Random ...
69
def __lowerCamelCase ( _lowerCAmelCase ) -> list: _UpperCAmelCase = len(_lowerCAmelCase ) for i in range(1 , _lowerCAmelCase ): _UpperCAmelCase = collection[i] _UpperCAmelCase = 0 _UpperCAmelCase = i - 1 while l...
684
0
from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWithNoAttention, TFBaseModelOut...
379
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, inf...
379
1
'''simple docstring''' from __future__ import annotations from random import choice def __magic_name__ ( __UpperCAmelCase ) -> Union[str, Any]: '''simple docstring''' return choice(__UpperCAmelCase ) def __magic_name__ ( __UpperCAmelCase , __UpperCA...
109
'''simple docstring''' from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class __a ( _snak...
109
1
'''simple docstring''' import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) ...
713
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_torch_available from ...utils import OptionalDependencyNotAvailable _UpperCAmelCase : str = { """configuration_gpt_neox_japanese""": ["""GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MA...
474
0
'''simple docstring''' import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets UpperCamelCase__: Dict = "\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machi...
127
'''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 UpperCamelCase__: str = logging.get_lo...
127
1
"""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 ( BnbQuantizati...
712
"""simple docstring""" def UpperCamelCase ( _A , _A ) -> str: lowercase : list[list[str]] = [[] for _ in range(_A )] lowercase : Any = key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""" ) i...
348
0