code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import...
694
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A__: Dict = logging.get_logger(__name__) A__: Optional[int] = { '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/markuplm-base/re...
694
1
from __future__ import annotations def lowercase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' if (voltage, current, resistance).count(0 ) != 1: raise ValueError('''One and only one argument must be 0''' ) if resistance < 0: ...
719
def lowercase_ ( _UpperCamelCase ): '''simple docstring''' __lowercase = [] __lowercase = [] __lowercase = { '''^''': 3, '''*''': 2, '''/''': 2, '''%''': 2, '''+''': 1, '''-''': 1, } # Priority of each operator __lower...
527
0
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging lowerCAmelCase_ = logging.get_l...
217
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar lowerCAmelCase_ = TypeVar('T') class _A ( Generic[T] ): def __init__( self : Optional[Any] , _A : T ) -> Union[str, Any]: ...
217
1
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class SCREAMING_SNAKE_CASE__ ( __A ): def __init__( ...
708
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, loggi...
68
0
from __future__ import annotations def lowerCAmelCase_ ( lowerCamelCase , lowerCamelCase ): print(F"Vertex\tShortest Distance from vertex {src}" ) for i, d in enumerate(lowerCamelCase ): print(F"{i}\t\t{d}" ) def lowerCAmelCase_ ( lowerCamelCase , ...
21
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin ...
21
1
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 UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { "hustvl/yolos-sm...
362
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, BlipaProcessor, BlipImageProcess...
362
1
from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer SCREAMING_SNAKE_CASE__ : List[Any] = logging.get_logger(__n...
0
'''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://huggingface.co/faceb...
634
0
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar _lowerCAmelCase = TypeVar('''KEY''') _lowerCAmelCase = TypeVar('''VAL''') @dataclass(frozen=SCREAMING_SNAKE_CASE__ ...
399
'''simple docstring''' def __lowerCAmelCase ( snake_case__ ): return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(snake_case__ ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__('''doctest''').testmod()
399
1
'''simple docstring''' import re from filelock import FileLock try: import nltk SCREAMING_SNAKE_CASE = True except (ImportError, ModuleNotFoundError): SCREAMING_SNAKE_CASE = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('p...
94
def snake_case (__lowercase ) -> int: '''simple docstring''' if not grid or not grid[0]: raise TypeError("The grid does not contain the appropriate information" ) for cell_n in range(1 , len(grid[0] ) ): grid[0][cell_n] += grid[0][cell_n - 1] _snake...
670
0
from collections.abc import Callable def a ( SCREAMING_SNAKE_CASE_ : Callable[[float], float] , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float ): """simple docstring""" UpperCamelCase : Optional[int] ...
721
from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def a ( SCREAMING_SNAKE_CASE_ : np.ndarray , SCREAMING_SNAKE_CASE_ : np.ndarray , SCREAMING_SNAKE_CASE_ : np.ndarray , SCREAMING_SNAKE_CASE_ : int ...
643
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A_ = { "configuration_llama": ["LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP", "Lla...
270
'''simple docstring''' 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_mvp i...
270
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class __A ( metaclass=a ): """simple docstring""" A_ = ['flax'] def __init__( self , *_lowerCamelCase , **_lowerCamelCase )-> List[str]: ...
702
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, ...
318
0
'''simple docstring''' import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def a__ ( _SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAKE_CASE : D...
71
'''simple docstring''' from statistics import mean, stdev def a__ ( _SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE : int = 3 ) -> list: """simple docstring""" UpperCAmelCase_ : Dict = min(_SCREAMING_SNAKE_CASE ) UpperCAmelCase...
71
1
'''simple docstring''' def _A ( A ) -> Optional[Any]: lowercase : Union[str, Any] = abs(UpperCamelCase__ ) lowercase : int = 0 while n > 0: res += n % 1_0 n //= 1_0 return res def _A ( A ) -> Tuple: lowercase : int ...
720
'''simple docstring''' import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelT...
425
0
'''simple docstring''' from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class __SCREAMING_SNAKE_CASE ( yaml.SafeLoader ): '''simple docstring''' def _lowerCamelCase ( self : Optional[int] ,UpperCamelCase ...
125
'''simple docstring''' import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_...
44
0
'''simple docstring''' from __future__ import annotations def _lowercase ( lowerCamelCase__ , lowerCamelCase__ = None ) -> list[list[str]]: """simple docstring""" __UpperCAmelCase : str = word_bank or [] # create a table ...
10
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _a : Any = logging.get_logger(__name__) _a : int = { "facebook/s2t-wav2vec2-large-en-de": ( "https://huggingface.co/facebook/s2t-wav2vec2-large-en-de/resolve/main...
10
1
"""simple docstring""" import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a ( unitte...
4
'''simple docstring''' from math import factorial def SCREAMING_SNAKE_CASE__ ( __A , __A , __A ) -> float: if successes > trials: raise ValueError('successes must be lower or equal to trials' ) if trials < 0 or successes < 0: raise ValueError('the f...
495
0
def lowerCamelCase__ ( snake_case_ : int ) -> bool: if not isinstance(snake_case_ , snake_case_ ): raise ValueError('''check_bouncy() accepts only integer arguments''' ) __snake_case = str(snake_case_ ) __snake_case = ''''''.join(sorted(sna...
388
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]' when switchi...
388
1
'''simple docstring''' import inspect import unittest from transformers import BitConfig 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...
3
# 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 required by...
30
0
"""simple docstring""" def lowercase (_snake_case = 1000 ) -> int: '''simple docstring''' __UpperCamelCase = 2**power __UpperCamelCase = str(_snake_case ) __UpperCamelCase = list(_snake_case ) __UpperCamelCase = 0 for i in list_num: ...
228
"""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 _A = "." # Internal TensorFlow ops tha...
228
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.uti...
11
import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis_float32 (there's also the fix_lavis branch) # also note: to convert Vicuna checkpoints, we had to include /home/niels/...
472
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING a_ :int = logging.get_logger(__name__) a_ :List[Any] = { """ut/deta""": """https://huggingface.co/ut/deta/resolve/main/config.json""", } class lower...
720
import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline a_ :str = version.parse(version.parse(torch.__version__)....
250
0
'''simple docstring''' from __future__ import annotations def A_ ( _lowerCAmelCase : list[int] , _lowerCAmelCase : list[int] , _lowerCAmelCase : list[int] , _lowerCAmelCase : list[list[str]] , _lowerCAmelCase : int , ): ...
44
"""simple docstring""" import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging __UpperCAmelCase = loggi...
642
0
import random def UpperCAmelCase__ ( lowercase__ , lowercase__ ) -> tuple: __lowercase , __lowercase , __lowercase = [], [], [] for element in data: if element < pivot: less.append(lowercase__ ) elif el...
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
'''simple docstring''' from collections import deque from .hash_table import HashTable class SCREAMING_SNAKE_CASE ( __A ): """simple docstring""" def __init__( self : Tuple , *UpperCamelCase__ : List[Any] , **UpperCamelCase__ : Dict ...
430
'''simple docstring''' def lowercase_ ( __A : int ) -> int: """simple docstring""" if n == 1 or not isinstance(__A , __A ): return 0 elif n == 2: return 1 else: lowercase : Tuple =[0, 1] for i in range(2 , n + 1 ): seq...
94
0
'''simple docstring''' import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mode...
79
'''simple docstring''' def __A ( lowerCamelCase_ ): """simple docstring""" return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def __A ( lowerCamelCase_ ): """simple docstring""" SCREAMING_SNAKE_CASE : Optional[Any] = 0 SCREAMING_SNAKE_CASE : ...
79
1
"""simple docstring""" import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedC...
581
"""simple docstring""" import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, ...
58
0
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def _snake_case ( A , A , A , A , A = None , A = None , A = None...
700
'''simple docstring''' import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transforme...
98
0
'''simple docstring''' def a_ ( _UpperCAmelCase : str ) -> List[Any]: __snake_case : Dict = [0] * len(SCREAMING_SNAKE_CASE__ ) for i in range(1 ,len(SCREAMING_SNAKE_CASE__ ) ): # use last results for better performance - dynamic programming...
286
"""simple docstring""" from __future__ import annotations from dataclasses import dataclass @dataclass class __lowercase : """simple docstring""" _A : float _A : TreeNode | None = None _A : TreeNode | None = None def SCREA...
480
0
"""simple docstring""" from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def A_ (__a , __a , __a , __a , ): '''simple docstring''' A_ = coefficient_matrix.shape A_ = constant_matri...
711
"""simple docstring""" 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 UpperCamelCase_ : Optional[Any] = '''src/tran...
482
0
"""simple docstring""" from copy import deepcopy class __a : def __init__( self : str , UpperCAmelCase_ : List[str] = None , UpperCAmelCase_ : Optional[Any] = None )-> Any: """simple docstring""" if arr ...
554
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.dat...
180
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicab...
585
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def _a ( __SCREAMING_SNAKE_CASE : Optional[Any] ...
585
1
"""simple docstring""" import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def snake_case ( _a: Dict , _a: Any , _a: Union[str, Any] , _...
510
"""simple docstring""" def snake_case ( _a: list )-> bool: '''simple docstring''' if not isinstance(_a , _a ): raise ValueError('Input series is not valid, valid series - [2, 4, 6]' ) if len(_a ) == 0: raise ValueError('Input list must...
510
1
"""simple docstring""" class snake_case : def __init__( self : int , a__ : int ) -> Optional[int]: '''simple docstring''' _A = n _A = [None] * self.n _A = 0 # index of...
621
"""simple docstring""" def a__ ( __lowercase , __lowercase , __lowercase , __lowercase ) -> str: # Return True if there is node that has not iterated. _A = [False] * len(__lowercase ) _A = [] queue.append(__lowercase ) _A = True...
621
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowercase : int = logging.get_logger(__name__) __lowercase : Union[str, Any] = { ...
476
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __lowercase : List[str] = { 'configuration_convnext': ['CONVNEXT_PRETRAINED_CONFIG_ARCHIVE...
476
1
import datasets from .evaluate import evaluate lowerCAmelCase__ = """\ @inproceedings{Rajpurkar2016SQuAD10, title={SQuAD: 100, 000+ Questions for Machine Comprehension of Text}, author={Pranav Rajpurkar and Jian Zhang and Konstantin Lopyrev and Percy Liang}, booktitle={EMNLP}, year={2016} } """ lowerCA...
716
import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_params import UNCONDITION...
626
0
"""simple docstring""" import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class UpperCamelCase_ ( a_ ): @require_torch def UpperCamelCase_ ( self ) ->...
673
"""simple docstring""" import math def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' return math.sqrt(lowerCAmelCase ) * math.sqrt(lowerCAmelCase ) == num def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' ...
673
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig class a__ ( __A ): """simple docstring""" __UpperCamelCase : Optional[int] = 'bert-generation' def __init__(self , __lowercase=5_03_58 , __lowercase=10_24...
474
'''simple docstring''' from manim import * class a__ ( __A ): """simple docstring""" def _snake_case (self ): __lowerCAmelCase = Rectangle(height=0.5 , width=0.5 ) __lowerCAmelCase = Rectangle...
474
1
"""simple docstring""" import os def __magic_name__ ( __snake_case : str = "matrix.txt" ) -> int: with open(os.path.join(os.path.dirname(__snake_case ) , __snake_case ) ) as in_file: lowercase : Optional[Any] = in_f...
361
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a__ = logging.get_logger(__name__) a__ = { """microsoft/wavlm-base""": """https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json""", # See all WavLM models at https://...
654
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class snake_case__ ( unittest...
710
"""simple docstring""" import heapq import sys import numpy as np SCREAMING_SNAKE_CASE__:Optional[int] = tuple[int, int] class snake_case__ : def __init__( self ): __a = [] __a = set() def a__ ( self ): if not self.empty(): retu...
67
0
'''simple docstring''' import operator as op def _a (__SCREAMING_SNAKE_CASE ): """simple docstring""" _UpperCamelCase =[] _UpperCamelCase =lambda __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE : int(x / y ) # noqa: E731 integer division operation _UpperCamelCa...
404
'''simple docstring''' import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class UpperCAmelCase ( lowercase_): """simple docstring""" lowerCAmelCase_ = (UnCLIPScheduler,) def UpperCamelCase__ ( self : ...
404
1
UpperCamelCase = { "meter": "m", "kilometer": "km", "megametre": "Mm", "gigametre": "Gm", "terametre": "Tm", "petametre": "Pm", "exametre": "Em", "zettametre": "Zm", "yottametre": "Ym", } # Exponent of the factor(meter) UpperCamelCase = { "m": 0, "km": 3, "Mm...
677
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 = { "configuration_clip": [ "CLIP_PRETRAINED_CO...
677
1
from math import isqrt def UpperCAmelCase ( a_ ) -> list[int]: """simple docstring""" __A = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , a_ , a_ ): ...
55
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer A__ = logging.get_logger(__name__) A__ = {'''v...
252
0
'''simple docstring''' import unittest import numpy as np import timeout_decorator # noqa from transformers import BlenderbotSmallConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...generation.test_flax_utils import FlaxGenerationTesterMixin from ...test_modeling_fl...
719
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils im...
195
0
def _SCREAMING_SNAKE_CASE ( __lowercase : Any , __lowercase : List[str] , __lowercase : Optional[Any] , __lowercase : int ) -> int: """simple docstring""" __A = len(snake_case__ ), len(grid[0] ) if ( m...
637
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_tens...
382
0
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_bac...
701
def UpperCamelCase_ ( __a ) -> int: if not isinstance(__a , __a ): raise TypeError("only integers accepted as input" ) else: a__ : Union[str, Any] = str(abs(__a ) ) a__ : Dict = [list(__a ) for char in rang...
151
0
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> Dict: if not is_accelerate_available(): return method snake_case__ = version.parse(...
33
from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE : Optional[int] = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MC...
197
0
from __future__ import annotations def _lowerCamelCase ( a_ : list[int]): # This function is recursive lowerCamelCase :Union[str, Any] = len(a_) # If the array contains only one element, we return it (it's the stop condition of # recursion) if array_length <= 1: ...
49
import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.utils import wr...
49
1
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.kandinsky.text_en...
1
import numpy as np def __lowerCAmelCase ( _A ,_A ,_A = 1E-12 ,_A = 100 ,): """simple docstring""" assert np.shape(_A )[0] == np.shape(_A )[1] # Ensure proper dimensionality. assert np.shape(_A )[0] == np.shape(_A )[0] # Ensure inputs ...
398
0
from datetime import datetime import requests def snake_case_ ( lowerCAmelCase_ : str ): __lowercase : Any = """https://downloadgram.net/wp-json/wppress/video-downloader/video?url=""" __lowercase : Dict = requests.get(base_url + url ...
709
from __future__ import annotations def snake_case_ ( lowerCAmelCase_ : str , lowerCAmelCase_ : list[str] | None = None ): __lowercase : Tuple = word_bank or [] # create a table __lowercase : int = len(lower...
649
0
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def a__ ( _SCREAMING_SNAKE_CASE : Optional[int] ...
71
'''simple docstring''' from ..utils import DummyObject, requires_backends class _snake_case (metaclass=__SCREAMING_SNAKE_CASE): __A : Any =["speech"] def __init__( self ,*_snake_case ,**_snake_case ): requires_backends(self ,["speech"] ) class _s...
71
1
def _UpperCamelCase (a__ :Optional[int] , a__ :int ): """simple docstring""" return "\n".join( f"""{number} * {i} = {number * i}""" for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(numb...
706
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": UpperCamelCase__ = argparse.ArgumentParser() parser.add_argument("--dump_path", default=None, type=str, ...
548
0
'''simple docstring''' import heapq as hq import math from collections.abc import Iterator class __snake_case : '''simple docstring''' def __init__( self , __SCREAMING_SNAKE_CASE ): snake_case__ : List[Any] = str(id_ ) snake_case__ : Dict...
38
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class _snake_case ( lowercase__): UpperCamelC...
413
0
import string from math import logaa def a(lowercase__ , lowercase__ ): '''simple docstring''' snake_case_ = document.translate( str.maketrans('' , '' , string.punctuation ) ).replace('\n' , '' ) snake_case_ = document_without_punctuation.split(' ' ) # word tokenization retur...
46
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow from ..test_modeling_t...
46
1
import math def lowerCamelCase_(lowerCamelCase_ , lowerCamelCase_ ) -> float: if ( not isinstance(lowerCamelCase_ , (int, float) ) or power_factor < -1 or power_factor > 1 ): raise ValueError("power_factor must be a valid float value be...
323
# 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 required by ...
323
1
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, require_flax if is_flax_available(): impo...
670
class _UpperCamelCase : '''simple docstring''' def __init__( self : List[str] , snake_case_ : int , snake_case_ : Optional[Any]=None , snake_case_ : List[str]=None ): UpperCamelCase_: List[Any] = data UpperCamelCase_: ...
670
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE : int = { "configuration_tapas": ["TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP", "TapasConfig"], "tokenization_tapas": ["TapasTokenizer"], }...
635
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging ...
635
1
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer lowerCamelCase = logging.get_logger(__name__) lowerCamelC...
207
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCamelCase = { """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoderConfig""", """VisionEncoderDecoderO...
207
1
from __future__ import annotations from PIL import Image # Define glider example UpperCamelCase = [ [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, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0...
45
import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels _A : Optional[int] = object() # For specifying empty leaf dict `{}` _A : Tuple = object() def __snake_case...
100
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE = { "configuration_lxmert": ["LXMERT_PRETRAINED_CONFIG_ARCHIVE_MAP",...
489
'''simple docstring''' from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import f...
489
1
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.kandinsky.text_encoder import...
9
'''simple docstring''' from functools import lru_cache @lru_cache def _UpperCamelCase ( UpperCamelCase__ ): if num < 0: raise ValueError("""Number should not be negative.""" ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name_...
407
0
def _lowercase ( ) -> Tuple: lowerCamelCase =0 for i in range(1 , 10_01 ): total += i**i return str(_UpperCAmelCase )[-10:] if __name__ == "__main__": print(solution())
269
from abc import ABC, abstractmethod from argparse import ArgumentParser class __A ( a ): @staticmethod @abstractmethod def _snake_case ( UpperCAmelCase_ ): raise NotImplementedError() @abstractmethod def _snake_case ( self ): rai...
269
1
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transform...
88
import os from datetime import datetime as dt from github import Github lowercase__ =[ 'good first issue', 'feature request', 'wip', ] def __UpperCamelCase ( ): __a : int = Github(os.environ['''GITHUB_TOKEN'''] ) __a : Dict = g.get_rep...
521
0
from packaging import version from .import_utils import is_accelerate_available if is_accelerate_available(): import accelerate def lowerCamelCase_ ( UpperCAmelCase_ : Any ) -> List[Any]: '''simple docstring''' if not is_accelerate_available(): return metho...
706
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testing_utils import require_tensorflow_text, require...
648
0
def lowerCamelCase__ ( __lowerCamelCase : int ): if not isinstance(__lowerCamelCase , __lowerCamelCase ): __UpperCAmelCase : Tuple = f"""Input value of [number={number}] must be an integer""" raise TypeError(__lowerCamelCase ) if numb...
63
from math import loga def lowerCamelCase__ ( __lowerCAmelCase : int ): """simple docstring""" if a < 0: raise ValueError("Input value must be a positive integer" ) elif isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError("Inp...
290
0
"""simple docstring""" class __magic_name__ : def __init__( self ): """simple docstring""" _lowerCAmelCase = """""" _lowerCAmelCase = """""" _lowerCAmelCase = [] def _lowerCamelCase ( self , __ma...
720
"""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
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase : Union[str, Any] = logging.get_logger(__name__) lowerCAmelCase : Dict ...
372
def lowerCamelCase_ ( ): _a : Optional[int] = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] _a : Dict = 6 _a : Any = 1 _a : Union[str, Any] = 1901 _a : Tuple = 0 while year < 2001: day += 7 ...
471
0
'''simple docstring''' import fire from utils import calculate_rouge, save_json def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase=None , **_lowerCAmelCase ): """simple docstring""" UpperCAmelCase = [x.strip() for x in open(_lowerCamelCase...
717
from collections import Counter from timeit import timeit def __UpperCamelCase ( _lowerCAmelCase = "" , ): """simple docstring""" return sum(c % 2 for c in Counter(input_str.replace(" " , "" ).lower() ).values() ) < 2 def __UpperCamelCase ( _lowerCAmelCase = "" ): ...
405
0
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: Optional[Any] ) -> str: _UpperCAmelCas...
300
import argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: Dict , lowerCAmelCase: Any , lowerCAmelCase: Optional[Any] , lowerCAmelCase: Any ) -> int: _UpperCAmelCase : Optional[int] ...
300
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _a : Tuple= {"configuration_swin": ["SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwinConfig", "SwinOnnxConfig"]} try: if no...
702
"""simple docstring""" import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): _a : List[str]= yaml.safe_load( "\\nname: \"\"\nallow_empty: false\nallow_empty_text: ...
192
0
import functools def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: list[int] , UpperCamelCase__: list[int] ): # Validation if not isinstance(UpperCamelCase__ , UpperCamelCase__ ) or not all(isinstance(UpperCamelCase__ , UpperCamelCase__ ) for day in days ...
6
"""simple docstring""" from __future__ import annotations from collections.abc import Sequence from typing import Literal def __UpperCamelCase ( snake_case__ , snake_case__ ): A_ : Optional[int] = list(snake_case__ ) A_ : List[Any] = list(snake_case__ ...
180
0
"""simple docstring""" import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax ...
317
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale...
317
1
from math import pow def a__ ( A__, A__, A__, A__, A__, ): if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. solutions_count += 1 return current_sum, solutions_count SCREAMING_SN...
101
def lowerCamelCase_ ( __UpperCamelCase , __UpperCamelCase ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) A_ = str(bin(__UpperCamelCase ) )[2:] # remove the leading "0b" A_ = str(bin(__UpperCamelCase ) )[2:] ...
141
0
from collections import Counter from timeit import timeit def A_ ( snake_case : str = "" , ) -> bool: '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def A_ ( snake_case : str ...
451
from collections import Counter from timeit import timeit def A_ ( snake_case : str = "" , ) -> bool: '''simple docstring''' return sum(c % 2 for c in Counter(input_str.replace(''' ''' , '''''' ).lower() ).values() ) < 2 def A_ ( snake_case : str ...
451
1
"""simple docstring""" import os def _lowerCamelCase ( __a = "matrix.txt" ): with open(os.path.join(os.path.dirname(__a ), __a ) ) as in_file: SCREAMING_SNAKE_CASE_ = in_file.read() SCREAMING_SNAKE_CASE_ = [[int(__a ) for cell in row.split(''',''' )...
626
"""simple docstring""" import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class snake_case ( __lowercase , ...
626
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeling_roberta_series import ( ...
583
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { "huggingface/time-series-transformer-tourism-monthly": ( "https://huggingface.co/huggingface/time-s...
583
1
def A ( _SCREAMING_SNAKE_CASE ) -> bool: if not isinstance(_SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ): raise ValueError("check_bouncy() accepts only integer arguments" ) lowerCamelCase : Optional[int] = str(_SCREAMING_SNAKE_CASE ...
311
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 SCREAMING_SNAKE_CASE__ : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_...
311
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { 'microsoft/markuplm-base': 'https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json', 'microsoft/ma...
706
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGen...
534
0
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Union[str, Any] = logging.get_logger(__name__) __UpperCamelCase : Dict = { '''microsoft/unispeech-sat-base...
4
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase_ = { 'configuration_nezha': ['NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NezhaConfig'], } try: if not is_torch_availabl...
173
0
"""simple docstring""" import math def a__ ( __lowercase , __lowercase ) -> int: _A = len(__lowercase ) _A = int(math.floor(math.sqrt(__lowercase ) ) ) _A = 0 while arr[min(__lowercase , __lowercase ) - 1] < x: ...
621
"""simple docstring""" import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": a_ = argparse.ArgumentParser( description=( "Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for...
621
1
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, EfficientFormerIm...
562
import inspect import os import re from transformers.configuration_utils import PretrainedConfig 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 lowercase_ ...
562
1
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 transformer...
129
import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def __lowerCamelCase ( _lowerCAmelCase ...
129
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, Di...
226
def __lowerCAmelCase ( __magic_name__ = 5_0 ): _lowercase: Union[str, Any] = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for block_start in range(row_length - block_length ): ways_number[r...
226
1
import copy from typing import Dict, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING from ..detr import DetrConfig from ..swin import SwinConfig snake_case_ : Tuple ={ '''facebook/maskformer-swin-b...
205
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time snake_case_ : Optional[Any] =Lock() def UpperCAmelCase ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase_...
205
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tensorflow_text_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _lowerCamelCase : Union[str, Any] = { '''configura...
686
import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def a_ ( __lowercase : Any ) -> List[An...
686
1
from typing import Any class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self : Union[str, Any] , lowerCamelCase : Any ) -> str: """simple docstring""" _UpperCAmelCase = data _UpperCAmelCase = None class SCREAMI...
402
from ...configuration_utils import PretrainedConfig from ...utils import logging __a: Any = logging.get_logger(__name__) __a: int = { '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/resolve/main/config.json''', } class SCREAMING_SNAKE_CASE__ ( UpperC...
402
1
from __future__ import annotations import unittest from transformers import 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 from ...test_pi...
654
from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, 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 C...
654
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) snake_case = { '''configuration_perceiver''': ['''PER...
700
"""simple docstring""" def snake_case ( lowerCAmelCase_ , lowerCAmelCase_ ) -> bool: return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
404
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _snake_case ( UpperCAmelCase_ ): __lowerCAmelCase : Union[str, Any] = ['image_processor', 'tokenizer'] __lowerCAmelCase : Union[str, Any] = 'CLIPImagePr...
12
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def lowercase_ ( __snake_case : Any ) -> List[Any]: '''simple docstring''' if "model" in orig_key: snake_case__ :Any = orig_key.replace("model."...
241
0
"""simple docstring""" __magic_name__ = { """a""": """AAAAA""", """b""": """AAAAB""", """c""": """AAABA""", """d""": """AAABB""", """e""": """AABAA""", """f""": """AABAB""", """g""": """AABBA""", """h""": """AABBB""", """i""": """ABAAA""", """j""": """BBBAA""",...
258
"""simple docstring""" from itertools import count def _A ( __lowercase = 50 ): """simple docstring""" lowerCamelCase__ = [1] * min_block_length for n in count(__lowercase ): fill_count_functions.append(1 ) for block_l...
258
1
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, ) _SCREAMING_SNAKE_CASE = { """iou_prediction_h...
537
"""simple docstring""" __lowercase : Union[str, Any] = { """meter""": """m""", """kilometer""": """km""", """megametre""": """Mm""", """gigametre""": """Gm""", """terametre""": """Tm""", """petametre""": """Pm""", """exametre""": """Em""", """zettametre""": """Z...
142
0
'''simple docstring''' from collections.abc import Generator from math import sin def __snake_case ( UpperCAmelCase_ : bytes ): if len(a_ ) != 32: raise ValueError("Input must be of length 32" ) lowerCamelCase_ = B'''''' for i in [3, 2, 1, 0]: little_end...
718
'''simple docstring''' import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Con...
445
0
'''simple docstring''' import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# lowerCAmelCase__ = [ # (stable-diffusion, HF Diffusers) ('''time_embed.0.weight''', '''time_em...
41
'''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 trans...
41
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __magic_name__ = { '''configuration_bloom''': ['''BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BloomConfig''', '''BloomOnnxConfig'''], } try: if not is_to...
718
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 import TokenizerTest...
530
0
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, ...
254
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer __magic_name__ = logging.get_logger(__name__) __magic_name__ = ...
254
1
import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging ...
643
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter __UpperCAmelCase : List[An...
643
1
import math def _UpperCAmelCase (UpperCamelCase_ : float , UpperCamelCase_ : float ): '''simple docstring''' if initial_intensity < 0: raise ValueError("""The value of intensity cannot be negative""" ) # handling of negative values of initial intensity ...
429
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class __snake_case : lowerCAmelCase__ = 42 lowerCAmelCase__ = None ...
429
1
'''simple docstring''' from __future__ import annotations def _lowerCamelCase ( _a , _a ): """simple docstring""" _lowerCamelCase = get_failure_array(_a ) # 2) Step through text searching for pattern _lowerCamelCase , _lowerCamelCase = 0, 0 # i...
712
import heapq def _lowerCamelCase ( _a ): """simple docstring""" _lowerCamelCase = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works with a min priority queue, s...
297
0
from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusionScheduler from ...uti...
619
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) d...
619
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available a__ : str ={ '''configuration_longt5''': ['''LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''LongT5Config''', '''LongT5OnnxConfig'''], }...
702
'''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 ...
434
0