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 __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar a =TypeVar("""T""") a =TypeVar("""U""") class A_ ( Generic[T, U] ): def __init__( self : str ,SCREAMING_SNAKE_CASE__ : Tuple ,SC...
652
from maths.prime_factors import prime_factors def UpperCamelCase_( lowerCamelCase_ ) -> int: if not isinstance(lowerCamelCase_ , lowerCamelCase_ ): _lowercase : str = F'''Input value of [number={number}] must be an integer''' raise TypeError(lowerCa...
89
0
import logging import os from typing import Dict, List, Optional, Union import torch import torch.nn as nn from accelerate.utils.imports import ( is_abit_bnb_available, is_abit_bnb_available, is_bnb_available, ) from ..big_modeling import dispatch_model, init_empty_weights from .dat...
241
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() __A =logging.get_logger(__name__) __A ={name: getattr(transformers, name + "Fast") for name in SLOW_TO_FAST_CONVE...
241
1
"""simple docstring""" import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline fr...
34
"""simple docstring""" import os import sys import unittest SCREAMING_SNAKE_CASE_ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files...
34
1
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : # Public class to implement a graph def __init__( self , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): '''simple docstring''' __a : Dict = row ...
697
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __SCREAMING_SNAKE_CASE : Optional[Any] = {'configuration_focalnet': ['FOCALNET_PRETRAINED_CONFIG_ARC...
697
1
"""simple docstring""" from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDMScheduler, ...
264
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms im...
264
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import load_numpy, s...
707
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class lowerCamelCase__( ...
80
0
from __future__ import annotations class lowerCAmelCase_ : def __init__( self, SCREAMING_SNAKE_CASE_ ) -> None: UpperCamelCase : List[Any] = order # a_{0} ... a_{k} UpperCamelCase : Tuple = [1.0] + [0.0] * ...
40
# 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 appli...
40
1
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # 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 __lowerc...
305
'''simple docstring''' import inspect import unittest from transformers import MobileViTConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common impor...
305
1
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. snake_case_ : str = 200 # Number of elements selected in every generation of evolution. The selection takes # place from best to worst ...
212
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (snake_case__ : int ): """simple docstring""" _snake_case : Any = [True] * limit _snake_case : Optional[Any] = False _snake_case : List[str] ...
609
0
'''simple docstring''' import torch from torch import nn class _snake_case (nn.Module): def __init__( self ,_snake_case ,_snake_case ,_snake_case ,_snake_case ,_snake_case=1 ,_snake_case=False ): super().__init__() UpperCAmelCase_ : Any = n_token UpperCA...
323
'''simple docstring''' import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { """vocab_fil...
323
1
"""simple docstring""" import re def snake_case ( A__ ): UpperCAmelCase_ : Optional[int] = re.compile(r"^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$" ) if match := re.search(A__ ,A__ ): return match.string == phone return False if __name__ == "__main__": print(indian_phone_...
95
"""simple docstring""" import math def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' return math.sqrt(lowerCAmelCase ) * math.sqrt(lowerCAmelCase ) == num def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' ...
673
0
'''simple docstring''' # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import...
124
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available A__ : Optional[int] = { '''configuration_audio_spectrogram_transformer''': [ '''AUDIO_SPECTROGRAM_TRANSFORMER_PRETR...
124
1
_snake_case = tuple[float, float, float] _snake_case = tuple[float, float, float] def _UpperCamelCase ( snake_case__, snake_case__ ) -> Vectorad: __UpperCAmelCase : Tuple = end_pointa[0] - end_pointa[0] __UpperCAmelCase : List[str] ...
382
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class _snake_case ( _lowercase ): lowerCamelCase__: Op...
382
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase_ : str = { '''configuration_transfo_xl''': ['''TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TransfoXLCo...
165
"""simple docstring""" 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 ...
165
1
"""simple docstring""" from collections import deque from .hash_table import HashTable class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , **UpperCamelCase_ ) -> Any: super().__init__(*UpperCamelCase_ , **U...
76
"""simple docstring""" import math import flax.linen as nn import jax.numpy as jnp def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 1 , __UpperCamelCase = 1 , __UpperCamelCase = 1.0e4 , __UpperCamelCase = False , __UpperCame...
76
1
import gc import unittest import numpy as np import torch from diffusers import ( AudioDiffusionPipeline, AutoencoderKL, DDIMScheduler, DDPMScheduler, DiffusionPipeline, Mel, UNetaDConditionModel, UNetaDModel, ) from diffusers.utils import slow, torch_device from diffusers.utils...
705
from collections.abc import Callable import numpy as np def snake_case__ ( __lowercase , __lowercase , __lowercase , __lowercase , __lowercase ) -> np.array: """simple docstring""" A__ : Any = int(np.ceil((x_end - xa) / s...
182
0
from ...processing_utils import ProcessorMixin class snake_case ( SCREAMING_SNAKE_CASE__ ): """simple docstring""" __lowerCAmelCase = "SpeechT5FeatureExtractor" __lowerCAmelCase = "SpeechT5Tokenizer" def __init__( self , lowerCAmelCase_ , lowerCAm...
321
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 PILImageResamplin...
662
0
from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("""socket.socket""" ) @patch("""builtins.open""" ) def UpperCamelCase__ ( lowerCAmelCase__ ,lowerCAmelCase__ ): # ===== initialization ===== lowercase = Mock() lowercase = c...
720
import argparse import hashlib # hashlib is only used inside the Test class import struct class A_ : def __init__( self : List[str] , snake_case__ : Union[str, Any] ): lowercase = data lowercase = [0X6_7_4_5_2_3_0_1, 0Xe_f_c_d_a_b...
72
0
import argparse import collections import json import os import re import string import sys import numpy as np A_: List[str] = re.compile(R'\b(a|an|the)\b', re.UNICODE) A_: Tuple = None def __lowerCAmelCase ( ): """simple docstring""" _lowercase = argparse...
398
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, Features, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase__ ) class lowerCamelCase_ ( lowerCAmelCase__ ): '''simple docstring''' __Up...
639
0
from __future__ import annotations def lowerCAmelCase_ (lowercase__ : int | float | str , lowercase__ : int | float | str ) -> list[str]: '''simple docstring''' if nth_term == "": return [""] lowerCAmelCase__ = int(lowercase__ ...
288
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase_ ( snake_case__ ): UpperCamelCase_ :Tuple = ['image_processor', 'tokenizer'] UpperCamelCase_ :Tuple = 'ViTImageProcessor' ...
288
1
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 lowerCamelCase : List[str] =4 lowerCamelCase : List[Any] =3 ...
228
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase_ ( A ): __lowerCamelCase...
443
0
"""simple docstring""" import logging from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import arg_to_scheduler from transformers import TrainingArguments a__ : Any = logging.getLogger(__name__) @dataclass class __magic_name__ ( _Uppe...
309
"""simple docstring""" import qiskit def A__ ( __lowerCamelCase, __lowerCamelCase ): """simple docstring""" _lowerCAmelCase = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q register _lowerCAmelCase = qiskit.QuantumCirc...
309
1
__a: Any = """ # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/huggingface/transformers.gi...
108
"""simple docstring""" import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () A_ : int =np.linspace(start=0, stop=7_5, num=7_5, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership f...
650
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) SCREAMING_SNAKE_CASE__:Optional[int] = {"""configuration_vit_mae""": ["""VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP""...
709
"""simple docstring""" from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError("""To use the rich extension, install rich with `pip install rich`""")
67
0
"""simple docstring""" import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream i...
102
"""simple docstring""" import re from filelock import FileLock try: import nltk UpperCAmelCase =True except (ImportError, ModuleNotFoundError): UpperCAmelCase =False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt", quiet=True) ...
617
0
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig 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_commo...
53
import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, AutoModelWithLMHead, ...
53
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : int = logging.get_logger(__name__) a__ : Any = { '''unc-nlp/lxmert-base-uncased''': '''https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config...
682
"""simple docstring""" import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import Generatio...
682
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEAN, IM...
705
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyImgaImgPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder import M...
472
0
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example UpperCAmelCase_ : Dict = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0,...
533
import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTokenizer, BlipImageProcessor, Bli...
20
0
"""simple docstring""" from collections import deque class A__ : def __init__( self , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): __lowerCAmelCase : int = process_name # process name __lowerCAmelCase : str = arrival_time # arrival time o...
713
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { """speechbrain/m-ctc-t-large""": """https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json"...
549
0
import os import re import shutil import sys import tempfile import unittest import black __UpperCAmelCase = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_copies # noqa: E402 # This is the reference co...
40
import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __magic_name__ (snake_case_ ): '''simple docstring''' __lowercase : List[str] = ['image_processor', 'tokenizer'] __lowercase :...
33
0
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( UpperCAmelCase_ : int ) -> list[int]: '''simple docstring''' __snake_case : Union[str, Any] = [True] * limit __snake_case : Tuple = Fal...
192
"""simple docstring""" import math def __UpperCAmelCase ( UpperCAmelCase_ : list , UpperCAmelCase_ : int ) -> int: '''simple docstring''' __snake_case : List[str] = len(UpperCAmelCase_ ) __snake_case : ...
192
1
import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizerOutput fro...
454
"""simple docstring""" import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as...
450
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy UpperCAmelCase : Optional[Any] ...
100
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase : List[Any] = logging.get_logger(__name__) Up...
100
1
"""simple docstring""" def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : str = (boundary[1] - boundary[0]) / steps _lowerCAmelCase : List[str] = boundary[0] _lowerCAmelCase : Tuple = ...
259
'''simple docstring''' from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def _A ( snake_case , snake_case , snake_case , snake_case , ) -> list[float]: _lowercase , _lowercase : Union[st...
245
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless req...
408
from torch import nn class _lowerCAmelCase ( nn.Module ): """simple docstring""" def __init__( self , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> int: """simple docstring""" super().__init__() snake_case__ ...
408
1
'''simple docstring''' import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.logging i...
71
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowercase ( lowercase__ ): lowercase = ['''image_processor''', '''tokenizer'''] lowercase = '''CLIPImageProcessor''' lowercas...
535
0
def __lowerCAmelCase ( A_ : int = 10 ) -> str: if not isinstance(A_ , A_ ) or n < 0: raise ValueError("Invalid input" ) __UpperCAmelCase = 10**n __UpperCAmelCase = 2_84_33 * (pow(2 , 7_83_04_57 , A_ )) + 1 return str(number %...
286
from abc import ABC, abstractmethod from argparse import ArgumentParser class UpperCAmelCase__ ( snake_case ): """simple docstring""" @staticmethod @abstractmethod def _UpperCAmelCase ( __lowerCAmelCase: ArgumentParser ) -> Tuple: '''simple docstring''' raise Not...
286
1
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, ...
517
'''simple docstring''' from collections import deque class SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : int , snake_case : str , snake_case : int , snake_case : int ): """simple docstring""" ...
517
1
from __future__ import annotations import requests __UpperCAmelCase = set( """approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked content_categories created_u...
709
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { """caidas/swin2sr-classicalsr-x2-64""": ( """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/main/config.json""...
218
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case__ : Optional[Any] = logging.get_logger(__name__) snake_c...
23
from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_torch_available(): import to...
441
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING A__ : Optional[Any] = logging.get_logger(__name__) A__ : List[str] = { """ut/deta""": """https://huggingface.co/ut/det...
717
"""simple docstring""" from __future__ import annotations def _snake_case ( lowerCamelCase__ : list[int] , lowerCamelCase__ : int ) -> bool: if len(lowerCamelCase__ ) == 0: return False lowerCamelCase_ : Dict =len(lowerC...
244
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCAmelCase = { 'configuration_rembert': ['REMBERT_PRETRAINED_CONFIG_ARCHIVE_...
201
from __future__ import annotations class lowerCamelCase : def __init__( self :List[Any] , lowercase :list[list[int]] ) -> Dict: """simple docstring""" SCREAMING_SNAKE_CASE = TypeError( '''Matrices must be formed from a list of zer...
201
1
from __future__ import annotations import typing from collections import Counter def __lowerCamelCase ( A__ : int ) -> typing.Counter[int]: lowerCamelCase_ : typing.Counter[int] = Counter() for base in range(1 , max_perimeter + 1 ): for perpendicular in range(A__ ,...
171
import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": snake_case__ : List[Any] = argparse.ArgumentParser() parser.add_argument( '--checkpoint_path', default=None, type=str, requi...
171
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class lowercase( metaclass=__a ): '''simple docstring''' lowercase__ = ["flax"] def __init__( self: Any, *a_: List[Any], **a_: Union[str, Any] ...
609
"""simple docstring""" from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_availab...
609
1
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...
46
class SCREAMING_SNAKE_CASE : """simple docstring""" def __init__( self , __UpperCamelCase , __UpperCamelCase ): """simple docstring""" snake_case_ = name snake_case_ = val def __str__( self ): """simple docstring""" return f"""{self...
46
1
import requests __magic_name__ : Any = """https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=""" def a_ ( __lowerCAmelCase ): # fetching a list of articles in json format lowerCAmelCase__ = requests.get(_NEWS_API + bbc_news_api_key ).json() #...
615
from scipy.stats import pearsonr import datasets __magic_name__ : Union[str, Any] = """ 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 relies ...
615
1
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ...
597
from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_xpu, require_torch_min...
597
1
import numpy as np def _a ( SCREAMING_SNAKE_CASE ): """simple docstring""" return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
43
def _lowerCamelCase ( ): return 1 def _lowerCamelCase ( a_ : int): return 0 if x < 0 else two_pence(x - 2) + one_pence() def _lowerCamelCase ( a_ : int): return 0 if x < 0 else five_pence(x - 5) + two_pence(a_) def _lowerCamelCase ...
166
0
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from...
435
'''simple docstring''' from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def A__ ( A : Namespace): '''simple docstring''' return ConvertCommand( args.model_type , args.tf_checkpoint , args.pyto...
435
1
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, ...
183
def a ( lowerCamelCase_ ): '''simple docstring''' if p < 2: raise ValueError('''p should not be less than 2!''' ) elif p == 2: return True lowercase__ = 4 lowercase__ = (1 << p) - 1 for _ in range(p - 2 ): lowe...
183
1
import inspect import unittest from transformers import MobileViTConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...
711
import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging _UpperCAmelCase = logging.get_logger(__name__) def _lowerCamelCase (...
297
0
'''simple docstring''' import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetne...
207
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCAmelCase ( metaclass=snake_case_ ): _lowercase: List[Any] = ['''torch''', '''scipy'''] def __init__( self : Tuple , *__snake_case : D...
207
1
import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark import ( BarkCoarseConfig, ...
708
"""simple docstring""" import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_uti...
553
0
"""simple docstring""" import qiskit def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int ,_lowerCamelCase : int ) -> qiskit.result.counts.Counts: _lowerCAmelCase : Optional[Any] = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit acting on the q ...
213
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : int = 1000 ) -> int: return sum(2 * a * ((a - 1) // 2) for a in range(3 ,n + 1 ) ) if __name__ == "__main__": print(solution())
213
1
'''simple docstring''' from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass UpperCamelCase__ : List[Any] = (3, 9, -11, 0, 7, 5, 1, -1) UpperCamelCase__ : Dict = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class _U...
178
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCamelCase__ : Tuple = logging.get_logger(__name__) UpperCamelCase__ : List[str] = { '''t5-...
178
1
'''simple docstring''' # 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...
365
def __snake_case ( _lowerCAmelCase : int ) -> bool: if num < 0: return False A_ : int = num A_ : int = 0 while num > 0: A_ : str = rev_num * 10 + (num % 10) num //= 10 return num_copy == r...
454
0
from sklearn.metrics import matthews_corrcoef import datasets lowercase : Dict = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes into account tr...
584
import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgumentParser, Traini...
584
1
'''simple docstring''' def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> int: """simple docstring""" return int((input_a, input_a).count(1 ) != 0 ) def lowerCAmelCase_ ( ) -> None: """simple docstring""" assert or_gate(0 , 0 ...
591
'''simple docstring''' import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from t...
591
1
'''simple docstring''' import warnings warnings.warn( "memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: " "`from accelerate import find_executable_batch_size` to avoid this warning.", FutureWarning, )
714
'''simple docstring''' from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize('''repo_id''' , ['''canonical_dataset_name''', '''org-name/dataset-name'''] ) @pytest.mark.parametrize('''path''' , ['''filename.csv''', '''fil...
575
0
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def a (_lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase = None ): if version.parse(hfh.__version__ ).release < version.parse('''0.11.0''' ).r...
234
from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils im...
484
0
import argparse import datetime def UpperCamelCase_ ( lowerCAmelCase__ ): """simple docstring""" _lowerCAmelCase : Any = { "0": "Sunday", "1": "Monday", "2": "Tuesday", "3": "Wednesday", "4": "Thursday", ...
713
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 snake_case = logging.get_logger(__name__) snake_case = "▁" snake_case ...
587
0
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common i...
138
'''simple docstring''' import math import random from typing import Any from .hill_climbing import SearchProblem def lowercase__( _UpperCamelCase : Optional[int] , _UpperCamelCase : bool = True , _UpperCamelCase : float = math.inf , _UpperCamelCase : float = -math.inf , _UpperCamelCase ...
138
1
"""simple docstring""" SCREAMING_SNAKE_CASE_ = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} SCREAMING_SNAKE_CASE_ = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__ ) -> List[Any]: a...
718
"""simple docstring""" from typing import TYPE_CHECKING from ..utils import _LazyModule SCREAMING_SNAKE_CASE_ = { """config""": [ """EXTERNAL_DATA_FORMAT_SIZE_LIMIT""", """OnnxConfig""", """OnnxConfigWithPast""", """OnnxSeq2SeqConfigWithPast""", """PatchingSpec""", ...
370
0
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__) __UpperCAmelCase = { 'microsoft/focalnet-t...
406
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class lowerCamelCase (ctypes.Structure ): '''simple docstring''' _snake_case : str = [('''size''...
406
1
__UpperCamelCase : str = '0.21.0' from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .data_loader im...
641
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator fr...
641
1
"""simple docstring""" from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from tran...
516
"""simple docstring""" import io import json import fsspec import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.json import JsonDatasetReader, JsonDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases ...
516
1
"""simple docstring""" import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": lowerCAmelCase_ : Tuple = argparse.ArgumentParser() parser.add_argument( '''--checkpoint_path''', defaul...
378
"""simple docstring""" from __future__ import annotations import pandas as pd def _lowerCAmelCase ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ): '''simple docstring''' UpperCAmelCase = [0] * no_of_processes UpperCAmelCase = ...
378
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin if is_torch_available(): import torch ...
605
from __future__ import annotations class __lowercase : """simple docstring""" def __init__( self , A_ )-> None: _SCREAMING_SNAKE_CASE = data _SCREAMING_SNAKE_CASE = None _SCREAMING_SNAKE_CASE = None de...
605
1
'''simple docstring''' from __future__ import annotations lowerCAmelCase__ : Tuple = [True] * 1_00_00_01 lowerCAmelCase__ : Any = 2 while i * i <= 1_00_00_00: if seive[i]: for j in range(i * i, 1_00_00_01, i): lowerCAmelCase__ : Dict = False i += 1 def __...
329
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class ...
329
1
'''simple docstring''' import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingfac...
369
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional from packaging import version if TYPE_CHECKING: from ... import PreTrainedTokenizer, TensorType from ...configuration_utils import PretrainedConfig from ...onnx import Onnx...
581
0
def A_ ( lowercase_ , lowercase_ , lowercase_ , lowercase_ ) ->int: """simple docstring""" SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = len(UpperCamelCase__ ), len(grid[0] ) if ( min(UpperCamelCase__ , UpperCamelCase__ ) < 0 or row == row...
715
__UpperCAmelCase = 9.80_665 def A_ ( lowercase_ , lowercase_ , lowercase_ = g ) ->float: """simple docstring""" if fluid_density <= 0: raise ValueError('Impossible fluid density' ) if volume < 0: raise ValueError('Impossible Object volume' ) if gravity <= 0: ...
259
0
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices SCREAMING_S...
85
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : Union[str, Any] = { "configuration_nllb_moe": [ "NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP", "NllbMoeConfig", ] } try: if...
85
1
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen...
369
def lowerCAmelCase_ ( __UpperCAmelCase: dict ) -> set: UpperCamelCase__ : int = set() # edges = list of graph's edges UpperCamelCase__ : str = get_edges(__UpperCAmelCase ) # While there are still elements in edges list, take an...
369
1
'''simple docstring''' import cva import numpy as np class _lowercase : def __init__( self : Any , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : int ) -> int: if k in (0.0_4, 0.0_6): __snake_case ...
56
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def _A ( ): """simple docstring""" lowerCAmelCase__ = ArgumentParser( description=( ...
61
0
"""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 Backbo...
713
"""simple docstring""" import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from...
282
0
"""simple docstring""" import math import random from typing import Any from .hill_climbing import SearchProblem def __lowercase ( snake_case_ : Optional[Any] ,snake_case_ : bool = True ,snake_case_ : float = math.inf ,snake_case_ : float = -math.inf ...
177
"""simple docstring""" def __lowercase ( snake_case_ : list ) ->float: '''simple docstring''' __A : Tuple = 0 while len(snake_case_ ) > 1: __A : List[Any] = 0 # Consider two files with minimum cost to be merged for _ in ran...
177
1
import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime as ort a__ : ...
709
from ...processing_utils import ProcessorMixin class lowercase ( UpperCAmelCase_ ): """simple docstring""" snake_case_ = 'WhisperFeatureExtractor' snake_case_ = 'WhisperTokenizer' def __init__( self : int , a_ : int , a_ : Uni...
235
0
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class UpperCamelCase ( unittest.TestCase ): '''simple docstring''' def UpperCamelCase ( self ): l...
257
from __future__ import annotations from collections import namedtuple def __lowerCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ) -> tuple: _UpperCAmelCase = namedtuple("result" , "name value" ) if (voltage, current, power).count(0 ) != 1: ...
684
0
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowercase_ ( __snake_case : Optional[int] , __snake_case : Tuple=False ) -> List[str]: '''simple docstring''' ...
57
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...
57
1
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_ava...
409
"""simple docstring""" from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { """t5-small""": """https://huggingfac...
409
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines....
712
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, ...
134
0
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def lowerCAmelCase_ ( lowercase: Any ) -> ...
271
from __future__ import annotations import csv import requests from bsa import BeautifulSoup def lowerCAmelCase_ ( lowercase: str = "" ) -> dict[str, float]: '''simple docstring''' _UpperCamelCase: Tuple = url or '''https://www.imdb.com/chart/top/?ref_=nv_mv_250''' _UpperCame...
271
1
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProcessing ...
360
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A_ = get_logger(__name__) A_ = r"\n Args:\n input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):\n ...
360
1
'''simple docstring''' import requests from bsa import BeautifulSoup def UpperCAmelCase_ ( __lowercase : int = "https://www.worldometers.info/coronavirus" ) -> dict: '''simple docstring''' _UpperCAmelCase = BeautifulSoup(requests.get(__lowercase ).text , "html....
236
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCAmelCase_ ( __snake_case ): _UpperCamelCase : str = ["image_processor", "tokenizer"] _UpperCamelCase : Union[str, Any] = "AutoImageProcesso...
66
0
'''simple docstring''' from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(...
499
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING A__ : Any =logging.get_logger(__name__)...
499
1
import unittest from transformers import SPIECE_UNDERLINE, ReformerTokenizer, ReformerTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common impor...
468
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCamelCase : Union[str, Any] = logging.get_logger(__name__) __UpperCamelC...
468
1
from copy import deepcopy class lowerCAmelCase__ : '''simple docstring''' def __init__( self , lowercase__ = None , lowercase__ = None ): '''simple docstring''' if arr is None and size is not None: __A ...
708
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Dict = {'''configuration_vit''': ['''VIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
516
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 _lowercase = logging.getLogger(__name__) _lowercase = 50 # max width of layer names _l...
659
from __future__ import annotations from collections.abc import Callable def UpperCamelCase ( snake_case__ , snake_case__ , snake_case__ , snake_case__ = 1_00 , ): lowerCAmelCase_ : Any = x_start lowerCAmelCase_ : Optional[Any] = fnc(snake_case_...
659
1
'''simple docstring''' __A : int = { """Pillow""": """Pillow""", """accelerate""": """accelerate>=0.11.0""", """compel""": """compel==0.1.8""", """black""": """black~=23.1""", """datasets""": """datasets""", """filelock""": """filelock""", """flax""": """flax...
720
'''simple docstring''' from __future__ import annotations def lowerCamelCase_ ( lowercase__ , lowercase__ , lowercase__): lowerCamelCase__ = list(range(len(lowercase__))) lowerCamelCase__ = [v / w for v, w in zip(lowercase__ , lowercase__)] index.sort(key=la...
187
0
import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pipeline_mixi...
191
import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( AutoConfig, AutoModelForSequenceClassification, Aut...
191
1
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py __snake_case = "src/transformers" # This is to make su...
181
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType clas...
181
1
'''simple docstring''' import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL,...
350
'''simple docstring''' from __future__ import annotations from bisect import bisect_left from functools import total_ordering from heapq import merge @total_ordering class a_ ( snake_case ): def __lt__( self : List[Any] , a_ : Optional[i...
350
1
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): A_ : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack A_ : set[int] = set() return any( node not in visited and depth_first_search(SCREAMING_SNAKE_CASE , S...
709
from typing import Dict from .base import GenericTensor, Pipeline class _lowerCamelCase ( UpperCamelCase ): """simple docstring""" def _snake_case ( self , _SCREAMING_SNAKE_CASE=None , _SCREAMING_SNAKE_CASE=None , _SCREAMING_SNAKE_CASE=None , **...
152
0
from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
47
'''simple docstring''' from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMi...
92
0
'''simple docstring''' from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class lowercase_ : __UpperCAmelCase = 42 __UpperCAmelCase = None __UpperCAmel...
223
'''simple docstring''' from __future__ import annotations def _UpperCamelCase ( __A , __A ) -> Optional[int]: '''simple docstring''' if len(__A ) <= 1 or n <= 1: return insert_next(__A , n - 1 ) rec_insertion_sort(__A , n - 1 ...
223
1
from __future__ import annotations import unittest from transformers import RoFormerConfig, 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, random_attention_mask fro...
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
def UpperCamelCase ( a , a ) -> int: '''simple docstring''' while a != 0: __magic_name__ , __magic_name__ = b % a, a return b def UpperCamelCase ( a , a ) -> int: '''simple docstring''' if gcd(a , a ) != 1: ...
712
'''simple docstring''' 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 ...
245
0
'''simple docstring''' import unittest from pathlib import Path from shutil import copyfile from transformers import SPIECE_UNDERLINE, is_sentencepiece_available from transformers.models.speech_to_text import SpeechaTextTokenizer from transformers.models.speech_to_text.tokenization_speech_to_text import VOCAB_FILES_...
72
'''simple docstring''' import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401...
72
1
import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, calculate_rouge, chunks, p...
721
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { """uclanlp/visualbert-vqa""": """https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json""", """uclanlp/visualbert-vqa-pre""": """https://huggingface.co/ucl...
622
0