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
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_funnel import FunnelTokenizer __snake_case : List[Any] =logging.get_logger(__name__) __snake_cas...
647
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_ful...
647
1
'''simple docstring''' def __lowercase (_lowercase ) -> list: """simple docstring""" # bit count represents no. of bits in the gray code if bit_count < 0: raise ValueError("""The given input must be positive""" ) # get the generated string sequence __low...
721
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def __lowercase () -> str: """simple docstring""" __lowerCamelCase : Any = HfArgumentParser(_lowercase ) __lowerCamelCase : List[str]...
483
0
'''simple docstring''' import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from tran...
334
'''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 ...
334
1
def _lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(SCREAMING_SNAKE_CASE ...
712
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, logging, ) logging.set_v...
563
0
_lowercase = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} _lowercase = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def __lowerCAmelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> list[int]: '''simple docstring''' ...
306
from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
306
1
from __future__ import annotations from fractions import Fraction def _snake_case ( __snake_case , __snake_case ) -> bool: '''simple docstring''' return ( num != den and num % 1_0 == den // 1_0 and (num // 1_0) / (den % 1_0) == num / den ) ...
718
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 ...
455
0
'''simple docstring''' class __UpperCAmelCase : '''simple docstring''' def __init__( self : Optional[Any] , _lowercase : int) -> None: A_ = size A_ = [0] * size A_ = [0] * size @staticmethod de...
366
'''simple docstring''' 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()...
366
1
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_si...
31
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( _lowercase : int = 10 , _lowercase : int = 1000 , _lowercase : bool = True ) ->int: '''simple docstring''' assert ( isinstance(_lowercase , _lowercase ) and isinst...
31
1
import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteSched...
64
'''simple docstring''' def a ( _UpperCAmelCase ) -> int: """simple docstring""" assert column_title.isupper() a_ = 0 a_ = len(_UpperCAmelCase ) - 1 a_ = 0 while index >= 0: a_ = (ord(column_title[index] ) - 6_4) * po...
697
0
"""simple docstring""" def _lowerCAmelCase ( lowerCamelCase__ : int ) -> int: _SCREAMING_SNAKE_CASE : int = 1 for i in range(1, num + 1 ): fact *= i return fact def _lowerCAmelCase ( lowerCamelCase__ : int ) -> ...
705
"""simple docstring""" import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( "files", [ ["full:README.md", "dataset_infos.json"], ["empty:README.md", "...
295
0
'''simple docstring''' # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lice...
442
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase_ : Dict = { 'configuration_graphormer': ['GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Graphormer...
442
1
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMix...
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, Mobi...
296
0
"""simple docstring""" import math import qiskit def lowerCamelCase_ (UpperCamelCase__ : Optional[int] = 1 , UpperCamelCase__ : int = 1 , UpperCamelCase__ : Optional[int] = 1 ): if ( isinstance(__a , __a ) or isinstance(__a , __a ) ...
506
import math from datetime import datetime, timedelta def UpperCamelCase_ ( __a ) -> datetime: a__ : Union[str, Any] = year % 19 a__ : List[str] = year % 4 a__ : str = year % 7 a__ : Any = math.floor(year / 100 ) a__ : List[str] = m...
37
0
"""simple docstring""" def UpperCAmelCase__ ( _UpperCAmelCase = 3 , _UpperCAmelCase = 7 , _UpperCAmelCase = 1000000 ): """simple docstring""" A_ : Union[str, Any] = 0 A_ : Optional[Any] = 1 for current_denominator in range(1 , ...
715
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin...
302
0
import datasets from .evaluate import evaluate _lowercase = '\\n@inproceedings{Rajpurkar2016SQuAD10,\n title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text},\n author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang},\n booktitle={EMNLP},\n year={2016}\n}\...
306
import os import jsonlines import numpy as np from tqdm import tqdm _lowercase = 2_048 _lowercase = 4_096 _lowercase = 42 _lowercase = os.environ.pop('PROCESS_TRAIN', 'false') _lowercase = {'null': 0, 'short': 1, 'long': 2, 'yes': 3, 'no': 4} def __lowerC...
306
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE__ : int = { 'configuration_groupvit': [ 'GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GroupViTConfig', 'GroupViTOnnxConfig...
720
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import conv...
636
0
"""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 = { '''facebook/xmod-base''': '''h...
93
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
304
0
from PIL import Image def _lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): def brightness(SCREAMING_SNAKE_CASE ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ValueError('''level must be betw...
720
def _lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' A_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def _lowerCamelCase ...
563
0
def snake_case (UpperCAmelCase__ ) -> list[int]: UpperCamelCase_: int = len(SCREAMING_SNAKE_CASE_ ) for i in range(SCREAMING_SNAKE_CASE_ ): for j in range(i + 1 , SCREAMING_SNAKE_CASE_ ): if numbers[j] < numbers[i]: UpperCamelC...
57
'''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()...
591
0
def a__ ( lowercase__ , lowercase__ ): '''simple docstring''' if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) UpperCAmelCase_ =str(bin(lowercase__ ) )[2:] # remove the leading "0b" UpperCAmelCase_ ...
550
import sys import turtle def a__ ( lowercase__ , lowercase__ ): '''simple docstring''' return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def a__ ( lowercase__ , lowercase__ , lowercase__ , lowercase__ , ): ...
550
1
'''simple docstring''' import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets UpperCAmelCase_ : Tuple = '''\ @inproceedings{kakwani2020indicnlpsuite, title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained...
24
"""simple docstring""" import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node UpperCAmelCase__ : str = 4 UpperCAmelCase__ : Dict...
223
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __a = { """configuration_blenderbot""": [ """BLENDERBOT_PRET...
720
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def lowerCamelCase__ ( _lowercase ): '''simple docstring''' ...
300
0
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.conversational i...
336
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 BartTokenizer lowercase ...
336
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, prepare_image_inputs if is_torch_availa...
702
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from...
227
0
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Dis...
511
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase : Optional[Any] = { 'configuration_mobilebert': [ 'MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
511
1
def lowerCAmelCase_ ( __UpperCAmelCase: int ) -> bool: if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True UpperCamelCase__ : Any = 4 UpperCamelCase__ : Any = (1 << p) - ...
369
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformers.models...
369
1
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar UpperCAmelCase__ : List[str] = TypeVar("T") class __lowercase ( Generic[T] ): def __init__( self , lowercase_) ->...
313
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever UpperCAmelCase__ : Union[str, Any] = logging.getLogger(__name__) class __lowercase ...
313
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _lowercase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: _low...
701
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class a_ ( UpperCAmelCase__ ): lowercase_ : int = ['''image_processor''', '''tokenizer'''] lowercase_ : Dict = '''AutoImageProcessor''' lowe...
427
0
def SCREAMING_SNAKE_CASE_ ( _snake_case :int = 100 ) -> int: _A = set() _A = 0 _A = n + 1 # maximum limit for a in range(2 , _snake_case ): for b in range(2 , _snake_case ): _A = a**b # calculates the c...
2
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
2
1
def _A (lowerCAmelCase__ :str , lowerCAmelCase__ :int ) -> list[str]: '''simple docstring''' return [sentence[i : i + ngram_size] for i in range(len(lowerCAmelCase__ ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
721
'''simple docstring''' # Copyright (c) 2021-, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
532
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __UpperCamelCase ( lowerCAmelCase__ ): """simple docstring""" lowerCAmelCase_ = ['''image_processor''', '''tokenizer'''] lowerCAmelCase_...
74
def __A ( _lowercase , _lowercase ): '''simple docstring''' _A = (boundary[1] - boundary[0]) / steps _A = boundary[0] _A = boundary[1] _A = make_points(_lowercase , _lowercase , _lowercase )...
484
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig _a : List[str] = logging.get_logger(__name__) _a : Union[str, Any] = { """Intel/dpt-large""": """https://huggingface.co/Intel/dpt-large/resolve/main/config....
111
import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_...
111
1
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, RobertaTo...
23
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar snake_case__ : Dict = TypeVar("""T""") class _a ( Generic[T] ): """simple docstring""" A_ = 42 # Cache st...
23
1
from queue import PriorityQueue from typing import Any import numpy as np def __magic_name__ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAme...
73
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_avail...
73
1
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqC...
46
"""simple docstring""" import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging _A = ...
182
0
'''simple docstring''' def _snake_case ( A ) -> bool: if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True lowerCAmelCase__ = 4 lowerCAmelCase__ = (1 << p) - 1 f...
98
'''simple docstring''' import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, r...
98
1
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_re...
570
from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE__ ( metaclass=lowercase__ ): snake_case__ : List[str] = ['''onnx'''] def __init__( self : List[Any] , *SCREAMING_SNAKE_CASE__ : Dict , **SCREAMING_SNAKE_CASE__ : ...
570
1
'''simple docstring''' import math def SCREAMING_SNAKE_CASE( UpperCamelCase ) -> str: UpperCAmelCase_ : List[str] = 0 UpperCAmelCase_ : str = 0 while num > 0: UpperCAmelCase_ : Union[str, Any] = num % 8 UpperCAmelCase_ ...
471
'''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, ...
471
1
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def a__ ( lowercase : int ) ...
98
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class A ...
326
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ : Any = logging.get_logger(__name__) UpperCamelCase_ : Dict = { '''uw-madison/mra-base-512-4''': '''https://huggingface.co/uw-madison/mra-b...
711
'''simple docstring''' from math import factorial def _lowerCAmelCase (_lowercase , _lowercase , _lowercase ): """simple docstring""" if successes > trials: raise ValueError("successes must be lower or equal to trials" ) if...
394
0
"""simple docstring""" def __magic_name__ ( UpperCamelCase : int = 1000 ) -> int: a__ = 1, 1 a__ = [] for i in range(1 , n + 1 ): a__ = prev_numerator + 2 * prev_denominator a__ = prev_numerator + prev_denominator if len(str(Uppe...
273
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class A__ : """simple docstring""" def __init__( self: Union[str, Any] )-> List[str]: lowerCamelCase : Optional[int] = ...
222
0
'''simple docstring''' import math import qiskit def A_ ( _lowerCAmelCase : Tuple = 1 , _lowerCAmelCase : str = 1 , _lowerCAmelCase : List[Any] = 1 ): """simple docstring""" if ( isinstance(_lowerCAmelCase , _lowerCAmelCase ) ...
708
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def A_ ( _lowerCAmelCase : Union[str, Any] ): """simple docstring""" if "img_encoder.pos_embed" in name: ...
11
0
"""simple docstring""" import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import ...
34
import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from...
445
0
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 from .tokenization_gpta import GPTaTokenizer ...
701
from __future__ import annotations def UpperCAmelCase__ ( lowerCamelCase_ : list[int] ): if not nums: return 0 __a : Any = nums[0] __a : List[Any] = 0 for num in nums[1:]: __a , __a : List[Any] = ( max_excluding + n...
577
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) lowercase_ = { """configuration_falcon""": ["""FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FalconConfig"""], } try: if not is_torch_available(): raise OptionalDe...
74
from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Confi...
431
0
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class lowerCamelCase ( datasets.BeamBasedBuilder ): '''simple docstring''' def A__ ...
716
def snake_case__ ( __SCREAMING_SNAKE_CASE ) -> str: UpperCAmelCase_ = int(__SCREAMING_SNAKE_CASE ) if decimal in (0, 1): # Exit cases for the recursion return str(__SCREAMING_SNAKE_CASE ) UpperCAmelCase_ , UpperCAmelCase_ = divmod(__SCREAMING_SNAKE_CASE , 2 ) re...
23
0
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class __lowercase : def __init__( self ) ->List[Any]: '''simple docstring''' __lowerCAmelCase : Union[str, Any] = '''''' __lowerCAmelCase : List[Any] = '''''' ...
492
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, Flax...
492
1
import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class a__ ( enum.Enum ): A__ ...
717
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xforme...
246
0
'''simple docstring''' import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logg...
28
def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase = " " ) -> list: """simple docstring""" snake_case__ : str = [] snake_case__ : int = 0 for index, char in enumerate(__lowerCAmelCase ): if char == separator: ...
252
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = { "configuration_roformer": ["ROFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "RoForme...
706
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
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor a = logging.get_logger(__name__) class __a ( _snake_case ): def __init__( self : str ,*lowerCamelCase : List[str] ,**lowerCamelCas...
109
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase = { '''configuration_swiftformer''': [ '''SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwiftFormerConfig''', '''SwiftFormerOnnx...
157
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ : Union[str, Any] = { "configuration_mgp_str": ["MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP", "MgpstrConfig"], "processing_mgp_str": ["...
721
"""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 ): """simple docstring""" snake_case__ = [("size...
632
0
# 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 # # Unless required by ap...
324
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanoramaPipeline, ...
324
1
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() def _lowerCAmelCase ( ...
642
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging a__ : Union[str, Any] = logging.get_logger(__name__) a__ : Optional[Any] = { "google/umt5-small": "https://huggingface.co/google...
642
1
"""simple docstring""" def lowerCamelCase_ ( __lowerCAmelCase=2_8123 ) -> int: '''simple docstring''' lowerCamelCase__ =[1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 ,...
530
"""simple docstring""" from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def lowerCamelCase_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase = False ) -> list[float]: '''simple doc...
530
1
'''simple docstring''' import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import logging _lowerc...
50
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase : List[str] = { """facebook/encodec_24khz""...
50
1
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common i...
336
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) lowercase : List[str] = { """configuration_clip""": [ "...
336
1
lowerCAmelCase : List[Any] = { """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""", """h...
720
def A_ ( a ): """simple docstring""" if upper_limit < 0: raise ValueError('Limit for the Catalan sequence must be ≥ 0' ) SCREAMING_SNAKE_CASE_ : List[str] = [0] * (upper_limit + 1) # Base case: C(0) = C(1) = 1 SCREAMING_SNAKE_CASE_ : An...
353
0
"""simple docstring""" import argparse import json import subprocess def _SCREAMING_SNAKE_CASE ( UpperCamelCase : List[str] , UpperCamelCase : Optional[Any] ): A__ = [] A__ = ( F"""curl -H \"Accept: application/...
574
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase__ = { "configuration_deberta": ["DEBERTA_PRETRAINE...
574
1
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging _lowercase = logging.get_logger...
96
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, ...
96
1
import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from diffusers.pipeli...
184
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_available()...
33
0
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require...
182
snake_case : Tuple = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def snake_case__ ( ) -> None: """simple docstring""" A__ : Union[str, Any] = input("Enter message: " ) A__ : Tuple = input("Enter key [alphanumeric]: " ) A__ : ...
182
1
import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ : Tuple = [ '''word_embeddings...
0
"""simple docstring""" import argparse import glob import logging import os import sys import time from collections import defaultdict from pathlib import Path from typing import Dict, List, Tuple import numpy as np import pytorch_lightning as pl import torch from callbacks import...
549
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase =logging.get_logger(__name__) __lowerCAmelCase ={'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/config.json'''} class __magic_name__ ( UpperCAmelCase__): _UpperCAmelCase :...
710
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_albert import Al...
405
0
import sys def UpperCamelCase_( _A :Optional[Any] )-> Tuple: UpperCamelCase__ = len(_A ) UpperCamelCase__ = [[0 for x in range(_A )] for x in range(_A )] UpperCamelCase__ = [[0 for x in range(_A )] for x in range(_A )] for chain_length in range(2 , _A...
551
import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": __UpperCamelCase = argparse.ArgumentParser() parser.add_argument( '--checkpoint_path', default=None, type=str,...
551
1
# 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 # # Unless requi...
708
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase__ = { "configuration_ctrl": ["CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP", "CTRLConfig"], "tokenization_ctrl": ["CTRLTokenizer"], } try: if...
634
0
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def A ( snake_case__ : List[Any] ) -> Optional[int]: '''simple docstring''' def wrapper(*snake_case__ : Any , ...
313
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
647
0
'''simple docstring''' def snake_case__ ( _A: int = 1000 ) -> int: '''simple docstring''' return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
713
'''simple docstring''' from math import ceil, sqrt def snake_case__ ( _A: int = 1000000 ) -> int: '''simple docstring''' lowerCAmelCase = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: lowerCAmelCase ...
605
0
import numpy as np from transformers import Pipeline def _SCREAMING_SNAKE_CASE ( __snake_case ) -> Union[str, Any]: _UpperCAmelCase = np.max(__snake_case , axis=-1 , keepdims=__snake_case ) _UpperCAmelCase = np.exp(outputs - maxes ) re...
108
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available _lowerCamelCase : int = { '''configuration_ernie''': ['''ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ErnieConfig''', '''ErnieOnnxConfig'''], } t...
686
0
def lowerCAmelCase_ ( __lowerCamelCase = 5_0_0_0_0_0_0_0 ): __snake_case : str = set() __snake_case : Optional[int] = int((limit - 2_4) ** (1 / 2) ) __snake_case : List[str] = set(range(3 , prime_square_limit + 1 ...
713
import unittest from transformers import BertGenerationTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin _snake_case : Optional[int] = ...
203
0
import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( "split_dict" , [ SplitDict(), SplitDict({"train": SplitInfo(name="train" , num_bytes=1337 , num_examples=42 , da...
59
# Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
291
0
def snake_case__ ( lowerCamelCase_ ): return 10 - x * x def snake_case__ ( lowerCamelCase_ , lowerCamelCase_ ): # Bolzano theory in order to find if there is a root between a and b if equation(lowerCamelCase_ ) * equation(lowerCamelCase_ ) >= 0...
423
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xf...
423
1
'''simple docstring''' import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class UpperCAmelCase : '''simple docstring''' @property def ...
42
'''simple docstring''' import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets A = '\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multiling...
320
0
from datetime import datetime import requests def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: str ) -> bytes: _UpperCAmelCase : Any = "https://downloadgram.net/wp-json/wppress/video-downloader/video?url=" _UpperCAmelCase : Tuple = requests.get(base_url + url ).j...
467
from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = {'openai-gpt': 'https://huggingface.co/openai-gpt/resolve/main/config.json'} class a ( UpperCAmelCase ): _lowercase ...
467
1
"""simple docstring""" 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 i...
83
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE :Optional[Any] = loggi...
236
0
"""simple docstring""" import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForCon...
500
"""simple docstring""" import baseaa def _snake_case ( UpperCAmelCase_ : str ): return baseaa.aaaencode(string.encode("""utf-8""" ) ) def _snake_case ( UpperCAmelCase_ : bytes ): return baseaa.aaadecode(UpperCAmelCase_ ).decode("""utf-8"""...
500
1
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: list ): SCREAMING_SNAKE_CASE__ = len(UpperCamelCase__ ) for i in range(1 , UpperCamelCase__ ): SCREAMING_SNAKE_CASE__ = collection[i] SCREAMING_SNAKE_CASE__ = 0 SCREAMING_SNAKE_CASE__ ...
6
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCamelCase__ = { 'configuration_mega': ['MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegaConfig', 'MegaOnnxConfig'], } try: if not is_torch...
110
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 packag...
197
"""simple docstring""" import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand __lowerCAmelCase : Optional[Any] =( """4S 3H 2C 7S 5H""", """9D 8H 2C 6S 7H""", """2D 6D 9D TH 7D""", """TC 8C 2S JH 6C""", ...
197
1
from manim import * class __UpperCamelCase ( _lowercase ): """simple docstring""" def _UpperCAmelCase ( self ) -> int: a__ = Rectangle(height=0.5 , width=0.5 ) a__ = Rectangle(height=0.46 , width=0.46 ).set_stroke(width=0 ) a...
194
import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor,...
194
1
'''simple docstring''' import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() __lowerCamelCase : Optional[int] = logging.get_logger(__name__) __lower...
713
'''simple docstring''' import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py __lowerCamelCase : ...
656
0
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor ...
168
'''simple docstring''' from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _A ( lowercase__ = "isbn/0140328726" ): lowercase__ = olid.strip().strip("""/""" ) # Remove leading/trailing whitespace & slashes if new_o...
325
0
import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging UpperCamelCase = logging.get_logger(__name__) class lowerCAmelCase_ ( __snake_case ): _UpperCamelCase : str ...
677
from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, r...
677
1
'''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, ) UpperCamelCase__ : int = pytest.mark.integration @pytest.mark.pa...
578
'''simple docstring''' from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _UpperCamel...
578
1
"""simple docstring""" from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def __lowercase ( _a , _a...
485
"""simple docstring""" import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) lowercase__ : List[...
485
1
import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import jit ...
651
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) for dirname in [ """text-classificat...
651
1
"""simple docstring""" import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class lowerCAmelCase__ : def __init__( self : Any , _lowerCamelCase ...
430
"""simple docstring""" from __future__ import annotations UpperCAmelCase__ = '#' class lowerCAmelCase__ : def __init__( self : List[Any] ): _snake_case = {} def lowercase ( self : str , _lowerCa...
430
1
def A__ ( lowerCamelCase , lowerCamelCase ) -> str: if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) UpperCamelCase_: Tuple = str(bin(lowerCamelCase ) )[2:] # remove the leading "0b" UpperCamelCase_: Any ...
548
import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def A__ ( lowerCamelCase , lowerCamelCase=() , lowerCamelCase=None , lowerCamelCase="no" , lowerCame...
548
1
'''simple docstring''' from ....utils import logging A : str = logging.get_logger(__name__) class lowerCAmelCase_ ( a_ ): def __init__( self : int, _snake_case : Dict, _snake_case : Optional[int]=None, _snake_case ...
136
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A : Any = logging.get_logger(__name__) A : Optional[Any] = {} class lowerCAmelCase_ ( a_ ): __UpperCAmelCase = 'llama' __UpperCAmelCase = ['past_key_...
136
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
164
import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( __snake_case ): """simple docstring""" lowerCAmelCase = (IPNDMScheduler,) lowerCAmelCase = (('num_inference_steps', 5_0)...
641
0
'''simple docstring''' def _lowercase ( lowercase__ = 1_0_0_0 ): __lowerCAmelCase : Tuple = 1, 1 __lowerCAmelCase : Optional[int] = 2 while True: __lowerCAmelCase : Optional[int] = 0 __lowerCAmelCase : Tuple ...
702
from math import factorial def _lowercase ( lowercase__ , lowercase__ ): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError('''Please enter posi...
583
0
def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> int: """simple docstring""" a = 1 for i in range(1, num + 1 ): fact *= i return fact def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> int: """simple docstring""" a = 0 while n...
387
import unittest import numpy as np from transformers.testing_utils import is_flaky, 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_tor...
387
1
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase : List[Any] = logging.get_logger(__name__) UpperCAmelCase : Any = { '''vocab_file''': '''vocab.json''', ...
706
import numpy as np from PIL import Image def _SCREAMING_SNAKE_CASE ( a , a , a ) -> np.ndarray: __A : Union[str, Any] = np.array(a ) if arr.shape[0] != arr.shape[1]: raise ValueError('The input array is not a square matrix' ...
77
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCamelCase ...
26
'''simple docstring''' from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers imp...
501
0
'''simple docstring''' import warnings from .generation import TFGenerationMixin class lowerCamelCase ( lowerCamelCase ): '''simple docstring''' warnings.warn( '''Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will ''' '''be remove...
717
'''simple docstring''' from heapq import heappop, heappush import numpy as np def __lowerCamelCase ( _UpperCamelCase : np.ndarray , _UpperCamelCase : tuple[int, int] , _UpperCamelCase : tuple[int, int] , _UpperCamelCase : bool , ): '''simple docstring'...
43
0
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor _lowerCamelCase : Any = logging.getLogger(__name__) _lowerCamelCase :...
352
def __a ( __lowerCAmelCase , __lowerCAmelCase = 0 ) -> list: SCREAMING_SNAKE_CASE : int = length or len(__lowerCAmelCase ) SCREAMING_SNAKE_CASE : Union[str, Any] = False for i in range(length - 1 ): if list_data[i] > ...
352
1
"""simple docstring""" from collections.abc import Callable class a_ : def __init__( self : Dict , __UpperCamelCase : Callable | None = None ) ->None: '''simple docstring''' _UpperCAmelCase = [] # Stores indexes of e...
715
"""simple docstring""" # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatting import TensorForma...
19
0
from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand lowercase_: Union[str, Any] = logging.get_logger(__name__) # pylint: disable=invalid-name def _...
648
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration lowercase_: Tuple = { 'tiny.en': 'https://openaipublic.azureedge.net/main/wh...
648
1
# This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( ...
702
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_to...
108
0
"""simple docstring""" import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, ren...
642
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel __UpperCAmelCase = { '''text_branch''': '''text_model''', '''audio_branch''': '''audio_model.audio_encoder''', '''attn''': '...
642
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
715
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time lowerCamelCase :Tuple = Lock() def __snake_case ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCame...
346
0