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, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __lowercase ( _UpperCAmelCase)...
480
"""simple docstring""" a_ = 256 # Modulus to hash a string a_ = 1000003 def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE__ : str , SCREAMING_SNAKE_CASE__ : str ): """simple docstring""" snake_case_ : str = len(SCREAMING...
480
1
'''simple docstring''' import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import rep...
289
'''simple docstring''' import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common ...
289
1
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor im...
654
a__ = [0, 2, 4, 6, 8] a__ = [1, 3, 5, 7, 9] def _UpperCAmelCase ( a : int , a : int , a : list[int] , a : int ): if remaining_length == 0: if digits[0] == 0 or digits[-1] == 0: return 0 for i ...
654
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 applicab...
715
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class SCREAMING_SNAKE_CASE_ (pl.LightningModule ): '''simple docstring''' def __init__( self : Any , __a ...
171
0
import warnings from ..trainer import Trainer from ..utils import logging UpperCAmelCase__ = logging.get_logger(__name__) class a ( __SCREAMING_SNAKE_CASE ): """simple docstring""" def __init__( self : List[str] , lowerCamelCase__ : Tuple=None , **lowerCamelC...
332
from ..utils import DummyObject, requires_backends class a ( metaclass=__SCREAMING_SNAKE_CASE ): """simple docstring""" UpperCamelCase_ : Optional[int] = ['note_seq'] def __init__( self : Dict , *lowerCamelCase__ : int , **lowerCamelC...
332
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = {} class __lowercase ( a__ ): _lowerCAmelCase = "llama" _lowerCAmelCase = ["past_key_va...
143
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_...
143
1
"""simple docstring""" def lowercase ( UpperCamelCase : int = 1000000 ): """simple docstring""" A__ : Optional[Any] =set(range(3 , UpperCamelCase , 2 ) ) primes.add(2 ) for p in range(3 , UpperCamelCase , 2 ): if p no...
656
"""simple docstring""" def lowercase ( UpperCamelCase : int ): """simple docstring""" if num <= 0: raise ValueError("Input must be a positive integer" ) A__ : Union[str, Any] =[True] * (num + 1) A__ : Union[str, Any] =2 while p *...
656
1
'''simple docstring''' from __future__ import annotations def _A ( A ,A ,A ,) -> tuple: if (electron_conc, hole_conc, intrinsic_conc).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 values" ) elif electron_conc < 0: raise ValueError(...
425
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...mode...
425
1
'''simple docstring''' from queue import PriorityQueue from typing import Any import numpy as np def lowerCamelCase ( lowerCamelCase : dict , lowerCamelCase : str , lowerCamelCase : set , lowerCamelCase : set , lowerCamelCase : dict , lowerCamelCase : dict ...
665
from __future__ import annotations def SCREAMING_SNAKE_CASE_ ( lowerCAmelCase_: list[int | float] , lowerCAmelCase_: int , lowerCAmelCase_: int ): if len(lowerCAmelCase_ ) == 0: raise ValueError("find_max() arg is an empty sequence" ) if ( ...
666
0
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, re...
171
import fire from utils import calculate_rouge, save_json def __lowerCamelCase ( A__ : Union[str, Any] , A__ : Optional[int] , A__ : Dict=None , **A__ : Dict ) -> str: lowerCamelCase_ : Union[str, Any] = [x.strip() for x in open(A__ ).readlines()] lowerCamelCase_ : ...
171
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available a_ = {'tokenization_herbert': ['HerbertTokenizer']} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable(...
296
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_ima...
296
1
"""simple docstring""" import logging import os import threading import time try: import warnings except ImportError: A__ : List[str]= None try: import msvcrt except ImportError: A__ : Dict= None try: import fcntl except ImportError: A__ : Dict= No...
20
"""simple docstring""" # Copyright 2022 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...
20
1
import random from .binary_exp_mod import bin_exp_mod def __a ( __UpperCAmelCase , __UpperCAmelCase=1000 ): if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd a__ = n - 1 a__ = 0 while d % 2 == 0: d /= 2 exp += 1 # n - 1=d*(...
194
import inspect import unittest class lowerCAmelCase ( unittest.TestCase ): def UpperCAmelCase ( self :int ): '''simple docstring''' try: import diffusers # noqa: F401 except ImportError: assert False def UpperCAmelCase ( ...
655
0
def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: int ): '''simple docstring''' lowercase_ = [[0 for _ in range(__lowerCamelCase )] for _ in range(m + 1 )] for i in range(m + 1 ): lowercase_ = 1 for n in range(m + 1 ): for k in range(1 , __lowerCamelCase ...
601
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE_ ( __lowerCamelCase: Optional[int] , __lowerCamelCase...
601
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase = logging.get_logger(__name__) lowercase = { '''facebook/s2t-small-librispeech-asr''': ( '''https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json''' ), # See all...
272
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) lowercase = { '''configuration_layoutlmv2''': ['''LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LayoutLMv2...
272
1
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets UpperCamelCase = """\ @inproceedings{popovic-2015-chrf, title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\", author = \"Popovi{\'c}, Maja\", b...
120
"""simple docstring""" 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_I...
120
1
"""simple docstring""" import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('9.1.0'): __snake_case = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilinear': PIL.Image.Res...
200
"""simple docstring""" import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def _lowerCamelCase ( lowerCamelCase__ : List[Any] , lowerCamelCase__ : str , lowerCamelCase__ : ...
200
1
import os import string import sys __UpperCamelCase : Optional[Any] = 1 << 8 __UpperCamelCase : Any = { 'tab': ord('\t'), 'newline': ord('\r'), 'esc': 27, 'up': 65 + ARROW_KEY_FLAG, 'down': 66 + ARROW_KEY_FLAG, 'right': 67 + ARROW_KEY...
641
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) class lowerCAmelCase__( snake_case__ ): '''simple docstring''' A_ : Union[str, ...
641
1
"""simple docstring""" from __future__ import annotations from typing import Any class a_ : def __init__( self : Union[str, Any] , snake_case__ : int ): lowerCAmelCase__ = num_of_nodes lowerCAmelCase__ = [] lowerCAmelCase__ = {} def _SCREAMING...
644
"""simple docstring""" import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets __lowerCAmelCase : Optional[Any] = "\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Translation ...
644
1
"""simple docstring""" import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig A: int = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ : def __init...
713
"""simple docstring""" import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer A: List[An...
359
0
def _snake_case (__lowercase): UpperCamelCase_ = 1 for i in range(1 , num + 1): fact *= i return fact def _snake_case (__lowercase): UpperCamelCase_ = 0 while number > 0: UpperCamelCase_ = number % 10 sum_of_di...
23
'''simple docstring''' import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import Generation...
603
0
"""simple docstring""" import math def lowerCamelCase_ ( _lowerCamelCase ): if not isinstance(_lowerCamelCase , _lowerCamelCase ): lowerCamelCase__ : List[Any] = f'''Input value of [number={number}] must be an integer''' raise TypeError(_lowerCamelCase ) ...
708
"""simple docstring""" import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate ...
696
0
from ..utils import DummyObject, requires_backends class lowerCamelCase_ ( metaclass=_SCREAMING_SNAKE_CASE ): '''simple docstring''' lowercase_ = ["transformers", "torch", "note_seq"] def __init__( self : Tuple , *_lowerCAmelCase : List[...
31
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": A : List[Any] = argparse.ArgumentParser() parser.add_argument('''--dump_path''', defau...
176
0
'''simple docstring''' 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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImag...
712
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ : Optional[Any] = logging.get_logger(__name__) lowercase_ : int = { '''bigcode/gpt_bigcode-santacoder''': '''https://huggingface.co/bigcode/gpt_bigcode-sant...
653
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __A ( snake_case__ ): '''simple docstring''' a_ = ['''image_processor''', '''tokenizer'''] a_ = '''ChineseCLIPImageProcessor''' a_ ...
424
class __A : '''simple docstring''' def __init__( self ): _lowerCAmelCase : Dict = "" _lowerCAmelCase : Optional[Any] = "" _lowerCAmelCase : List[Any] = [] def SCREAMING_SNAKE_CASE__ ( self , _snake_case ...
424
1
'''simple docstring''' import logging from transformers import PretrainedConfig a_ : str = logging.getLogger(__name__) a_ : List[str] = { "bertabs-finetuned-cnndm": "https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summ...
532
'''simple docstring''' from typing import Any def _A (lowerCAmelCase__ :list ) -> list[Any]: '''simple docstring''' if not input_list: return [] _a = [input_list.count(lowerCAmelCase__ ) for value in input_list] _a ...
532
1
"""simple docstring""" class lowercase__ : def __init__( self : Any , snake_case__ : Any , snake_case__ : Optional[Any] ): lowerCamelCase_ : str =name lowerCamelCase_ : Tuple =val def __str__( self : str ): return ...
153
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase = { '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/resolve/main/config.json''', } class lowerCA...
247
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 __A : Optional[Any] = logging.get_logger(__name__) __A : ...
126
'''simple docstring''' import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class _UpperCamelCase ( tf.keras.layers.Layer ): '''sim...
126
1
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, Au...
678
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, ...
678
1
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_com...
486
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 ( AutoCo...
486
1
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments @require_tf c...
157
import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_G...
157
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A ={ "configuration_upernet": ["UperNetConfig"], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNot...
704
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 TF...
241
0
'''simple docstring''' from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): from ..mod...
41
'''simple docstring''' import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def _A ( A__ ): """simple docstring""" __lowercase = [ '''encoder.version''', '''decoder.version''', '''model.encoder....
41
1
"""simple docstring""" import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class __lowerCamelCase : def __init__( self ,...
20
"""simple docstring""" from __future__ import annotations from typing import Generic, TypeVar A__ : Any= TypeVar("""T""") class __lowerCamelCase ( Generic[T] ): def __init__( self , snake_case_ ) -> None: UpperCamelCase__ = data ...
20
1
'''simple docstring''' import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput A_ = logging.getLogger(__name__) if is_torch_tp...
143
'''simple docstring''' def A_ ( snake_case = 1000 ): SCREAMING_SNAKE_CASE:Tuple = 2**power SCREAMING_SNAKE_CASE:Optional[int] = str(snake_case ) SCREAMING_SNAKE_CASE:int = list(snake_case ) SCREAMING_SNAKE_CASE:Optional[Any] = 0 for i in l...
143
1
"""simple docstring""" from __future__ import annotations def lowerCamelCase ( _snake_case ,_snake_case = None ): UpperCAmelCase__ : List[Any] = word_bank or [] # create a table UpperCAmelCase__ : int = len(_snake_case ) + 1 UpperCAmelCase__ : ...
254
"""simple docstring""" import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import Backbon...
254
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class a ( metaclass=lowerCamelCase__ ): """simple docstring""" __UpperCAmelCase = ["""transformers""", """torch""", """note_seq"""] def __init__( self : Optional...
347
# 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 app...
454
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a_ :Tuple = { 'configuration_falcon': ['FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FalconConfig'], } try: if not is_torch_available(): raise OptionalDep...
709
import json import os from functools import lru_cache from typing import Dict, List, Optional, Tuple, Union import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding, EncodedInput from ...utils import PaddingStrategy, logging a_ :s...
250
0
import inspect import unittest class lowerCAmelCase_ ( unittest.TestCase ): def snake_case ( self ): try: import diffusers # noqa: F401 except ImportError: assert False def snake_case ( self ): import diffusers ...
105
def _A ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : list ): _enforce_args(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) if n == 0: return 0 UpperCamelCase :Union[str, Any] = float('''-inf''' ) for i in range(1 , n + 1 ...
658
0
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __a: int = (7_20, 12_80) # Height, Width __a: Any = (0.4, 0.6) # if height or width lower than this scale, drop it. __a: Optional[int] = ...
428
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase ): lowercase__ , lowercase__ : Tuple = position lowercase__ : int = [ (y + 1, x + 2), (y - 1, x + 2), (y + 1, x - 2), (y ...
428
1
"""simple docstring""" from __future__ import annotations import numpy as np def UpperCamelCase ( SCREAMING_SNAKE_CASE_ ) ->tuple[np.ndarray, np.ndarray]: _lowerCamelCase, _lowerCamelCase : List[str] = np.shape(SCREAMING_SNAKE_CASE_ ) if rows != columns: ...
434
"""simple docstring""" from collections.abc import Callable import numpy as np def UpperCamelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) ->np.array: _lowerCamelCase : Tuple = ...
434
1
"""simple docstring""" # Copyright 2022 The HuggingFace Team and The OpenBMB 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...
645
"""simple docstring""" import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transfor...
645
1
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer import...
445
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case : Optional[int] = logging.get_logger(__name__) snake_case : Optional[Any] = { '''microsoft/wavlm-base''': '''https://huggingface.co/microsoft/...
445
1
"""simple docstring""" def __magic_name__ ( __snake_case : int = 1000 ) -> int: lowercase , lowercase : Optional[Any] = 1, 1 lowercase : int = [] for i in range(1 , n + 1 ): lowercase : ...
518
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _A : int = logging.get_logger(__name__) _A : int = { """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json""", } cl...
518
1
from __future__ import annotations import numpy as np def _A ( _lowercase ) -> int: """simple docstring""" return np.maximum(0 , _lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
1
"""simple docstring""" def UpperCAmelCase_ ( __a : float , __a : float ): '''simple docstring''' if density <= 0: raise ValueError('Impossible fluid density' ) if bulk_modulus <= 0: raise ValueError('Impossible bulk modulus' ) retur...
437
0
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor UpperCamelCase : Dict = logging.get_logger(__name__) class UpperCamelCase__ (UpperCamelCase__ ): '''simple docstring''' def __init__( self ,*_lowerCAmelCas...
714
'''simple docstring''' 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_...
9
0
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format='%(message)s') def a_ ( lowerCAmelCase_ : np.ndarray ): return input_array.reshape((input_array.size, 1) ) def a_ ( lowerCAmelCase_ : np...
53
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import XLNetT...
524
0
"""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 lowercase = logging.get_logg...
713
"""simple docstring""" 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 SCREAMING_SNAKE_CASE_ ( unittest.TestCase): '''simple ...
150
0
"""simple docstring""" from __future__ import annotations def a__ ( lowerCAmelCase__ , lowerCAmelCase__ = None , lowerCAmelCase__ = None , lowerCAmelCase__ = False , ): UpperCAmelCase_ = cipher_alphabet or [chr(lowerCAmelCase__ ) for i in...
82
import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql import sql # no...
559
0
def __lowercase ( snake_case ): """simple docstring""" if len(snake_case ) <= 1: return [tuple(snake_case )] __magic_name__ :str = [] def generate(snake_case, snake_case ): if k == 1: res.append(tuple(arr[:] ) ) return ...
180
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 [ """tex...
180
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class snake_case__ ( metaclass=a_): a_ = ['''flax'''] def __init__( self : List[Any] , *_A : Tuple , **_A : Optional[int] ) -> str: requires_backends(self , ['...
541
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { '''facebook/xlm-roberta...
186
0
def lowerCamelCase__ ( ): """simple docstring""" for n in range(1 , 1000000 ): yield n * (n + 1) // 2 def lowerCamelCase__ ( lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : List[Any] = 1 SCREAMING_SNAKE_CASE : ...
488
def lowerCamelCase__ ( lowercase , lowercase ): """simple docstring""" return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
488
1
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo __UpperCamelCase : int = '\\n@misc{wu2016googles,\n title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n author...
248
def A ( _lowercase = 1_000_000 ): SCREAMING_SNAKE_CASE : Optional[int] = set(range(3 , _lowercase , 2 ) ) primes.add(2 ) for p in range(3 , _lowercase , 2 ): if p not in primes: continue ...
248
1
import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, r...
481
import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig 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_confi...
481
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCamelCase = { "configuration_swiftformer": [ "SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwiftFormerConfig", "SwiftFormerOnnxConfig"...
66
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase = { """configuration_upernet""": ["""UperNetConfig"""], } try: if not is_torch_available(): raise OptionalDepen...
259
0
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class...
712
"""simple docstring""" def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : list , SCREAMING_SNAKE_CASE : int ): '''simple docstring''' __lowerCamelCase : Optional[An...
363
0
"""simple docstring""" from math import isqrt def __snake_case ( SCREAMING_SNAKE_CASE: int ): """simple docstring""" return all(number % divisor != 0 for divisor in range(2 , isqrt(__UpperCamelCase ) + 1 ) ) def __sn...
580
"""simple docstring""" import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class _lowercase ( unittest.TestCase ): _lowerCamelCase ...
490
0
from ..utils import DummyObject, requires_backends class lowercase__( metaclass=snake_case__ ): '''simple docstring''' snake_case__ = ['''torch'''] def __init__( self , *__SCREAMING_SNAKE_CASE , **__SCREAMING_SNAKE_CASE) -> int: ...
582
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class lowercase__( tf.keras.optimizers.schedules.LearningRateSchedule ): ''...
582
1
'''simple docstring''' import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTester...
263
'''simple docstring''' import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": lowercase__ =argparse.ArgumentParser() parser.add_argument('--dump_path', default=None, type...
263
1
"""simple docstring""" from heapq import heappop, heappush import numpy as np def lowerCamelCase_( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , )-> tuple[float | int, list[tuple[int, int]]]: _SCREAMING_SNAKE_CASE : int...
716
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase_ = { '''configuration_clipseg''': [ '''CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CLIPSegConfig''', '''CLIPSegTextConfig''...
635
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 A__ (snake_case : Dict ...
279
import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset a__ = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1), 6: (3, 2), 7:...
279
1
"""simple docstring""" from math import isqrt, loga def lowercase ( UpperCamelCase : int ): """simple docstring""" A__ : Optional[int] =[True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in r...
715
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __A : Optional[Any] = { "configuration_resnet": ["RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP...
595
0
"""simple docstring""" import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, requir...
227
'''simple docstring''' from __future__ import annotations from math import pi, sqrt def UpperCamelCase ( lowercase_ : float , lowercase_ : float ) -> tuple: '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) e...
72
0
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, ...
714
"""simple docstring""" import requests snake_case = '''https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=''' def snake_case ( lowerCAmelCase_ ) -> None: # fetching a list of articles in json format _snake_case = requests.get(_NEWS_...
404
0
def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowercase = [0 for i in range(len(_SCREAMING_SNAKE_CASE ) )] # initialize interval's left pointer and right pointer __lowercase , __lowercase = 0, 0 for i in range(1 , len(_SCREAMING_SNAKE_CASE ) ): # case when cu...
402
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor snake_case__ : Optional[Any] = logging.get_logger(__name__) class _A ( _lowercase ): '''simple docstring''' def __init__( self : Dict , *lowerCam...
402
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE__ : Any = {'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig''', '''YolosOnn...
710
"""simple docstring""" from collections import Counter from timeit import timeit def A_ ( UpperCAmelCase__ = "" , ) -> bool: return sum(c % 2 for c in Counter(input_str.replace(' ' , '' ).lower() ).values() ) < 2 def A_ ( UpperCAmelCase...
509
0
'''simple docstring''' def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ) -> List[Any]: lowerCamelCase_ = '' for i in table: res += inp[i - 1] return res def _UpperCamelCase ( __UpperCamelCase ) -> Tuple: return data[1:] + data[0] ...
42
from math import sqrt def UpperCAmelCase ( a_ ) -> bool: """simple docstring""" assert isinstance(a_ , a_ ) and ( number >= 0 ), "'number' must been an int and positive" __A = True # 0 and 1 are none primes. if number <= 1: __...
55
0
"""simple docstring""" from typing import List, Union import numpy as np from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, logging from .base import PIPELINE_INIT_ARGS, ArgumentHandler, ChunkPipeline UpperCAmelCase_ : Union[str, Any] = logging...
176
"""simple docstring""" from __future__ import annotations import requests def _A (__a ) -> dict: """simple docstring""" SCREAMING_SNAKE_CASE_ : Any = f'https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty' return requests.get(__a ...
176
1
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": lowercase_ : List[Any] = argparse.ArgumentParser() parser.add_argument('--dump_path', default=None, type=s...
64
import math def A_ ( _UpperCAmelCase ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False ...
671
0
"""simple docstring""" import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def lowercase__( __SCREAMING_SNAKE_CASE : Dataset , __SCREAMING_SNAKE_CASE : Dict...
477
"""simple docstring""" import numpy as np def lowercase__( __SCREAMING_SNAKE_CASE : np.array ): return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
477
1
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_f...
460
'''simple docstring''' from math import sqrt def _SCREAMING_SNAKE_CASE (A = 1_000_000 ) -> int: """simple docstring""" lowercase__ = 0 lowercase__ = 0 lowercase__ = 42 while num_cuboids <= limit: max_cuboid_size += 1 ...
460
1
"""simple docstring""" from __future__ import annotations def lowerCAmelCase (__UpperCamelCase : str , __UpperCamelCase : Dict ): """simple docstring""" __UpperCamelCase =sorted(numsa + numsa ) __UpperCamelCase =divmod(len(__UpperCamelCase ) , ...
714
"""simple docstring""" def lowerCAmelCase (__UpperCamelCase : int = 1_0_0_0_0_0_0 ): """simple docstring""" __UpperCamelCase =1 __UpperCamelCase =1 __UpperCamelCase ={1: 1} for inputa in range(2 , __UpperCamelCase ): __Upper...
296
0
from collections import defaultdict class UpperCAmelCase_ : '''simple docstring''' def __init__( self , _A , _A ): '''simple docstring''' __SCREAMING_SNAKE_CASE = total # total no of tasks (N) # DP table will have a ...
148
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ : Any ={ '''configuration_mask2former''': [ '''MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Mask2FormerConfig''', ], } ...
148
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a : Optional[Any] = { '''configuration_mobilebert''': [ ''...
680
'''simple docstring''' # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format,...
680
1
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 lowercase_ = logging.get_logger(__name__) lowercase_ =...
74
"""simple docstring""" import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def lowercase__ ( lowerCamelCase : int , ...
308
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.ut...
223
'''simple docstring''' import os from pathlib import Path def _UpperCamelCase ( ) -> Tuple: '''simple docstring''' from torch.utils.cpp_extension import load UpperCamelCase__ = Path(__A ).resolve().parent.parent.parent / "kernels" / "deformable_detr" ...
223
1
"""simple docstring""" from queue import PriorityQueue from typing import Any import numpy as np def __lowerCAmelCase ( __UpperCamelCase : dict , __UpperCamelCase : str , __UpperCamelCase : set , __UpperCamelCase : set , __Upp...
58
"""simple docstring""" import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput __lowerCAmelCase : Tuple ...
58
1
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class _SCREAMING_SNAKE_CASE ( __snake_case ): ...
716
"""simple docstring""" def SCREAMING_SNAKE_CASE ( lowerCamelCase_): assert column_title.isupper() a__ = 0 a__ = len(lowerCamelCase_) - 1 a__ = 0 while index >= 0: a__ = (ord(column_title[index]) - 64) * pow(26 , ...
200
0
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class _lowerCamelCase ( datasets.BeamBasedBuilder ): def UpperCamelCase_ ( self ) -> Optiona...
64
"""simple docstring""" def lowerCamelCase_ ( __lowerCAmelCase , __lowerCAmelCase ) -> float: '''simple docstring''' return price * (1 + tax_rate) if __name__ == "__main__": print(F'''{price_plus_tax(100, 0.25) = }''') print(F'''{price_plus_tax(125.50, 0.05) = }''') ...
530
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/licenses/LICENS...
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 numpy as np import torch from torch.utils.data import Dataset from utils import logger class lowercase__ ( SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self : Optional[int] , _UpperCAmel...
82
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def __UpperCamelCase ( lowerCAmelCase__ : np.ndarray , lowerCAmelCase__ : np.ndarray ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(lowerCAmelCase__ , lowerCAmelCa...
521
0
def _UpperCamelCase ( lowerCAmelCase_ ) ->str: return "".join([hex(lowerCAmelCase_ )[2:].zfill(2 ).upper() for byte in list(lowerCAmelCase_ )] ) def _UpperCamelCase ( lowerCAmelCase_ ) ->bytes: # Check data validity, following RFC3548 # https://www.ietf.org/r...
717
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __lowercase ( unittest.TestCase ): def _lowercase ( self : ...
627
0
"""simple docstring""" import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ...
103
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case =logging.get_logger(__name__) __snake_case ={ """bigcode/gpt_bigcode-santacoder""": """https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/conf...
133
0
import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class __A ( enum.Enum ): __A ...
269
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore UpperCAmelCase__ : List[Any] =list(good_file_paths()) assert filepaths, "good_file_paths() failed!" UpperCAmelCase__ : Dict ...
269
1
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def __UpperCAmelCase ( __a : int = 3 ) -> qiskit.result.counts.Counts: """simple docstring""" if isinstance(__a ,__a ): ...
14
'''simple docstring''' import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from ut...
448
0
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 import Image from ..ima...
700
import os def __UpperCAmelCase ( ) -> Union[str, Any]: """simple docstring""" with open(os.path.dirname(__a ) + '''/grid.txt''' ) as f: _a : str = [] # noqa: E741 for _ in range(20 ): l.append([int(__a ) for x in f.read...
578
0
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vis...
58
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(">=", "4.25.0")): raise OptionalDependencyNotAvaila...
684
0
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqa...
355
'''simple docstring''' import os from datetime import datetime as dt from github import Github snake_case_ = [ """good first issue""", """good second issue""", """good difficult issue""", """enhancement""", """new pipeline/model""", """new scheduler""", """wip""", ] def ...
355
1
def a ( snake_case__: list ): '''simple docstring''' lowercase_ = len(snake_case__ ) for _ in range(snake_case__ ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: lowercase_ , lowercase_ = arr[i ...
97
from __future__ import annotations from math import pi, sqrt def a ( snake_case__: float , snake_case__: float ): '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: rais...
97
1
# Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __a = re.compile(R"""^(?P<major>\d+)""" R"""\.(?P<minor>\d+)""" R"""\.(?P<patch>\d+)$""") @total_ordering @dataclass class __lo...
627
from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configur...
627
1
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def A_ ( _lowerCAmelCase ) -> int: monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings" , set() ) @pytest.fixture def A_ ( _lowerCAmelCase ) -> ...
629
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils...
629
1
import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) _SCREAMING_SNAKE_CASE : Any = logging.getLogger() def __lowerCAmelCase (...
712
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import...
206
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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( OPENAI_CLIP_MEAN, OPENAI...
74
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class __UpperCamelCa...
74
1
import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import SeqaSeqLoggingCallback, get_checkpoint_ca...
701
import os from datetime import datetime as dt from github import Github A : Union[str, Any] = [ 'good first issue', 'good second issue', 'good difficult issue', 'enhancement', 'new pipeline/model', 'new scheduler', 'wip', ] def _lowe...
473
0
"""simple docstring""" import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class a__ ( UpperCamelCase_ ): snake_case__ = '''MCTCTFeatureExtractor''' snake_case__ = '''AutoTokenizer''' def __init__(...
227
"""simple docstring""" import math from collections.abc import Callable def UpperCAmelCase ( snake_case : Callable[[float], float] , snake_case : float , snake_case : float ): _lowerCAmelCase:float = xa _lowerCAmelCase:float ...
227
1
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokeniza...
701
'''simple docstring''' 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 imp...
511
0
import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, Ski...
2
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'andreasmadsen/efficient_mlm_m0.40': ( ...
503
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 A_( A , A , ...
486
from torch import nn class _UpperCamelCase ( nn.Module ): '''simple docstring''' def __init__( self : Dict , __lowercase : List[str] , __lowercase : Dict ): '''simple docstring''' super()._...
486
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a = { "configuration_bloom": ["BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP", "BloomConfig", "BloomOnnxConfig"], } try: if not ...
7
'''simple docstring''' from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Union[str, Any] = logging.get_logger(__name__) __lowerCAmelCase : Optional[int] = { ...
262
0
# 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 applic...
711
import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": __UpperCAmelCase = argparse.ArgumentParser( description=( """Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for Transfer Learned""" ...
582
0