code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' from torch import nn def __snake_case ( UpperCAmelCase_ : Union[str, Any] ): if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(F'''Unsu...
55
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def a__ ( ) -> tuple[list[int], int]: UpperCAmelCase : str = [randint(-1_000 , 1_000 ) for i in range(10 )] UpperCAmelCase : Any = randint(-5_...
336
0
from math import ceil def UpperCamelCase_( _snake_case : int , _snake_case : Any ): """simple docstring""" __a =list(range(0 , _snake_case ) ) __a =[item for sublist in list(device_map.values() ) for item in sublis...
308
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCAmelCase : Any = logging.get_logger(__name__) _lowerCAmelCase : int = { "caidas/swin2sr-classicalsr-x2-64": ( "https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/resolve/...
308
1
import json import os import unittest from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class lowerCamelCase_ ( UpperCAmelCase_ , unittest.TestCase ): '''simple docstring''' a__ : ...
43
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_available,...
43
1
'''simple docstring''' import sys import turtle def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase ) -> tuple[float, float]: return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCa...
129
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> List[Any]: if "cls_token" in name: ...
129
1
def _a ( SCREAMING_SNAKE_CASE_ : list[int] , SCREAMING_SNAKE_CASE_ : int ): __lowerCAmelCase = len(SCREAMING_SNAKE_CASE_ ) __lowerCAmelCase = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, ...
92
def _a ( SCREAMING_SNAKE_CASE_ : int = 1_00_00_00 ): __lowerCAmelCase = [i - 1 for i in range(limit + 1 )] for i in range(2 , limit + 1 ): if phi[i] == i - 1: for j in range(2 * i , limit + 1 , SCREAMING_S...
92
1
'''simple docstring''' import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import Acce...
311
'''simple docstring''' import argparse import importlib from pathlib import Path # Test all the extensions added in the setup lowercase : Optional[int] = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/...
311
1
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 Conversation __A = logging...
10
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils...
280
0
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoT...
366
"""simple docstring""" import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def _lowerCAmelCas...
181
0
from math import factorial def snake_case( __magic_name__ = 1_00 ) -> int: '''simple docstring''' return sum(int(__magic_name__ ) for x in str(factorial(__magic_name__ ) ) ) if __name__ == "__main__": print(solution(int(input('Enter th...
308
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase_ = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ], } tr...
308
1
"""simple docstring""" import unittest from transformers import MraConfig, 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, floats_tensor, ids_tensor, r...
357
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import ...
154
0
def lowerCAmelCase__ ( lowerCamelCase_ : list): '''simple docstring''' lowerCAmelCase__ : int = False while is_sorted is False: # Until all the indices are traversed keep looping lowerCAmelCase__ : Dict = True for i in range(0 ...
129
from jiwer import compute_measures import datasets __snake_case : Dict ='\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER and WIL: improved evaluation mea...
129
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ ...
358
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING lowerCamelCase_ : int = logging.get_logger(__name__) class __A ( _SCREAMING_...
215
0
'''simple docstring''' import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class UpperCamelCase__ ( lowercase__ ): """simple docstring""" SCREAMING_SNAKE_CASE__ : Optional[int] = "M-CLIP" def __init__( self , snake_case=1_0_2_4 , ...
311
'''simple docstring''' import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_com...
311
1
'''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, PixaStructProcessor, Pi...
136
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, ...
136
1
"""simple docstring""" def _lowerCAmelCase ( lowercase_ , lowercase_ ): UpperCAmelCase = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): UpperCAmelCase = n - k # Calculate C(n,k) for i in ran...
78
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> int: UpperCAmelCase__ : Tuple = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def a__ ( lowerCAmelCase__ = 1_00 ) -> int: Up...
181
0
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_...
363
def SCREAMING_SNAKE_CASE_ ( __A : list ) -> list: """simple docstring""" a_ : int = len(__A ) for _ in range(__A ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + 1] < arr[i]: ...
120
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor A__ : Dict =logging.get_logger(__name__) class UpperCAmelCase ( snake_case_ ): def __init__( self : Optional[Any] ...
70
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _SCREAMING_SNAKE_CASE ( lowerCAmelCase__): _UpperCamelCase:Optional[int] = ["image_processor", "tokenizer"] _UpperCamelCase:Tuple = "ChineseCLIPImageProce...
154
0
"""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 = logging.get_logger(__name__)...
212
"""simple docstring""" import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class _lowerCamelCase ( unittest.TestCase ): def _lowerCAmelCase ( self : Dict ) -> None: """simple d...
212
1
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller lowercase : Union[str, Any] = 3 def lowerCAmelCase_ ( snake_case__ ): '''simple docstring''' print('''Gene...
3
'''simple docstring''' from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def snake_case_ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ = False )-> list[float]: '''simple docstrin...
215
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer _SCREAMING_SNAKE_CASE = {"vocab_file": "vocab.txt", "tokenizer_file": "tokenizer.json"} _SCREAMING_S...
357
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model from transformers.util...
165
0
"""simple docstring""" import argparse import collections import json import os import re import string import sys import numpy as np UpperCAmelCase : Union[str, Any] = re.compile(r"\b(a|an|the)\b", re.UNICODE) UpperCAmelCase : Optional[Any] = None def _SCREAMING_...
136
"""simple docstring""" import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder UpperCAmelCase : Union[str, Any] = "__DUMMY_TRANSFORMERS_USER__" UpperCAmelCase : Dict = "Dummy...
136
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) A : Dict = { 'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_CONFIG_...
33
import logging from transformers.configuration_utils import PretrainedConfig A : Union[str, Any] = logging.getLogger(__name__) class __A( a ): snake_case_ = '''masked_bert''' def __init__( self , _snake_case=30_522 , _snake_case=768 , ...
33
1
import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ...
10
'''simple docstring''' from sklearn.metrics import recall_score import datasets __A : Dict = "\nRecall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:\nRecall = TP / (TP + FN)\nWhere TP is...
120
0
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( unittest.TestCas...
208
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for...
208
1
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> str: return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
212
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=__magic_name__ ) class A__ ( __magic_name__ ): lowercase = field(default='audio-cl...
212
1
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 logging __snake_case :Tuple = logging.get_logger(__name__) __snake_case ...
131
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): def get_matched_characters(_UpperCAmelCase , _UpperCAmelCase ) -> str: __a = [] __a = min(len(_stra ) , len(_stra ) ) // 2 for i, l in enumerate(_stra ): ...
131
1
import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transformers.mod...
92
"""simple docstring""" from dataclasses import dataclass, field from typing import Optional @dataclass class lowerCamelCase : lowerCamelCase__ : Optional[str] = field( default='codeparrot/codeparrot' ,metadata={'help': 'Model name or path of model to...
165
0
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def snake_case_ ( *snake_case , snake_case = None , snake_case=True , snake_case=2 ) -> List[Any]: from .. import __version__ ...
288
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 GenerationTesterMixin from ...
288
1
"""simple docstring""" from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def lowercase ( ): lowercase_ : Union[str, Any] = { '''repo_name''': ['''test_repo1''', ''...
33
"""simple docstring""" def lowercase ( __snake_case : int ): if not isinstance(__snake_case , __snake_case ): raise ValueError('''Input must be an integer''' ) if input_num <= 0: raise ValueError('''Input must be positive''' ) return sum( divisor for di...
33
1
_snake_case = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def _A ( __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ ): # Return True if there is node that has ...
363
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, ...
201
0
'''simple docstring''' import inspect import unittest from transformers import MobileNetVaConfig 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_confi...
208
'''simple docstring''' from collections.abc import Sequence def a_ ( _lowerCAmelCase ,_lowerCAmelCase ) -> float: return sum(c * (x**i) for i, c in enumerate(_lowerCAmelCase ) ) def a_ ( _lowerCAmelCase ,_lowerCAmelCas...
208
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase = { '''configuration_mgp_str''': ['''MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MgpstrConfig'''], '''processing_mgp_str''': ['''Mgp...
370
"""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 import Mvp...
312
0
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 lowerCamelCase = logging.get_logger(__name_...
131
import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common impor...
131
1
"""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_mod...
371
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImage...
108
0
"""simple docstring""" from __future__ import annotations import math def _UpperCAmelCase ( __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : bool , __lowerCamelCase : list[int] , __lowerCamelCase : float ) -> int...
288
"""simple docstring""" import argparse import torch from transformers import BertForMaskedLM if __name__ == "__main__": UpperCAmelCase__ = argparse.ArgumentParser( description=( 'Extraction some layers of the full BertForMaskedLM or RObertaForMaskedLM for Transfer Learned'...
288
1
from __future__ import annotations def A_ ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: Dict = list(range(len(_UpperCAmelCase ) ) ) SCREAMING_SNAKE_CASE_: Any = [v / w for v, w in zip(_UpperCAmelCase , _...
356
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class __lowercase ( tf.keras.optimizers.schedules.LearningRateSchedule ): "...
127
0
import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor UpperCAmelCase__ = logging.get_logger(__name__) class __lowerCAmelCase ( __lowerCamelCase ): def __init__( self : Dict , *A : Optional[int] , **A : List[str]) -> ...
339
def lowerCAmelCase_ ( __UpperCAmelCase: int ) -> bool: return str(__UpperCAmelCase ) == str(__UpperCAmelCase )[::-1] def lowerCAmelCase_ ( __UpperCAmelCase: int ) -> int: return int(__UpperCAmelCase ) + int(str(__UpperCAmelCase )[::-...
201
0
'''simple docstring''' _SCREAMING_SNAKE_CASE = "0.18.2" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, i...
368
'''simple docstring''' _SCREAMING_SNAKE_CASE = {"a": ["c", "b"], "b": ["d", "e"], "c": [], "d": [], "e": []} _SCREAMING_SNAKE_CASE = ["a", "b", "c", "d", "e"] def __lowerCamelCase ( __lowerCAmelCase : List[Any] , __lowerCAmelCase : str , __...
3
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) UpperCAmelCase : str = {'configuration_beit': ['BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BeitConfig', 'BeitOnnxConfi...
280
import cva import numpy as np class _a : """simple docstring""" def __init__( self : Any , UpperCAmelCase : float , UpperCAmelCase : int ): if k in (0.04, 0.06): A_ = k A_ ...
312
0
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. snake_case__ = 2_00 # Number of elements selected in every generation of evolution. The selection takes # place from best to...
4
'''simple docstring''' from collections.abc import Sequence def snake_case__ ( lowerCamelCase__ : Sequence[float] , lowerCamelCase__ : bool = False ) -> float: if not arr: return 0 A_ : Union[str, Any] = 0 if allow_empt...
4
1
"""simple docstring""" import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, ...
84
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ ...
108
0
'''simple docstring''' import re import string import numpy as np import datasets _lowercase = """ Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. """ _lowercase = """ Args: predictions: List of ...
229
'''simple docstring''' 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 VQDiffusion...
229
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase : Optional[Any] = logging.get_logger(__name__) lowercase : List[str] = { "facebook/xlm...
20
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached...
127
0
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformer...
358
class SCREAMING_SNAKE_CASE__ : def __init__(self : str , a__ : list ): """simple docstring""" __snake_case = set_counts __snake_case = max(a__ ) __snake_case = len(a__ ) ...
238
0
import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class __snake_case ( unittest.TestCase ): def _SCREAMING_SNAKE_CASE ( self ): ...
20
'''simple docstring''' import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, s...
3
0
import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel from transformers.file_utils...
367
def lowerCamelCase_ ( _a : int , _a : list[int] , _a : int ): '''simple docstring''' def count_of_possible_combinations(_a : int ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_...
59
0
'''simple docstring''' from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. __snake_case =200 # Number of elements selected in every generation of evolution. The selection takes # place from best to wors...
4
'''simple docstring''' from __future__ import annotations from typing import Any class UpperCAmelCase_ : def __init__( self : Optional[int] , UpperCAmelCase__ : int , UpperCAmelCase__ : int , UpperCAmelCase__ : ...
4
1
from itertools import permutations def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : tuple ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False __UpperCamelCase =[7, ...
358
from __future__ import annotations def _UpperCAmelCase ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ): if b == 0: return (1, 0) ((__UpperCamelCase) , (__UpperCamelCase)) =extended_euclid(SCREAMING_SNAKE_CASE__ , a % ...
117
0
'''simple docstring''' from __future__ import annotations import math def UpperCamelCase_ ( snake_case_ : list , snake_case_ : list ) -> list: '''simple docstring''' if len(snake_case_ ) != 2 or len(a[0] ) != 2 or ...
229
'''simple docstring''' import importlib import inspect import json import os import re import shutil import sys from pathlib import Path from typing import Dict, Optional, Union from urllib import request from huggingface_hub import HfFolder, cached_download, hf_hub_download, model_info from packaging i...
229
1
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sentencepiece_available, is_tf...
359
'''simple docstring''' import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def a_ ( _UpperCAmelCase : List[Any] ) -> ...
0
0
"""simple docstring""" import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRo...
46
"""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 ...
238
0
# flake8: noqa # Lint as: python3 __magic_name__: Optional[int] = [ "VerificationMode", "Version", "disable_progress_bar", "enable_progress_bar", "is_progress_bar_enabled", "experimental", ] from .info_utils import VerificationMode from .logging import disable_progress_bar, enable...
363
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, FlaxM...
138
0
from collections.abc import Sequence def _UpperCAmelCase ( snake_case , snake_case ): """simple docstring""" return sum(c * (x**i) for i, c in enumerate(snake_case ) ) def _UpperCAmelCase ( snake_case , snake_case ): """simple docstring""" _l...
82
def UpperCamelCase ( __lowerCamelCase : str , __lowerCamelCase : int ): snake_case : list[list[str]] = [[] for _ in range(__lowerCamelCase )] snake_case : int = key - 1 if key <= 0: raise ValueError("Height o...
59
0
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase_ : Dict = logging.get_logger(__name__) lowerCamelCase_ : int = { """kakaobrain/align-ba...
362
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificat...
197
0
import json import os import re import unicodedata from json.encoder import INFINITY from typing import Any, Dict, List, Optional, Tuple, Union import numpy as np import regex from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...tokenization_utils_base import BatchEncoding from ...utils imp...
99
import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() snake_case__ : Dict = logging.get_logger(__name__) snake_case__ : Optional[Any] ...
117
0
'''simple docstring''' import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging _A : str =logging.get_logger(__name__) class _lowercase : a = None @experimental def SCREAMING_SNAKE_CASE_ (U...
359
'''simple docstring''' from math import asin, atan, cos, radians, sin, sqrt, tan _A : List[str] =637_8137.0 _A : Dict =635_6752.31_4245 _A : int =6_378_137 def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase ...
129
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Optional[int] = logging.get_logger(__name__) UpperCAmelCase_ : Optional[Any] = { 'microsoft/markuplm-base': 'https://huggingface.co/microsoft/markuplm-base/resolve/mai...
32
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def _a ( a :List[Any] ) -> Optional[int]: a = [] ...
0
0
def lowerCAmelCase__ ( UpperCamelCase__ , UpperCamelCase__ ): '''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(...
366
"""simple docstring""" from __future__ import annotations import time _snake_case = list[tuple[int, int]] _snake_case = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1...
324
0
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : int ): if len(_UpperCAmelCase ) <= 1: return lst A__ = 1 while i < len(_UpperCAmelCase ): if lst[i - 1] <= lst[i]: i += 1 else: ...
335
import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp from digital_image_proces...
138
0
def __lowercase ( _UpperCamelCase ) ->list: """simple docstring""" lowercase : Tuple = int(_UpperCamelCase ) if n_element < 1: lowercase : Any = ValueError('''a should be a positive number''' ) raise m...
173
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...
173
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __a = { 'configuration_data2vec_audio': ['DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Data2VecAudioConfig'], 'configuration_data2vec_text': [ 'D...
30
"""simple docstring""" from ..utils import DummyObject, requires_backends class _A ( metaclass=lowerCAmelCase ): snake_case__ : Optional[int] = ['torch', 'torchsde'] def __init__( self , *__lowerCAmelCase , **__lowerCAmelCase ): ...
197
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device lowerCamelCase_ : Dict = False ...
215
"""simple docstring""" from ...processing_utils import ProcessorMixin class __A ( _SCREAMING_SNAKE_CASE ): """simple docstring""" __lowerCAmelCase = "WhisperFeatureExtractor" __lowerCAmelCase = "WhisperTokenizer" def __init__( self ...
215
1
'''simple docstring''' def a_ ( lowerCamelCase : int = 1000 ): lowerCAmelCase = 1, 1 lowerCAmelCase = [] for i in range(1 , n + 1 ): lowerCAmelCase = prev_numerator + 2 * prev_denominator lowerCAmelCase = prev_numerator + prev_denominator ...
4
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 lowerCAmelCase__ ( lowerCamelCase_ : Optional[Any]): # picklable for multiprocessi...
129
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'shi...
364
"""simple docstring""" import argparse import json import logging import os import shutil import sys import tempfile import unittest from unittest import mock import torch from accelerate.utils import write_basic_config from transformers.testing_utils import TestCasePlus, get_gpu_count, run_command, slow, t...
133
0
from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) lowerCAmelCase_ = _symb...
8
'''simple docstring''' import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_avai...
324
0
def __lowerCamelCase ( __magic_name__ : int ): return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
367
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 __UpperCAmelCase = logging.get_logger(__name__)...
42
0
"""simple docstring""" import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
173
"""simple docstring""" from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test...
173
1
import os def UpperCamelCase ( __lowerCamelCase : int ): snake_case : List[str] = len(grid[0] ) snake_case : List[str] = len(__lowerCamelCase ) snake_case : Dict = 0 snake_case : Any = 0 ...
10
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCamelCase = { """configuration_pix2struct""": [ """PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Pix2StructConfig""", """Pix...
10
1
'''simple docstring''' import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils i...
215
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import Patchi...
215
1
from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowercase( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ = None ) -> str: '''simple docstring''' if version.parse(hfh.__version__ ).release < versio...
165
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def lowercase( UpperCamelCase_ = True , *UpperCamelCase_ , **UpperCamelCase_ ) -> int: '''simple docstring''' if not is_tqdm_available(): ...
165
1
'''simple docstring''' import inspect import os import unittest from pathlib import Path import torch import accelerate from accelerate.test_utils import execute_subprocess_async from accelerate.test_utils.testing import run_command class snake_case ( unittest.TestCase ): ...
55
lowercase_ : Optional[int] = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)] def __SCREAMING_SNAKE_CASE ( snake_case_ ): '''simple docstring''' _UpperCAmelCase = 0 while number: # Increased Speed Slightly by checking eve...
133
0
import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaModel, logging, ) logging.set...
369
import collections import inspect import unittest from transformers import FocalNetConfig 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 BackboneTest...
297
0
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...ut...
308
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __UpperCAmelCase ( tf.keras.layers.Layer ): def __init__( self , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_=1 , ...
42
0
'''simple docstring''' import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ) def lowerCamelCase__ ...
360
'''simple docstring''' lowercase =[0, 2, 4, 6, 8] lowercase =[1, 3, 5, 7, 9] def lowerCamelCase__ ( __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : list[int] , __lowerCamelCase : int ): '''simple docstring''' i...
242
0
import os def lowerCAmelCase_ ( __a ) -> Dict: """simple docstring""" lowerCamelCase__: Union[str, Any] =len(grid[0] ) lowerCamelCase__: List[Any] =len(__a ) lowerCamelCase__: str =0 lowerCamelCase__: Tuple =0 lowerCamelCase__: ...
10
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=__SCREAMING_SNAKE_CASE ) class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): '''simple docstring'...
10
1
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision fro...
357
"""simple docstring""" import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) __magic_name__ = { "sample_size": 32, "in_channels": 3, "out_channels": 3, "layers_per_block": 2, "num_class_embed...
255
0
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMix...
165
"""simple docstring""" import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class lowerCamelCase (nn.Module ): lowerCamelCase__ : int lowerCame...
165
1
"""simple docstring""" import argparse import os import re __UpperCamelCase : List[str] = '''src/diffusers''' # Pattern that looks at the indentation in a line. __UpperCamelCase : int = re.compile(R'''^(\s*)\S''') # Pattern that matches `"key":" and puts `key` in group 0. __Uppe...
361
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCamelCase : Any = { '''configuration_layoutlmv2''': ['''LAYOUTLMV2_PRETR...
309
0
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__=False ) -> Optional[Any]: if isinstance(_A , _A ) and isinstance(_A , _A ): __lowerCamelCase : List[Any] = len(set_a.intersection(_A ) ) if alternative_union: __lowerCamelCas...
73
'''simple docstring''' import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_...
297
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ : Tuple ={'''configuration_sew''': ['''SEW_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SEWConfig''']} try: if not is_torch_available(): raise OptionalDependencyNotA...
118
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase__ : str ={'''configuration_vit_mae''': ['''VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMAEConfig''']} t...
118
1
def _a ( SCREAMING_SNAKE_CASE_ : str = "The quick brown fox jumps over the lazy dog" , ): __lowerCAmelCase = set() # Replace all the whitespace in our sentence __lowerCAmelCase = input_str.replace(" " , "" ) for alpha in input...
92
"""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 import ( ...
242
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __magic_name__: Union[str, Any] = { "configuration_encodec": [ "ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP", "EncodecConfig", ], "feature_...
366
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_xlnet import...
138
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 impo...
298
"""simple docstring""" import math def lowercase__ ( _UpperCAmelCase = 1_00 ) -> int: '''simple docstring''' lowercase : List[str] = sum(i * i for i in range(1 , n + 1 ) ) lowercase : Dict = int(math.pow(sum(range(1 ...
255
0
'''simple docstring''' 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 lowerCAmelCase: List[Any] = object() # For specifying empty leaf dict `{}` lowerCAmelCase: int ...
362
'''simple docstring''' import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, Character...
96
0
import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditionalGeneration, BartTokenize...
240
'''simple docstring''' import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_...
309
0
"""simple docstring""" import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def _a ( *_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = None , _SCREAMING_SNAKE_CASE=True , _SCREAMING_SNAKE_CASE=2 ) -> Dict: from .. import __version...
233
"""simple docstring""" def _a ( _SCREAMING_SNAKE_CASE ) -> list[int]: snake_case_ = len(_SCREAMING_SNAKE_CASE ) for i in range(_SCREAMING_SNAKE_CASE ): for j in range(i + 1 , _SCREAMING_SNAKE_CASE ): if numbers[j] < numbers[i]: ...
233
1
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 OnnxConfigWithPast, PatchingSpec from ...ut...
118
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) A : Optional[int] = l...
118
1
import gc import unittest from parameterized import parameterized from diffusers import FlaxUNetaDConditionModel from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import load_hf_numpy, require_flax, slow if is_flax_available(): import jax import jax.numpy as jn...
93
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class _a ( unittest.TestCase ):...
93
1
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TOKEN,...
156
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.utils import logging logging.se...
138
0
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> Union[str, Any]: lowerCAmelCase__ : Dict = word.split() def justify(SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ) -> str: lowerCAmelCase__ : ...
357
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked bef...
307
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunDiscreteScheduler fro...
99
"""simple docstring""" from __future__ import annotations import math import numpy as np from numpy.linalg import norm def _snake_case ( lowercase__ , lowercase__ ): return math.sqrt(sum(pow(a - b , 2 ) for a, b in zip(lowercase__ , ...
96
0
import re import time from typing import Optional import IPython.display as disp from ..trainer_callback import TrainerCallback from ..trainer_utils import IntervalStrategy, has_length def __snake_case ( _UpperCAmelCase ): __a = int(_UpperCAmelCase ) __a , __a , ...
131
def __snake_case ( _UpperCAmelCase , _UpperCAmelCase ): def get_matched_characters(_UpperCAmelCase , _UpperCAmelCase ) -> str: __a = [] __a = min(len(_stra ) , len(_stra ) ) // 2 for i, l in enumerate(_stra ): ...
131
1
import warnings from ...utils import logging from .image_processing_deit import DeiTImageProcessor lowerCamelCase : int = logging.get_logger(__name__) class lowerCAmelCase ( __a ): '''simple docstring''' def __init__( self : List[str] , *__a : List...
233
lowerCamelCase : Tuple = {'''a''': ['''c''', '''b'''], '''b''': ['''d''', '''e'''], '''c''': [], '''d''': [], '''e''': []} lowerCamelCase : int = ['''a''', '''b''', '''c''', '''d''', '''e'''] def snake_case_ ( lowerCAmelCase_ : Optional[int] , low...
233
1
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def A (__lowerCamelCase :Optional[int] ): _lowerCAmelCase = FileLock(str(tmpdir / """foo.lock""" ) ) _lowerCAmelCase = FileLock(str(tmpdir / """foo.lock""" ) ...
229
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import Fl...
229
1
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer ...
93
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _lowercase : str = lo...
93
1
'''simple docstring''' import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def A (__lowerCamelCase :List[Any] ): _lowerCAmelCase = [ "decoder.version", "decoder.output_projection.weight", ...
363
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase = logging.get_logger(__name__) _lowercase = { """YituTech/conv-bert-base""": """https://hug...
229
0
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : int ) -> int: '''simple docstring''' if not isinstance(__lowercase , __lowercase ) or number < 0: raise ValueError("Input must be a non-negative integer" ) _UpperCAmel...
22
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Dict = { """configuration_jukebox""": [ """JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP""", """JukeboxConfig""", """Jukeb...
307
0
'''simple docstring''' import json from typing import TYPE_CHECKING, 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_...
270
'''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_utils import...
270
1
import argparse import os import re lowerCamelCase = '''src/transformers''' # Pattern that looks at the indentation in a line. lowerCamelCase = re.compile(R'''^(\s*)\S''') # Pattern that matches `"key":" and puts `key` in group 0. lowerCamelCase = re.compile(R'''^\s*"([^"]+)":''') ...
131
import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common impor...
131
1
import argparse UpperCamelCase = '''docs/source/_static/js/custom.js''' def __lowerCamelCase ( snake_case__ ) -> int: """simple docstring""" with open(__lowerCAmelCase ,encoding="""utf-8""" ,newline="""\n""" ) as f: _SCREAM...
353
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_...
125
0