code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from maths.prime_check import is_prime def _lowerCAmelCase ( _lowerCAmelCase ) -> int: '''simple docstring''' if not isinstance(_lowercase , _lowercase ): __snake_case = F'''Input value of [number={number}] must be an int...
371
'''simple docstring''' from torch import nn def __lowercase (_lowercase ) -> Union[str, Any]: """simple docstring""" if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() el...
150
0
'''simple docstring''' import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerT...
718
'''simple docstring''' from random import randint, random def __UpperCamelCase ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase = False , UpperCAmelCase = False , UpperCAmelCase = 5 , ): lowercase__ : Optional[Any] = [[-1] * number_of_cells] # Create a highway w...
428
0
from __future__ import annotations import math from collections.abc import Callable def SCREAMING_SNAKE_CASE__ ( lowercase ,lowercase ,lowercase ,lowercase = 100 ,) -> Optional[Any]: snake_case : int = x_start snake_case : List[Any] = fnc(lowerCAmelC...
587
# 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/licenses/LICENSE-2.0 # # Unless required by app...
53
0
'''simple docstring''' # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionCon...
411
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow ...
411
1
'''simple docstring''' import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger UpperCamelCase : Optional[Any] = '<<<<<<< This should probably be modified because it m...
50
"""simple docstring""" def _lowerCamelCase( a ): return " ".join( "".join(word[::-1] ) if len(a ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wollef sroirraw"""))
528
0
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def SCREAMING_SNAKE_CASE ( __UpperCamelCase : str = "laptop" ) -> DataFrame: """simple docstring""" A__ : List[Any] = F"https://www.amazon.in/l...
712
import numpy as np _SCREAMING_SNAKE_CASE : Any = [ ['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'k'], ['l', 'm', 'n', 'o', 'p'], ['q', 'r', 's', 't', 'u'], ['v', 'w', 'x', 'y', 'z'], ] class UpperCamelCase__ : '''simple docstring''' def __init__( self...
55
0
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class lowerCAmelCase__ ( unittest.TestCase ): ...
265
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ : Optional[int] = { 'configuration_llama': ['LLAMA_PRETRAINED_CONFIG_A...
265
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase : Any = { "configuration_resnet": ["RESNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "...
542
'''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 __UpperCAmelCase : def __init__( self , lowerCAmelCase_ ...
542
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dim...
563
from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, SquadDataTrainingArgument...
563
1
"""simple docstring""" from typing import Any, Dict, List, Union 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 ..image_utils import load_image if is_torch_available():...
704
"""simple docstring""" from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_u...
524
0
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class lowerCamelCase ( SCREAMING_SNAKE_CASE ): UpperCAmelCase : List[...
471
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImageResa...
471
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler,...
705
'''simple docstring''' import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision,...
92
0
'''simple docstring''' import unittest from knapsack import greedy_knapsack as kp class A ( unittest.TestCase ): def __lowerCAmelCase ( self : Union[str, Any] ) -> int: """simple docstring""" _a...
22
"""simple docstring""" from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class lowercase__( _UpperCAmelCase ): '''simple docstring''' def __lowerCAmelCase ( self :Union[str, Any] ) -> str: '''simple doc...
698
0
"""simple docstring""" 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 tran...
702
"""simple docstring""" def a__ ( lowerCAmelCase : list , lowerCAmelCase : list ): '''simple docstring''' _validate_point(lowerCAmelCase ) _validate_point(lowerCAmelCase ) if len(lowerCAmelCase ) != len(lowerCAmelCase ): raise ValueError("Both ...
660
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __magic_name__ : str =logging.get_logger(__name__) __magic_name__ : List[Any] ...
664
'''simple docstring''' import numpy class UpperCamelCase_ : """simple docstring""" def __init__( self : Union[str, Any] , _lowerCamelCase : numpy.ndarray , _lowerCamelCase : numpy.ndarray ) -> None: __magic_name__ ...
664
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available UpperCamelCase__ : int = {"tokenization_herbert": ["HerbertTokenizer"]} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() except Op...
620
import pickle import numpy as np from matplotlib import pyplot as plt class __snake_case : def __init__( self , _A , _A , _A , _A , _A , _A=0.2 , _A=0.2): SCREAMING_SNAKE_CASE_ = bp_numa SCREAMING_SNAKE_CASE_ = bp_numa ...
620
1
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBer...
78
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_ ( UpperCAme...
583
0
"""simple docstring""" import argparse import datetime def snake_case_ ( A_ : str ): '''simple docstring''' _lowerCamelCase : Union[str, Any] = { '''0''': '''Sunday''', '''1''': '''Monday''', '''2''': '''Tuesday''', ...
598
"""simple docstring""" import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorStat...
598
1
"""simple docstring""" import inspect import unittest from transformers import DecisionTransformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester...
595
"""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 DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils im...
426
0
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class snake_case__ (datasets.BuilderConfig ): """simple docstring""" SCREAMING_SNAKE_CASE_ : ...
662
import argparse import os import re __lowerCAmelCase : Union[str, Any] = 'src/transformers/models/auto' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict __lowerCAmelCase : Dict = re.compile(r'[A-Z_]+_MAPPING(\...
662
1
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { "facebook/encodec_24khz": "https://huggingface.co/facebo...
517
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( a__) -> float: """simple docstring""" if not nums: raise ValueError('List is empty') return sum(a__) / len(a__) if __name__ == "__main__": import doctest doctest.testmod()
517
1
'''simple docstring''' import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download i...
703
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) _a : str = {"configuration_vit": ["VIT_PRETRAINED_CONFIG_A...
10
0
import pickle import numpy as np from matplotlib import pyplot as plt class UpperCamelCase_ : '''simple docstring''' def __init__( self : List[Any] , UpperCAmelCase__ : Tuple , UpperCAmelCase__ : Dict , UpperCAmelCase__ : List[str] , Up...
87
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) snake_case_ ...
592
0
'''simple docstring''' import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, PreTrainedTokenizer, ...
13
'''simple docstring''' from __future__ import annotations from collections.abc import Callable a = list[list[float | int]] def __magic_name__ ( __UpperCAmelCase , __UpperCAmelCase ) -> Matrix: '''simple docstring''' __SCREAMING_SNAKE_CASE ...
13
1
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets __magic_name__ = datasets.logging.get_logger(__name__) __magic_name__ = '''\ @inproceedings{bleurt, title={BLEURT: Learning Robust Metrics for Text Generation}, author={Thibault Sella...
276
def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase ): if any(not isinstance(__lowerCAmelCase , __lowerCAmelCase ) or x < 0 for x in sequence ): raise TypeError("Sequence must be list of non-negative integers" ) for _ in range(len(__lowerCAmelCase ) ): for i, (rod_u...
276
1
'''simple docstring''' import math import flax.linen as nn import jax.numpy as jnp def lowerCamelCase ( UpperCamelCase : jnp.ndarray , UpperCamelCase : int , UpperCamelCase : float = 1 , UpperCamelCase : float = 1 , UpperCamelCase : ...
700
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_...
234
0
'''simple docstring''' from collections.abc import Iterable from typing import Generic, TypeVar __lowerCamelCase = TypeVar('''_T''') class A__ ( Generic[_T] ): def __init__( self , UpperCamelCase__ = None ) -> None: '''simple docstring...
288
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class A__ ( _snake_case ): lo...
288
1
def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> float: """simple docstring""" if mass < 0: raise ValueError('''The mass of a body cannot be negative''' ) return 0.5 * mass * abs(lowercase_ ) * abs(lowercase_ ) if __name__ == "__main__": impo...
177
def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ ) -> float: """simple docstring""" def get_matched_characters(lowercase_ , lowercase_ ) -> str: A__ = [] A__ = min(len(_stra ) , len(_stra ) ) // 2 ...
177
1
'''simple docstring''' import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configura...
502
'''simple docstring''' from __future__ import annotations SCREAMING_SNAKE_CASE__ : List[Any] = 1.6021e-19 # units = C def a ( UpperCamelCase_ : float , UpperCamelCase_ : float , UpperCamelCase_ : float , ) -> tuple[str, float]: if (con...
538
0
def __magic_name__ ( __a : int , __a : int ): '''simple docstring''' return abs(__a ) if a == 0 else greatest_common_divisor(b % a , __a ) def __magic_name__ ( __a : int , __a : int ): '''simple docstring''' while y: # --> when y=0 then loop wi...
86
import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBertForMaskedLM, DistilBer...
86
1
"""simple docstring""" from __future__ import annotations a = """#""" class lowercase_ : '''simple docstring''' def __init__( self : Tuple ): _A = {} def lowerCAmelCase_ ( self : Tuple , _UpperCAmelCase : str ): ...
7
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_GUID...
548
0
"""simple docstring""" import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipeline...
614
"""simple docstring""" from heapq import heappop, heappush import numpy as np def __UpperCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , ) -> tuple[float | int, list[tuple[int, int]]]: """simp...
614
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { "facebook/dpr-ctx_encoder-single-nq-base": ( "https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base...
329
'''simple docstring''' import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging __UpperCAmelCase = logging.get_logger(__name__) def lowerCAmelCase_ ( __A : Union[str, Any] )...
329
1
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalD...
702
'''simple docstring''' import numpy as np def __A ( a_ : np.array ): return (2 / (1 + np.exp(-2 * vector ))) - 1 if __name__ == "__main__": import doctest doctest.testmod()
551
0
"""simple docstring""" 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 trans...
142
"""simple docstring""" import os def lowerCamelCase_ ( ): lowerCamelCase_ = os.path.dirname(os.path.realpath(_lowerCamelCase ) ) lowerCamelCase_ = os.path.join(_lowerCamelCase , '''triangle.txt''' ) with open(_lowerCamelCase ) as f: ...
142
1
'''simple docstring''' 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_ava...
160
'''simple docstring''' import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def _SCREAMING_SNAKE_CASE ...
160
1
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDoc...
259
"""simple docstring""" 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 im...
259
1
'''simple docstring''' 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 imp...
708
'''simple docstring''' import argparse import torch from safetensors.torch import load_file from diffusers import StableDiffusionPipeline def SCREAMING_SNAKE_CASE( UpperCamelCase ,UpperCamelCase ,UpperCamelCase ,UpperCamelCase ,UpperCamelCase ) -> Tuple: # load bas...
471
0
'''simple docstring''' class lowercase_ : """simple docstring""" def __init__( self : Tuple, UpperCamelCase__ : int ) -> None: _A = size _A = [0] * size _A = [0] * size @staticmethod def __UpperCAmelCase ( UpperC...
107
'''simple docstring''' import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, ...
107
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __a : int = logging.get_logger(__name__) __a : Tuple = { '''uclanlp/visualbert-vqa''': '''https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json''', '''uclanlp/visualbert...
702
import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __a : Dict = logging.get_logger(__name__) class UpperCAmelCase( snake_case_ ): """simple docstring""" def __init__( self , *lowerCamelCase , ...
298
0
from __future__ import annotations def UpperCamelCase ( __magic_name__ : float , __magic_name__ : float , __magic_name__ : float ) -> float: """simple docstring""" if days_between_payments <= 0: raise ValueError("""days_between_payme...
15
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE_ = { """configuration_ctrl""": ["""CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CTRLConfig"""], """tokenization_ctrl...
237
0
from ..utils import DummyObject, requires_backends class snake_case_ ( metaclass=__lowercase ): A_ = ['note_seq'] def __init__( self : Dict , *_snake_case : Dict , **_snake_case : List[Any] )->List[str]: '''simple docstring'...
240
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int ) -> bool: if num < 0: return False __lowerCAmelCase : int = num __lowerCAmelCase : int = 0 while num > 0: __lowerCAmelCase : Any = rev_num * 10 + (num % 10) num //= 10 return num_copy == rev_n...
240
1
"""simple docstring""" import re def a ( __snake_case : str ): '''simple docstring''' UpperCAmelCase_ :Optional[Any] = re.compile( r'''^(?:0|94|\+94|0{2}94)''' r'''7(0|1|2|4|5|6|7|8)''' r'''(-| |)''' r'''\d{7}$''' ) return bool(re.search(__snake_case,...
608
"""simple docstring""" from __future__ import annotations from collections.abc import MutableSequence class _snake_case : '''simple docstring''' def __init__( self : Dict , snake_case : int , snake_case : MutableSequence[float] ): if len(snake_case ) !=...
608
1
"""simple docstring""" def _snake_case ( _snake_case : list[int] ): if not nums: # Makes sure that the list is not empty raise ValueError('''List is empty''' ) lowerCAmelCase : int = sum(_snake_case ) / len(_snake_case ) # Calculate the average ...
637
"""simple docstring""" 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 Paddin...
637
1
"""simple docstring""" from math import ceil def UpperCAmelCase__ (snake_case__ : Optional[Any] , snake_case__ : Union[str, Any] ): """simple docstring""" _snake_case : Union[str, Any] = list(range(0 , snake_case__ ) ) _snak...
609
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { '''xlm-roberta-base...
609
1
def _snake_case ( __snake_case = 10 ): if not isinstance(__snake_case , __snake_case ) or n < 0: raise ValueError('''Invalid input''' ) _UpperCamelCase = 10**n _UpperCamelCase = 28433 * (pow(2 , 7830457 , __snake_case )) + 1 return str(number % m...
711
def _snake_case ( __snake_case ): if not isinstance(__snake_case , __snake_case ): raise TypeError('''Input value must be an \'int\' type''' ) _UpperCamelCase = 0 while number: position += 1 number >>= 1 return position if __name__ == "__main_...
71
0
'''simple docstring''' import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preprocessing...
664
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ : int =logging.get_logger(__name__) __magic_name__ : List[Any] ={} class UpperCamelCase_ ( A ): """simple docstring""" UpperCAmelCase__ : in...
664
1
"""simple docstring""" import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class __magic_name__ ( __UpperCAmelCase ): __A : List[Any] = "" __A : str = ( ...
475
"""simple docstring""" import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel fro...
475
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ : Optional[Any] = { "configuration_convbert": ["CONVBERT_PRETRAINED_CON...
591
'''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/licenses/LICENSE-2.0 # # U...
591
1
"""simple docstring""" import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ...
720
"""simple docstring""" 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 BasicTra...
16
0
'''simple docstring''' def A ( UpperCamelCase_ : Optional[Any] , UpperCamelCase_ : Optional[int] ) -> int: '''simple docstring''' lowerCAmelCase__ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res ...
48
def SCREAMING_SNAKE_CASE ( lowercase_ ) -> list: """simple docstring""" if len(lowercase_ ) <= 1: return [tuple(lowercase_ )] A__ = [] def generate(lowercase_ , lowercase_ ): if k == 1: res.append...
87
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a__: List[str] = { 'configuration_layoutlmv3': [ 'LAYOU...
212
from __future__ import annotations import math from collections.abc import Callable def UpperCamelCase__( UpperCamelCase__ : Callable[[int | float], int | float] , UpperCamelCase__ : int | float , UpperCamelCase__ : int | float , UpperCamelCase__ : int = 1_00 , )->flo...
212
1
"""simple docstring""" # DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils i...
118
from manim import * class _A ( _lowerCamelCase ): def __a ( self : Dict ) -> Any: """simple docstring""" lowercase : Tuple = Rectangle(height=0.5 , width=0.5 ) lowercase : str = ...
217
0
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface im...
712
import argparse import struct import unittest class UpperCAmelCase__ : '''simple docstring''' def __init__( self : Any , a_ : bytes ): '''simple docstring''' __UpperCAmelCase : List[Any] = data # Initializ...
241
0
UpperCamelCase = range(2, 20 + 1) UpperCamelCase = [10**k for k in range(ks[-1] + 1)] UpperCamelCase = {} def _A ( lowerCAmelCase_ : Optional[int] , lowerCAmelCase_ : Tuple , lowerCAmelCase_ : List[Any] , lowerCAmelCase_ : Optional[Any] ): ...
61
import collections import importlib.util import os import re from pathlib import Path snake_case__ : Optional[int] = '''src/transformers''' # Matches is_xxx_available() snake_case__ : Union[str, Any] = re.compile(R'''is\_([a-z_]*)_available()''') # Catches a o...
392
0
def lowerCamelCase__ ( UpperCamelCase__ : Union[str, Any] ) -> str: '''simple docstring''' _snake_case = len(SCREAMING_SNAKE_CASE__ ) while cur > 1: # Find the maximum number in arr _snake_case = arr.index(max(arr[0:...
704
import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from transformers.utils import W...
541
0
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"): a_ :Optional[int] = { "linear": PIL.Image.Resampling.BILINEAR, "bilinear": PIL.Image.Resampling.BILINEAR, "bicubic"...
478
import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available() and ...
478
1
import math import unittest def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): assert isinstance(_A , _A ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0...
705
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=UpperCamelCase ) class _lowerCamelCase ( UpperCamelCase ): """simple docstring""" # `task` is not a ClassVar ...
152
0
from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) __A : List[Any...
27
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters A_ = (7_20, 12_80) # Height, Width A_ = (0.4, 0.6) # if height or width lower than this scale, drop it. A_ =...
609
0
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar UpperCAmelCase_ : List[str] = TypeVar('T') UpperCAmelCase_ : int = TypeVar('U') class SCREAMING_SNAKE_CASE__ ( Generic[T, U] ): def __init__...
443
import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets UpperCAmelCase_ : int = datasets.logging.get_logger(__name__) UpperCAmelCase_ : Dict = '\\n@InProceedi...
443
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(): ...
270
'''simple docstring''' def UpperCamelCase__ ( __SCREAMING_SNAKE_CASE ) -> int: if n == 1 or not isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ): return 0 elif n == 2: return 1 else: snake_case__ : int = ...
270
1
'''simple docstring''' import operator as op def __UpperCamelCase ( _lowercase ) -> Optional[int]: _lowercase : Optional[Any] = [] _lowercase : Any = lambda _lowercase, _lowercase : int(x / y ) # noqa: E731 integer division operation _low...
4
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def __UpperCamelCase ( _lowercase ) -> None: _lowercase , _lowercase : List[Any] = analyze_text(_lowercase ) _lowercase ...
4
1
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _lowerCamelCase : Optional[Any] = [ # tf -> hf ('''/''', '''.'''), ('''layer_''', '''layers.'''...
184
from __future__ import annotations def lowerCamelCase_ ( _UpperCamelCase ) -> list: """simple docstring""" if len(_UpperCamelCase ) == 0: return [] snake_case_ , snake_case_ : Dict = min(_UpperCamelCase ), max(_UpperCamelCase ...
60
0
import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class lowerCamelCase__ ( ...
225
import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEmbeddings, BertLayer, ...
225
1
"""simple docstring""" import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transforme...
450
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer __UpperCamelCase : List[Any] = loggin...
450
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils import I...
707
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, AutoModelForSeqaSeqLM, AutoTokenizer, ...
71
0
import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class lowerCAmelCase_ ( __snake_case , unittest.TestCase ): _U...
66
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowerCAmelCase__ :Tuple = {'''configuration_deit''': ['''DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''DeiTConfig''', '''DeiT...
618
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class __magic_name__ ( unittest.TestCase): ...
89
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class __magic_name__ ( __UpperCAmelCase): '''simple docs...
89
1
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva a :List[Any] = "" a :Union[str, Any] = "" a :List[str] = "" a :str = 1 # (0 is vertical, 1 is horizontal) def _lowercase ( ) -> ...
680
"""simple docstring""" import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger a :Optional[Any] = "<<<<<<< This should probably be modified because it mentions: " a :Tupl...
680
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ = {"configu...
393
"""simple docstring""" def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : int ): '''simple docstring''' if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise TypeError("""Input value must be an 'int' type""" ) lowerCAmelCa...
393
1
import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBertForMasked...
529
from __future__ import annotations def a__ ( A_, A_ ): '''simple docstring''' if b == 0: return (1, 0) ((__magic_name__) , (__magic_name__)) = extended_euclid(A_, a % b ) __magic_name__ = a // b return (y, x - k * y) def a__ ( ...
529
1
def UpperCAmelCase ( lowercase__ : int ): '''simple docstring''' if not isinstance(lowercase__ , lowercase__ ) or number < 0: raise ValueError("""Input must be a non-negative integer""" ) a__ = 0 while number: # This way we arrive at next set ...
718
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impo...
412
0
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase : Dict =lo...
228
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart import BartT...
228
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__name__) UpperCAmelCase_ = { '''uw-madison/mra-base-512-4''': '''https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json''', } class __magic_name__...
264
from __future__ import annotations UpperCAmelCase_ = 1.6_0_2_1E-1_9 # units = C def lowerCAmelCase_ ( lowercase: float , lowercase: float , lowercase: float , ) -> tuple[str, float]: '''simple docstring''' if (conductivity, electron_conc, mobi...
264
1
'''simple docstring''' from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) ...
275
'''simple docstring''' import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) __A : int = pytest.mark.integration ...
275
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase__ ={ '''configuration_mobilebert''': [ '''MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
702
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
0
'''simple docstring''' import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTok...
566
'''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 PreTrainedTokenizer from ...utils import logging snake_case : Tuple = logging.get_logger(__...
566
1
import coval # From: git+https://github.com/ns-moosavi/coval.git # noqa: F401 from coval.conll import reader, util from coval.eval import evaluator import datasets __SCREAMING_SNAKE_CASE = datasets.logging.get_logger(__name__) __SCREAMING_SNAKE_CASE = '\\n@InProceedings{moosavi2019minimum,\n author ...
153
from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_forma...
153
1
from ..utils import DummyObject, requires_backends class lowerCAmelCase__( metaclass=__lowercase ): '''simple docstring''' __snake_case = ['torch'] def __init__( self , *__lowerCamelCase , **__lowerCamelCase ) -> Optional[Any]:...
249
from __future__ import annotations def lowerCamelCase__ (__lowerCamelCase, __lowerCamelCase = None, __lowerCamelCase = None, __lowerCamelCase = False, ): _SCREAMING_SNAKE_CASE : Dict = cipher_alphabet or [chr(__lowerCamelCase ) for i in range...
249
1
'''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 if is_torch_available(): import torch ...
711
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UN...
92
0
"""simple docstring""" import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): imp...
34
from math import factorial def snake_case_ ( SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ,SCREAMING_SNAKE_CASE_ ) -> float: if successes > trials: raise ValueError("successes must be lower or equal to trials" ) if trials < 0 or successes...
397
0
'''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 if is_torch_available...
343
'''simple docstring''' def lowerCAmelCase_ ( snake_case__ ): '''simple docstring''' if len(snake_case__ ) <= 1: return [tuple(snake_case__ )] A : Dict = [] def generate(snake_case__ , snake_case__ ): if k == 1: ...
343
1
'''simple docstring''' 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...
309
'''simple docstring''' from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_...
309
1
'''simple docstring''' def _a ( ): snake_case : List[str] =[] snake_case : int =1 while len(lowerCamelCase_ ) < 1e6: constant.append(str(lowerCamelCase_ ) ) i += 1 snake_case : Tuple =''''''.join(lowerCamel...
136
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class lowerCAmelCase_ : def __init__( self : List[str], _snake_case : int ): '''simple docstring''' snake_case : Optional[...
136
1
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from...
1
'''simple docstring''' import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffuse...
350
0
import random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPAIN...
712
from __future__ import annotations import time import numpy as np lowerCamelCase_ : Any = [8, 5, 9, 7] lowerCamelCase_ : int = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] lowerCamelCase_ : int = ...
345
0
'''simple docstring''' from __future__ import annotations from typing import Any class a_ : def __init__( self : Dict , lowercase : int , lowercase : int , lowercase : float = 0 ): """simple docstring""" ...
172
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def UpperCAmelCase_ ( __lowerCamelCase : NDArray[floataa] ,__lowerCamelCase : NDArray[floataa] ,__lowerCamelCase : list[int] ,...
172
1
from __future__ import annotations def lowerCamelCase__ ( _lowerCamelCase = 4 ) ->list[list[int]]: _UpperCAmelCase =abs(_lowerCamelCase ) or 4 return [[1 + x + y * row_size for x in range(_lowerCamelCase )] for y in range(_lowerCamelCase )] def lowerCamelCase__ ( _lower...
592
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class _a ( A__ ): ...
592
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.j...
301
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversation...
327
0
'''simple docstring''' import math import flax.linen as nn import jax.numpy as jnp def snake_case_ (_a : jnp.ndarray , _a : int , _a : float = 1 , _a : float = 1 , _a : float = 1.0E4 , _a : bool = False ...
358
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A ={ 'configuration_table_transformer': [ 'TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TableTransformerConfig', 'TableTra...
358
1
"""simple docstring""" from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase__ ( _lowerCAmelCase ): """simple docstring""" A__ : Union[str, Any] = "ClapFeatureExtractor" ...
104
'''simple docstring''' # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Ver...
215
0
'''simple docstring''' from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf A : Union[str,...
702
'''simple docstring''' import unittest from transformers import MODEL_FOR_VISUAL_QUESTION_ANSWERING_MAPPING, is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, req...
163
0
from __future__ import annotations def __UpperCamelCase ( _lowerCAmelCase ) -> int: """simple docstring""" create_state_space_tree(_lowerCAmelCase , [] , 0 , [0 for i in range(len(_lowerCAmelCase ) )] ) def __UpperCamelCase ( _lowerCAmelC...
662
"""simple docstring""" def _snake_case ( UpperCamelCase : str , UpperCamelCase : int ): UpperCAmelCase : List[Any] = word.split() def justify(UpperCamelCase : list , UpperCamelCase : int , UpperCamelCase : int ) -> str: UpperCAmelCa...
160
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import DDIMPipeline, DDIMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, slow, torch_device from ..pipeline_params import UNCONDITIONAL_IMAGE_GENERATION_BATCH_PA...
700
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig,...
239
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) UpperCAmelCase_ : Any = ...
44
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class A ( lowerCamelCase_ ): '''simple docstring''' lowerCamelCase : Any = """""" lowerCamelCase : s...
226
0
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A__ ( A__ ): """simple docstring""" _lowercase = (UnCLIPScheduler,) def _UpperCamelCase( self : Any , **lowerCamelCase__ : Tuple ): a...
713
import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from transformers import AutoCo...
151
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCamelCase__ : Tuple = logging.get_logger(__name__) lowerCamel...
698
"""simple docstring""" from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class lowercase__( _UpperCAmelCase ): '''simple docstring''' def __lowerCAmelCase ( self :Union[str, Any] ) -> str: '''simple doc...
698
1
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to t...
152
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_dim...
152
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase : Optional[int] = { '''configuration_pix2struct''': [ '''PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Pix2StructConfig''', '...
511
def __lowerCamelCase ( __a :int ) -> Dict: """simple docstring""" A__ = len(__a ) A__ = sum(__a ) A__ = [[False for x in range(s + 1 )] for y in range(n + 1 )] for i in range(1 , n + 1 ): A__ ...
176
0
"""simple docstring""" from __future__ import annotations lowerCAmelCase_ = list[list[int]] # assigning initial values to the grid lowerCAmelCase_ = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3,...
635
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { '''asapp/sew-tiny-100k''': '''https://huggingface.co/asapp/sew-tiny-100k/resolve/main/config.js...
635
1