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 math import factorial def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ = 20 ): snake_case_ = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... snake_case_ = n // 2 return int(factorial(SCREAMING_SNAKE_CASE__ ) / ...
39
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_to...
52
0
'''simple docstring''' # Lint as: python3 # pylint: enable=line-too-long # pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position __lowerCamelCase : List[Any] = """2.13.1""" import platform import pyarrow from packaging import version if version.parse(platform.p...
418
'''simple docstring''' import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils im...
418
1
from math import isclose, sqrt def __UpperCAmelCase ( __a : float ,__a : float ,__a : float ) -> tuple[float, float, float]: """simple docstring""" _a : Any = point_y / 4 / point_x _a : Dict = 2 * normal_gradi...
14
def __UpperCAmelCase ( __a : str ) -> list: """simple docstring""" if n_term == "": return [] _a : list = [] for temp in range(int(__a ) ): series.append(F"""1/{temp + 1}""" if series else '''1''' ) retu...
14
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCAmelCase_ = { 'configuration_maskformer': ['MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MaskFormerConfig'], 'configuration_maskformer_swin': ['Ma...
712
from __future__ import annotations from math import ceil, floor, sqrt def lowerCamelCase__ ( A__ : int = 2000000 ): '''simple docstring''' __lowerCamelCase = [0] __lowerCamelCase = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ...
80
0
"""simple docstring""" import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XL...
636
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import Config...
678
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { """uclanlp/visualbert-vqa""": """https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json""", """uclanlp...
275
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( lowercase ): """simple docstring""" return [ord(lowercase ) - 96 for elem in plain] def __UpperCAmelCase ( lowercase ): """simple docstring""" return "".join(chr(elem + 96 ) for e...
275
1
from __future__ import annotations class snake_case : '''simple docstring''' def __init__( self : Any , lowerCAmelCase_ : int ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE_ = order # a_{0} ... a_{k} SC...
393
from collections import UserDict 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...
59
0
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
612
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowerCAmelCase ( UpperCamelCase_: ndarray ) -> float: '''simple docstring''' return np.dot(UpperCamelCase_ , Uppe...
612
1
a_ :Optional[Any] = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] a_ :Any = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] a_ :Any = { 0: "Sunday", 1: "Monday", 2: "Tuesday", 3: "Wednesday", 4: "Thursday", 5: "Friday", 6: "Saturday", } def lowercase_ (A : int , A : ...
478
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ :Optional[int] = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLNetC...
478
1
from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def _lowerCamelCase ( ): lowerCamelCase :Optional[int] = { '''repo_name''': ['''test_repo1''', '''test_repo2''', '''test_repo3'''], '''p...
718
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is...
49
0
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'vocab_file': 'vocab.json', 'merges_file': 'merges.txt',...
503
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, l...
503
1
"""simple docstring""" def A_ ( _lowerCAmelCase : int ) -> List[str]: """simple docstring""" assert ( isinstance(_lowerCAmelCase, _lowerCAmelCase ) and number_of_steps > 0 ), f'number_of_steps needs to be positive integer, your input {numbe...
704
"""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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_ut...
285
0
import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _UpperCamelCase = logging.get_logger(__name__...
243
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _lowerCamelCase ( a ): """simple docstring""" UpperCAmelCase_ : Dict ="ClapFeatureExtractor" UpperCAmelCase_ : Union[str, Any] =("RobertaToken...
243
1
'''simple docstring''' import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_ava...
709
'''simple docstring''' from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class _SCREAMING_SNAKE_CASE ( yaml.SafeLoader ): '''simple docstring''' def A ( self : List[str] , lowercase : List[Any] ...
265
0
from math import isqrt def _a ( lowerCAmelCase )-> bool: return all(number % divisor != 0 for divisor in range(2 , isqrt(lowerCAmelCase ) + 1 ) ) def _a ( lowerCAmelCase = 10**6 )-> int: SCREAMING_SNAKE_CASE_ = 0 SCREAMING_SNAKE_CASE_ ...
360
from math import isqrt def _a ( lowerCAmelCase )-> bool: return all(number % divisor != 0 for divisor in range(2 , isqrt(lowerCAmelCase ) + 1 ) ) def _a ( lowerCAmelCase = 10**6 )-> int: SCREAMING_SNAKE_CASE_ = 0 SCREAMING_SNAKE_CASE_ ...
360
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Dict = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', 'JukeboxVQVAEConfig...
717
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, Dist...
571
0
"""simple docstring""" import os def lowercase__ ( ) -> Optional[int]: lowerCAmelCase__ : List[Any] = os.path.join(os.path.dirname(lowerCamelCase ) , "num.txt" ) with open(lowerCamelCase ) as file_hand: return str(sum(in...
308
import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch SCREAMING_SNAKE_CASE_ ...
300
0
'''simple docstring''' from __future__ import annotations from typing import Generic, TypeVar SCREAMING_SNAKE_CASE__ : Any = TypeVar("""T""") class __lowerCAmelCase( Generic[T] ): def __init__( self : int , SCREAMING_SNAKE_CASE : int ): ...
707
'''simple docstring''' from PIL import Image def SCREAMING_SNAKE_CASE__ ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE_ :List[Any] = (259 * (level + 255)) / (255 * (259 - level)) def contrast(SCREAMING_SNAKE_CASE ) -> int: return int(128 + f...
233
0
'''simple docstring''' import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclass # C...
119
def A_ ( _lowerCAmelCase ) -> bool: UpperCamelCase : List[Any] = 0 for ch in input_str: UpperCamelCase : Optional[Any] = ord(_lowerCAmelCase ) UpperCamelCase : Optional[Any] = pow(2 , _lowerCAmelCase ) # If we already turned on bit for ...
629
0
from collections.abc import Sequence from queue import Queue class __A : def __init__(self , __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__=None , __magic_name__=None ): lowerCamelCase__ : int = start lowerCa...
96
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score fro...
96
1
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_stable_dif...
559
# limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class a__ ( __snake_case ): def __init__( self , UpperCAmelCase , UpperCAmelCase ) -> Tuple: super().__ini...
559
1
import argparse import os import torch from transformers.utils import WEIGHTS_NAME _lowerCAmelCase : Dict = ["small", "medium", "large"] _lowerCAmelCase : Dict = "lm_head.decoder.weight" _lowerCAmelCase : List[Any] = "lm_head.weight" def lowerCAmelCase ( _lowerCAmelCas...
712
import torch from transformers import AutoModel class _UpperCamelCase ( torch.nn.Module ): def __init__( self :str , lowerCamelCase :Tuple="sayef/fsner-bert-base-uncased" ) -> int: super(lowerCamelCase , self ).__init__() UpperCAmelCase__ = ...
364
0
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase_ : List[Any] , UpperCAmelCase_ : List[str] , UpperCAmelCase_ : int , UpperCAmelCase_ : Optional[Any] , UpperCAmelCase_ : Union[str, Any] , ) -> fl...
13
"""simple docstring""" def lowercase_ ( __UpperCAmelCase ) -> str: return " ".join( """""".join(word[::-1] ) if len(__UpperCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words("""Hey wo...
299
0
class snake_case_ : '''simple docstring''' def __init__( self, A_ ) -> None: UpperCAmelCase__ =size UpperCAmelCase__ =[0] * size UpperCAmelCase__ =[0] * size @staticmethod def __UpperCAmelCase ( A_ ) -> int: return index |...
700
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { 'Salesforce/blip-vqa-base': 'https://huggingface.co/Salesforce/blip-vqa-...
510
0
import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor from diffusers....
641
_lowercase : Dict = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3.0", "huggingface-hub": "...
641
1
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_INPAINT...
390
lowercase_ = {str(digit): digit**5 for digit in range(10)} def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : int ): '''simple docstring''' return sum(DIGITS_FIFTH_POWER[digit] for digit in str(__SCREAMING_SNAKE_CASE ) ) def __lowerCAmelCase ...
390
1
"""simple docstring""" import math def A_ (__a ): '''simple docstring''' A_ = [True] * n A_ = False A_ = False A_ = True for i in range(3 , int(n**0.5 + 1 ) , 2 ): A_ = i * 2 while i...
115
"""simple docstring""" import argparse import os import re UpperCamelCase_ : Any = '''src/transformers/models/auto''' # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict UpperCamelCase_ : Optional[int...
115
1
'''simple docstring''' from __future__ import annotations a__ = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] a__ = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def __UpperCAmelCase ( __a : str ) -> list[float]: """simple docstring""" ...
710
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py a__ = '''\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, title = {BLEU: a Method for Automatic Evaluation of ...
578
0
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils i...
184
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 A__ ( __A : List[str] , __A ...
184
1
'''simple docstring''' import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaP...
715
'''simple docstring''' def lowerCAmelCase (__A): """simple docstring""" _a = set() # To detect a back edge, keep track of vertices currently in the recursion stack _a = set() return any( node not in visited and depth_first_search(__A ...
352
0
import math def UpperCAmelCase_ ( _A , _A ): '''simple docstring''' if ( not isinstance(__UpperCamelCase , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError('''power_factor must be a valid float value...
493
def UpperCamelCase( __UpperCamelCase : Any ): if not head: return True # split the list to two parts lowerCAmelCase_ , lowerCAmelCase_ : Any = head.next, head while fast and fast.next: lowerCAmelCase_ : List[Any] = fast.next.next lowerCA...
171
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = { 'configuration_clipseg': [ 'CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP', 'CLIPSegConfig', 'CLIPSegTextConfig', 'CLIPSegVisionConfig', ...
702
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_c...
503
0
'''simple docstring''' import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class __snake_case ( ctypes.Structure ): __lowerCAmelCase = [("""size""", ctyp...
368
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentPars...
636
0
'''simple docstring''' import json import re from typing import TYPE_CHECKING, List, Optional, Tuple, Union import numpy as np from ...utils import is_tf_available, is_torch_available, logging if TYPE_CHECKING: if is_torch_available(): import torch if is_tf_available(): import tensorflow as tf from to...
721
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCamelCase__ = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig', ], 'feature_extr...
640
0
"""simple docstring""" import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import ve...
674
"""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/LICEN...
674
1
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging _snake_case : Any = logging.get_logger(__name__) _snake_case : int = { """CarlCochet/trajectory-transformer-halfcheetah-medium-v2""": ( """https://huggingface.co/CarlC...
493
'''simple docstring''' import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging import v...
493
1
def SCREAMING_SNAKE_CASE ( __lowerCAmelCase = 3 , __lowerCAmelCase = 7 , __lowerCAmelCase = 100_0000 ) -> Optional[Any]: snake_case__ = 0 snake_case__ = 1 for current_denominator in range(1 , limit + 1 ): snake_case__ = current_denominator * num...
33
from math import sqrt def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' 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 nu...
362
0
"""simple docstring""" import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) fro...
176
"""simple docstring""" import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def _A (__a ) -> Optional[int]: """simple docstring""" SCREAMING_SNAKE_CAS...
176
1
import os def __magic_name__ ( ): '''simple docstring''' with open(os.path.dirname(__a ) + """/p022_names.txt""" ) as file: UpperCamelCase__ = str(file.readlines()[0] ) UpperCamelCase__ = names.replace("""\"""" , """""" ...
513
def __magic_name__ ( __a : list[int] ): '''simple docstring''' UpperCamelCase__ = len(__a ) for i in range(__a ): for j in range(i + 1 , __a ): if numbers[j] < numbers[i]: UpperCamelCase__ , UpperCam...
513
1
"""simple docstring""" import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin __A = """ Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app ...
560
"""simple docstring""" class _lowerCAmelCase : """simple docstring""" def __init__( self , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ): '''simple docstring''' lowerCAmelCase__ :Tuple = None ...
560
1
import re import string import numpy as np import datasets __lowerCAmelCase : Dict ='\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' __lowerCAmelCase : str ='\nArgs:...
696
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Dict =logging.get_logger(__name__) __lowerCAmelCase : List[Any] ={ 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class _...
696
1
"""simple docstring""" import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": a_ = argparse.ArgumentParser() parser.add_argument('''--dump_path''', default=None, typ...
48
"""simple docstring""" from manim import * class __lowercase ( _UpperCAmelCase): """simple docstring""" def __UpperCamelCase (self ): snake_case_ : Union[str, Any] = Rectangle(height=0.5 , width=0.5 ) snake_c...
48
1
from typing import Any def lowerCamelCase__ ( _lowercase ): '''simple docstring''' if not input_list: return [] UpperCAmelCase_ : Any = [input_list.count(_lowercase ) for value in input_list] UpperCAmelCase_ : Dict = max(_lowercase ) # Gets the ...
30
import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor snake_case__ = logging.get_logger(__name__) class UpperCAmelCase ( __lowerCamelCase ): def __init__( self : Optional[Any] , *lowerCAmelCase : ...
583
0
from math import pow, sqrt def _SCREAMING_SNAKE_CASE ( *_lowerCamelCase : float) -> bool: '''simple docstring''' __UpperCamelCase : Tuple = len(_lowerCamelCase) > 0 and all(value > 0.0 for value in values) return result ...
94
import re import string import numpy as np import datasets lowercase : List[str] = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' lowercase : List[str] = '\...
94
1
'''simple docstring''' from __future__ import annotations def _snake_case ( _SCREAMING_SNAKE_CASE : Dict , _SCREAMING_SNAKE_CASE : Tuple ) -> Any: """simple docstring""" if len(_a ) == 0: return False lowerCAmelCase = len(_a ...
433
a_ = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) a_ = frozenset(['prompt', 'negative_prompt']) a_ = frozenset...
25
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig A: Optional[Any] = { "albert-base-v1": "https://huggingface.co/albert-base-v1/resolve/main/config.json", "albert-large-...
7
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A: int = { "configuration_trajectory_transformer": [ "TRAJECTORY_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "TrajectoryTransformerCon...
7
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices UpperCamelCase_ = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( ...
92
'''simple docstring''' import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": lowerCAmelCase_ : str = argparse.ArgumentParser() parser.add_argument( '''--checkpoint_path''', default...
414
0
"""simple docstring""" import json import sys def snake_case ( UpperCamelCase__ : Any , UpperCamelCase__ : Tuple ) -> Tuple: with open(UpperCamelCase__ , encoding="""utf-8""" ) as f: lowerCamelCase : str = json.load(UpperCamel...
42
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase :Optional[int] = logging.get_logger(__name__) __lowerCamelCase :List[str] = { 'google/realm-cc-news-pretrained-embedder': ( 'https://huggingface.co/google/real...
42
1
'''simple docstring''' A__ : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.6_0_9_3_4_4, "knot": 1.8_5_2, } A__ : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_7_7_7_7_7_7_7_8, "mph": 0.6_2_1_3_7_1_1_9_2, "knot": 0.5_3_9_9_5_6_8_0_3, } def ...
13
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, re...
405
0
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'p...
363
"""simple docstring""" from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import Squad...
363
1
"""simple docstring""" import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class lowerCAmelCase ( a ): """simple docstring""" __lowercase :Optional[Any] = (EulerDisc...
142
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase ( a ): """simple docstring""" __lowercase :Optional[int] = ["image_processor", "tokenizer"] __low...
142
1
"""simple docstring""" from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration...
700
"""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 a = logging.get_logger(__name__) a = { '''facebook/de...
505
0
from __future__ import annotations def __UpperCAmelCase ( __A , __A = None , __A = None ) -> None: '''simple docstring''' if start is None: UpperCAmelCase__ = 0 if end is None: UpperCAmelCase...
475
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A = logging.get_logger(__name__) A = { "facebook/deit-base-distilled-patch16-22...
475
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 = {'configuration_...
712
'''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 Padd...
8
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunDiscr...
176
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configu...
501
0
"""simple docstring""" import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pat...
701
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE =logging.get_logger(__name__) __SCREAMING_SNAKE_CASE ={ "facebook/wav2vec2-base-960h": "https://huggingface.co/facebook/wav2vec2-ba...
477
0
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
98
"""simple docstring""" from scipy.stats import pearsonr import datasets SCREAMING_SNAKE_CASE_ = ''' Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relie...
465
0
'''simple docstring''' import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class _a ( SCREAMING_SNAKE_CASE ): '''simple docstring''' A...
707
'''simple docstring''' import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def lowercase__( __UpperCamelCase: bytes ,__UpperCamelCase: int ): """simple docstring""" SCREAMING_SNAKE_CA...
508
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "RWKV/rwkv-4-169m-pile": "https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json", "RWKV/rwkv-4-430m-pile": "https://huggingface.co/RWKV/rwkv-...
42
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class __lowercase (_UpperCAmelCase ): def UpperCamelCase__ ( self ) ->List[Any]: '''simple docstring''' return [ {"col_1": 3, "col_2": "a"}, ...
492
0
"""simple docstring""" __SCREAMING_SNAKE_CASE ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def lowercase__( __SCREAMING_SNAKE_CASE : bytes ): # Make sure the supplied data is a bytes-like object if not isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNA...
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
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common import Token...
590
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): A_ : Dict = [0 for i in range(r + 1 )] # nc0 = 1 A_ : Tuple = 1 for i in range(1 , n + 1 ): # to compute current row from previous row. A_ : str = mi...
590
1
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 snake_case_ ( unittest.TestCase ): def __A ( self ): ...
712
import importlib import inspect import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py lowerCAmelCase__: Optional[int] = "src/transformers" # This is to make sure the trans...
311
0
def __UpperCamelCase ( lowercase__ : str , lowercase__ : str ) -> bool: '''simple docstring''' lowerCAmelCase_ : Optional[Any] = len(lowercase__ ) lowerCAmelCase_ : int = len(lowercase__ ) lowerCAmelCase_ ...
600
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class __a ( ctypes.Structure ): # _fields is a specific attr expected by ctypes __snake_case : Optional[Any] = [("""size""", ctypes.c_int),...
600
1
'''simple docstring''' # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2...
710
'''simple docstring''' from __future__ import annotations import math def _lowerCamelCase( UpperCamelCase__ : int ) -> list[int]: if num <= 0: A : str = F'''{num}: Invalid input, please enter a positive integer.''' raise ValueError(UpperCamelCase__ ...
537
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { 'facebook/nllb-moe-54B': 'https://huggingface.co/facebook/nllb-moe-54b/resolve/main/config.json', } class __lowerCAmelCase ( ...
291
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase_ = { 'configuration_timesformer': ['TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TimesformerConfig'], } try: if not is_torch_available(): raise OptionalD...
291
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __lowerCAmelCase = { '''configuratio...
704
"""simple docstring""" import requests from bsa import BeautifulSoup def A_ ( __UpperCamelCase : str , __UpperCamelCase : dict ): lowercase = BeautifulSoup(requests.get(__UpperCamelCase , params=__UpperCamelCase ).content , '''html.parser''' ...
396
0
'''simple docstring''' from math import factorial lowercase__ : dict[str, int] = {str(digit): factorial(digit) for digit in range(10)} def a__ ( lowercase : int ) -> int: """simple docstring""" if not isinstance(lowercase, lowercase ): r...
98
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureExtra...
112
0
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @requi...
361
"""simple docstring""" # Function to print upper half of diamond (pyramid) def lowercase_ ( _UpperCAmelCase ): """simple docstring""" for i in range(0 , _UpperCAmelCase ): for _ in range(0 , n - i - 1 ): # printing spaces print(''' ''' , end=''''...
361
1
from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, default_data_colla...
225
import argparse import os import re import tensorflow as tf import torch from transformers import BertConfig, BertModel from transformers.utils import logging logging.set_verbosity_info() lowerCamelCase__ = logging.get_logger(__name__) def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : Uni...
225
1
'''simple docstring''' import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging lowercase_ = "\\n\n" lowercase_ = "\nPerplexity (PPL) is one of the most common metrics for eval...
352
'''simple docstring''' from __future__ import annotations import math def lowerCAmelCase (__A , __A , __A , __A , __A): """simple docstring""" if depth < 0: raise ValueError('''Depth cannot be less than 0''') if not scores: raise V...
352
1
from __future__ import annotations from typing import Any def _SCREAMING_SNAKE_CASE ( __snake_case ) -> None: create_state_space_tree(__snake_case , [] , 0 ) def _SCREAMING_SNAKE_CASE ( __snake_case , __snake_case , __snake_case ) -> ...
108
'''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 UpperCAmelCase ( unittest.TestCase ): '''simple docstring''' ...
42
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fr...
712
from manim import * class __UpperCamelCase ( _lowercase ): """simple docstring""" def _UpperCAmelCase ( self ) -> Dict: a__ = Rectangle(height=0.5 , width=0.5 ) a__ = Rectangle(height=0.46 , width=0.46 ).set_stroke(width=0 ) a__ ...
148
0
'''simple docstring''' from typing import Dict, Optional import numpy as np import datasets __snake_case : List[str] = '\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For ...
215
'''simple docstring''' import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class lowerCamelCase ( lowercase_ , lowercase_ ): ...
215
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer SCREAMING_SNAKE_CASE__ = {"vocab_file": "vocab.txt", "tokenizer_file"...
104
"""simple docstring""" import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class lowerCAmelCase_ ( unittest.TestCase ): """simple docstring""" def snake_cas...
104
1
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def __snake_case ( lowerCAmelCase : list[list[float]] ): __UpperCAmelCase = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this impleme...
396
'''simple docstring''' from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo _UpperCamelCase : Any = '\\n@misc{wu2016googles,\n title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Tran...
396
1
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class _lowerCAmelCase ( __a ): def __a ( self , _UpperCamelCase ) -> Optional[Any]: with open(_UpperCamelCase , encoding="utf-8" ) as input_f...
279
import math import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from .attention_processor import Attention from .embeddings import get_timestep_embedding from .modeling_utils import ModelMixin class _lowerCAmelCase ( __a , __a ): @register...
279
1
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule, ...
298
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class lowerCAmelCase__ : def __init__( self : Optional[int] ) -> Optional[int]: __lowerCamelCase = '''''' __lowerCamelCase = '''''' __lowerCamelCase ...
298
1
import unittest from transformers import DebertaConfig, 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 ModelTesterMixin, ids_tensor from .....
376
# limitations under the License. # 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 .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils import deprecate deprecate...
376
1
def lowerCAmelCase__( lowercase : str , lowercase : str = " " ) -> List[Any]: __snake_case : Any = [] __snake_case : List[str] = 0 for index, char in enumerate(lowerCAmelCase__ ): if char == separator: split_words.ap...
243
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimestepEmbedding, FlaxT...
521
0
"""simple docstring""" 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 UpperCamelCase = [ os.path.join(os.path.dirname(__file__), dirname) ...
700
"""simple docstring""" import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn...
562
0
"""simple docstring""" import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib ...
213
'''simple docstring''' def lowerCAmelCase_ ( a : int ): a__ = generate_pascal_triangle(a ) for row_idx in range(a ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=' ' ) ...
394
0
"""simple docstring""" 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_ ( A__ , ...
714
"""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 B...
573
0
'''simple docstring''' def _a ( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase = 0 , _lowerCamelCase = 0 ) -> List[Any]: """simple docstring""" __snake_case : int = right or len(_lowerCamelCase ) - 1 if left > right...
26
def __UpperCamelCase ( A ): if len(A ) < 2: return collection def circle_sort_util(A , A , A ) -> bool: UpperCamelCase__ = False if low == high: return swapped UpperCamelCase__ = low ...
415
0
import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def a__ ( A_, A_ ): '''simple docstring''' assert isinstance(A_, A_ ...
718
import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokeniz...
76
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowerCAmelCase : str =logging.get_logger(__name__) __lowerCAmelCase : Unio...
359
"""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 Up...
359
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageResampling ...
626
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch i...
626
1
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_te...
385
from typing import Dict import numpy as np from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException if is_tf_available(): import tensorflow as tf from ..tf_utils import stable_softmax ...
385
1
"""simple docstring""" import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def _lowerCamelCase ( *lowerCamelCase__ : Optional[int] ): if not isinstance(lowerCamelCase__ , lowerCamelCase__ ): lowercase__ : Op...
128
"""simple docstring""" import socket def _lowerCamelCase ( ): lowercase__ : str = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) lowercase__ : int = socket.gethostname() lowercase__ : Optional[Any] = 1_23_12 sock.connect((host, port) ) sock.send...
128
1
'''simple docstring''' from sklearn.metrics import fa_score import datasets _SCREAMING_SNAKE_CASE = '\nThe F1 score is the harmonic mean of the precision and recall. It can be computed with the equation:\nF1 = 2 * (precision * recall) / (precision + recall)\n' _SCREAMING_SNAKE_CASE = ...
18
"""simple docstring""" def snake_case__ ( _lowerCamelCase, _lowerCamelCase ) ->Dict: """simple docstring""" assert x is not None assert y is not None __lowercase : Optional[int] = len(_lowerCamelCase ) __lowercase : Union[str, Any] ...
575
0
'''simple docstring''' import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def snake_case ( ) -> Any: """simple docstring""" UpperCamelCase_ : int = ...
707
'''simple docstring''' import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from t...
543
0
"""simple docstring""" import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput de...
594
"""simple docstring""" import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class __lowercase( lowercase__ ): '''simple docstring''' __a : int = (DDPMParallelScheduler,) def snake_case_ ( self , **__a...
594
1
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timestep...
709
"""simple docstring""" from __future__ import annotations def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase ) -> list[str]: '''simple docstring''' if partitions <= 0: raise ValueError("partitions must be a positive number!" ) if partitions > number_of_byte...
386
0
def lowerCamelCase__ ( __lowerCamelCase : int ): if not isinstance(__lowerCamelCase , __lowerCamelCase ): __UpperCAmelCase : Tuple = f"""Input value of [number={number}] must be an integer""" raise TypeError(__lowerCamelCase ) if numb...
63
"""simple docstring""" import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.mod...
616
0
from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. snake_case_ = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst of that generation and m...
718
class SCREAMING_SNAKE_CASE__ : def __init__(self : Optional[Any] ): """simple docstring""" __snake_case = {} def a (self : str ): """simple docstring""" print(self.vertex ) ...
388
0
"""simple docstring""" from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer __magic_name__ : L...
102
"""simple docstring""" from bisect import bisect from itertools import accumulate def UpperCamelCase (SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): UpperCamelCase : Dict = sorted(zip(SCREA...
102
1
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowerCamelCase_ ( _SCREAMING_SNAKE_CASE ...
403
import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, torch_device from transformers....
403
1
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Imag...
153
"""simple docstring""" import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info()...
153
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __UpperCamelCase : Optional[int] = logging.get_logger(__name__) __UpperCamelCase ...
712
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCamelCase : Union[str, Any] = { 'configuration_layoutlmv2': ['LAYOUTLMV2_PRETRAIN...
458
0
"""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 import ShapERenderer from d...
657
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def UpperCamelCase_( _snake_case : Optional[Any] ): """simple docstring""" ...
242
0
'''simple docstring''' from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging a : List[Any] = logging.get_logger(__name__) a : List[str] = { """huggingface/autoformer-tourism-monthly""": """https://huggingface.co/hugg...
720
'''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 : ...
609
0