code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, ...
57
import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_single_gpu, ) from accelerate....
57
1
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils ...
525
def __A ( _A ): """simple docstring""" __a = [] for data in source_data: for i, el in enumerate(_A ): if len(_A ) < i + 1: data_lists.append([] ) data_lists[i].append(float(_A ) ) return data_lists def __A ( _A , _A ): ...
525
1
'''simple docstring''' from __future__ import annotations def __lowerCamelCase ( __lowerCAmelCase : list[int] ) -> list[int]: if len(__lowerCAmelCase ) == 0: return array snake_case , snake_case = min(__lowerCAmelCase ), max(__low...
369
'''simple docstring''' from manim import * class _lowerCAmelCase ( A__ ): """simple docstring""" def lowerCAmelCase ( self : Optional[Any] )-> Union[str, Any]: snake_case = Rectangle(height=0.5 , width=0.5 ...
369
1
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 _A = logging.get_logger(__name__) _A = "▁" _A = {"vocab_file": "senten...
705
import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger _A = get_logger(__name__) _A = R"\n Args:\n input_ids (`jnp.ndarray` of shape `(batch_size, sequence_length)`):\n Indices of input...
279
0
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): if number < 0 or shift_amount < 0: raise ValueError('''both inputs must be positive integers''' ) snake_case_ = str(bin(SCREAMING_SNAKE_CASE__ ) ) binary_number += "0" * shi...
39
'''simple docstring''' from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) SCREAMING_SNAKE_CASE_ = 2_99_79_24_58 # Symbols SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ = symbols('...
523
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer lowercase : Dict = {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'} ...
94
from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def _SCREAMING_SNAKE_CASE ( _lowerCamelCase : str) -> None: '''simple docstring''' __UpperCamelCase , __UpperCamelCase : ...
94
1
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_tor...
542
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STANDARD_MEA...
542
1
"""simple docstring""" import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_...
406
"""simple docstring""" import time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging snake_case = logging.get_logger(__name__) snake_case = R'\n Args:\n input_i...
406
1
'''simple docstring''' import re def A_( A : str): if len(re.findall('[ATCG]' , A)) != len(A): raise ValueError('Invalid Strand') return dna.translate(dna.maketrans('ATCG' , 'TAGC')) if __name__ == "__main__": import doctest ...
3
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers im...
556
0
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class _UpperCAmelCase : a = 42 a = None a = None def ...
481
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging logging.set_verb...
481
1
'''simple docstring''' import enum import shutil import sys a__ , a__ : Any = shutil.get_terminal_size() a__ : Optional[int] = {'''UP''': '''A''', '''DOWN''': '''B''', '''RIGHT''': '''C''', '''LEFT''': '''D'''} class __snak...
368
'''simple docstring''' from math import loga def __lowerCamelCase ( UpperCAmelCase_ ) ->int: if a < 0: raise ValueError('Input value must be a positive integer' ) elif isinstance(UpperCAmelCase_ , UpperCAmelCase_ ): raise TypeError('Input value ...
368
1
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch...
703
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 lowerCamelCase ( tf.keras.optimizers.schedules.LearningRateSchedule ): '''...
501
0
# 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 cl...
39
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ ): if any(not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) or x < 0 for x in sequence ): raise TypeError('''Sequence must be list of non-negative integers''' ) for _ in range(len(SCREAMING_SNAKE_CASE_...
39
1
"""simple docstring""" def snake_case_ ( A_ : int ): '''simple docstring''' if divisor % 5 == 0 or divisor % 2 == 0: return 0 _lowerCamelCase : Any = 1 _lowerCamelCase : List[Any] = 1 ...
714
"""simple docstring""" def snake_case_ ( A_ : int ): '''simple docstring''' _lowerCamelCase : list[list[int]] = [[0 for _ in range(A_ )] for _ in range(m + 1 )] for i in range(m + 1 ): _lowerCamelCase : Union[str, Any] ...
598
0
import os from typing import Dict, List, Tuple, TypeVar, Union __lowerCAmelCase : Any = TypeVar("T") __lowerCAmelCase : Dict = Union[List[T], Tuple[T, ...]] __lowerCAmelCase : Optional[Any] = Union[T, List[T], Dict[str, T]] __lowerCAmelCase ...
509
import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def __UpperCAmelCase ( __a : bytes ,__a : int ) -> np.array: """simple docstring""" _a : int = F"""{sampling_rate}""" _...
14
0
'''simple docstring''' import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf ...
35
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule SCREAMING_SNAKE_CASE__ = {'tokenization_wav2vec2_phoneme': ['Wav2Vec2PhonemeCTCTokenizer']} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer ...
35
1
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have ...
33
from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE__ : def __init__( self , a = 6): lowercase__ : Node | None = None lowercase__ : Node | None = None self.create_linked_list(a) def snake_case_ ( self , a)...
164
0
"""simple docstring""" import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeli...
31
"""simple docstring""" 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_...
31
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { """uclanlp/visualbert-vqa""": """https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json""", """ucl...
178
"""simple docstring""" from manim import * class _lowerCAmelCase ( snake_case_ ): def lowerCamelCase ( self ) -> Any: '''simple docstring''' snake_case : List[str] = Rectangle(height=0.5 , width=0.5 ) snake_case ...
178
1
"""simple docstring""" from importlib import import_module from .logging import get_logger A__ : List[Any]= get_logger(__name__) class __lowerCamelCase : def __init__( self , snake_case_ , snake_case_=None ) -> List[str]: UpperCamelCase__ ...
20
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py A__ : Any= """src/diffusers""" # Matches is_xxx_available() A__ : Tuple= re.c...
20
1
import operator as op def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> Dict: _a = [] _a = lambda _UpperCAmelCase , _UpperCAmelCase : int(x / y ) # noqa: E731 integer division operation _a = { '^': op.pow, '*': o...
562
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils import...
562
1
def _SCREAMING_SNAKE_CASE ( snake_case_ : list[list[int]] , snake_case_ : int , snake_case_ : int , snake_case_ : set ): __magic_name__ , __magic_name__ = len(snake_case_ ), len(grid[0] ) if ( min(snake_case_ , snake_case_ ) < 0 or row == row...
678
# Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def _SCREAMING_SNAKE_CASE ( snake_case_ : Tuple , snake_case_ : Union[str, Any] , snake_case_ : List[str] , snake_case_ : Union[str, Any] ): __magic_name__ = { '''en''': '''Machine learni...
678
1
'''simple docstring''' import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency a = { 'E': 12.70, 'T': 9.06, 'A': 8.17, 'O': 7.51, 'I': 6.97, 'N': 6.75, 'S': 6.33, 'H': 6.09, 'R': 5.99, 'D': 4.25, 'L': 4.03, ...
350
from math import loga def SCREAMING_SNAKE_CASE__ ( __lowerCAmelCase ): if a < 0: raise ValueError("Input value must be a positive integer" ) elif isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError("Input value must be a 'int' type" ) return 0...
276
0
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_tf...
701
'''simple docstring''' lowerCAmelCase_ = "Alexander Joslin" import operator as op from .stack import Stack def lowerCAmelCase( a__ : str ): '''simple docstring''' lowerCamelCase__ = {"*": op.mul, "/": op.truediv, "+": op.add, "...
426
0
"""simple docstring""" from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def lowercase ( lowerCAmelCase_...
29
'''simple docstring''' from typing import Callable, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "microsoft/xprophetnet-large-wiki100-cased": ( "https://huggingface.co/microsoft/xprophetnet-large-wiki100-...
42
0
def snake_case_ ( lowerCAmelCase_ : int , lowerCAmelCase_ : int ): return int((input_a, input_a).count(1 ) != 0 ) def snake_case_ ( ): assert or_gate(0 , 0 ) == 0 assert or_gate(0 , 1 ) =...
649
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_configuration_common import ConfigTester from ....
649
1
import argparse import logging import pickle from collections import Counter logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO ) lowerCamelCase__ = logging.getLogger(__name__) if __name__ == "__main__": lowerCamelCase__ ...
612
"""simple docstring""" import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils...
247
0
'''simple docstring''' import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute...
708
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase__( lowerCAmelCase ): __magic_name__ : Tuple = ["image_processor", "tokenizer"] __magic_name__ : Any = "ViT...
50
0
"""simple docstring""" import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowerCAmelCase_ : str = argparse.ArgumentParser('''Stable Diffusion script with intel optimization''', add_help=F...
673
"""simple docstring""" import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, UNetaDConditionModel, VideoToVideoSDPipeline, ) from diffusers.utils import flo...
673
1
'''simple docstring''' # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is tr...
709
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def A__( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): # Initialise PyTorch model ...
652
0
'''simple docstring''' from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _snake_case ( ) -> Tuple: lowerCAmelCase__ = HfArgumentParser(A ) lowerCAmelCase__ = parser.parse_args_into_dataclasses()[0] ...
90
def a_ ( SCREAMING_SNAKE_CASE__ : bytes ): '''simple docstring''' return "".join([hex(SCREAMING_SNAKE_CASE__ )[2:].zfill(2 ).upper() for byte in list(SCREAMING_SNAKE_CASE__ )] ) def a_ ( SCREAMING_SNAKE_CASE__ : str ): '''simple docstring''' if (l...
464
0
'''simple docstring''' from math import factorial lowerCamelCase_ : List[Any] = {str(d): factorial(d) for d in range(10)} def __magic_name__( _A ): '''simple docstring''' return sum(DIGIT_FACTORIAL[d] for d in str(_A ) ) def __magic_name__( ): ''...
265
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_C...
265
1
import random class _a : @staticmethod def __snake_case (SCREAMING_SNAKE_CASE_ ) -> tuple[list[int], list[int]]: UpperCAmelCase_: List[str] = [ord(SCREAMING_SNAKE_CASE_ ) for i in text] UpperCAmelCase_: List[Any] ...
556
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distr...
556
1
from __future__ import annotations import math def _lowerCAmelCase ( _lowerCAmelCase ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of...
481
import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig 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...
481
1
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING lowercase = logging.get_logger(__name__) class __A( _SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE = 'upernet' ...
272
"""simple docstring""" def __a ( a = 6_0_0_8_5_1_4_7_5_1_4_3 ): """simple docstring""" try: _a = int(a ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0...
388
0
import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformer...
712
def lowerCAmelCase( __lowerCamelCase ): __a = len(__lowerCamelCase ) while cur > 1: # Find the maximum number in arr __a = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi __a = arr[mi::-1] + arr[mi + 1 : len(__lowerCa...
246
0
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_available, is_vision_available ...
35
def A__( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): return not any( neighbour == 1 and colored_vertices[i] == color for i, neighbour in enumerate(__lowerCAmelCase ) ) def A__( __lowerCAmelCase , __lowerCAmelCase , ...
304
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCamelCase__ : Optional[int] = {"configuration_ibert": ["IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "IBertConfig", "IBertOnnxConfig"]} try: if not i...
713
'''simple docstring''' # coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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 # ...
178
0
'''simple docstring''' import requests from bsa import BeautifulSoup def _lowerCAmelCase ( __snake_case : str = "AAPL" ) -> str: __A : Optional[Any] = f'https://in.finance.yahoo.com/quote/{symbol}?s={symbol}' __A : Optional[int] =...
8
from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_forma...
461
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase : Optional[int] = { '''configuration_clipseg''': [ '''CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CLIPSegConfig''', '''CLIPSegTextConfig''',...
713
import argparse import gc import json import os 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 Accelerato...
315
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings UpperCamelCase : List[str] = r'\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can...
50
'''simple docstring''' import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention...
526
0
"""simple docstring""" # 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...
244
"""simple docstring""" import jax.numpy as jnp from ...utils import logging from ..ta.modeling_flax_ta import FlaxTaEncoderModel, FlaxTaForConditionalGeneration, FlaxTaModel from .configuration_mta import MTaConfig A__ : Optional[Any] = logging.get_logger(__name__) A__ : Tuple ...
244
1
'''simple docstring''' import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgument...
533
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils impor...
590
0
# We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings("""ignore""", category=UserWarning, module="""torch.optim.lr_scheduler""") class __SCREAMING_SNAKE_CASE ...
365
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/facebook/musicgen-small/resolve/main/compressi...
365
1
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs ...
97
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor __SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) class lowercase_ ( __snake_case ): def __init__( self , *lowercase_ , **lowercase_ ):...
670
0
from __future__ import annotations from math import pow, sqrt def UpperCamelCase (lowercase_: float , lowercase_: float , lowercase_: float ) -> dict[str, float]: if (resistance, reactance, impedance).count(0 ) != 1: raise ValueError("""One and only one argument must be 0...
64
import warnings from ...utils import logging from .image_processing_poolformer import PoolFormerImageProcessor A_ : Union[str, Any] = logging.get_logger(__name__) class _a (__magic_name__ ): '''simple docstring''' def __init__( self , *A__ , **A__ ): ...
64
1
from __future__ import annotations import numpy as np def UpperCamelCase_( lowerCamelCase_ ) -> Optional[int]: return np.maximum(0 , lowerCamelCase_ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
89
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : Any = { "ut/deta": "https://huggingface.co/ut/deta/resolve/main/config....
89
1
from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from ...test...
709
# 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 ap...
353
0
'''simple docstring''' def UpperCamelCase__ ( __SCREAMING_SNAKE_CASE = 200_0000 ) -> List[str]: snake_case__ : Optional[Any] = [0 for i in range(n + 1 )] snake_case__ : List[Any] = 1 snake_case__ : Optional[Any] = 1 fo...
270
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __A : List[Any] = logging.get_logger(__name__) __A : List[Any] ...
275
0
import cva import numpy as np class __SCREAMING_SNAKE_CASE: def __init__( self: Dict , UpperCamelCase: float , UpperCamelCase: int ) -> List[Any]: if k in (0.04, 0.06): snake_case__ = k snake_ca...
718
from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerOutput from diffusers.schedule...
372
0
'''simple docstring''' from __future__ import annotations import math def _UpperCamelCase ( lowerCAmelCase__: int ,lowerCAmelCase__: int ,lowerCAmelCase__: bool ,lowerCAmelCase__: list[int] ,lowerCAmelCase__: float ) -> int: if depth < 0: ...
294
'''simple docstring''' SCREAMING_SNAKE_CASE : Union[str, Any] = 0 # The first color of the flag. SCREAMING_SNAKE_CASE : List[str] = 1 # The second color of the flag. SCREAMING_SNAKE_CASE : Optional[Any] = 2 # The third color of the flag. SCREAMING_SNAKE_CASE ...
294
1
def UpperCAmelCase ( _lowerCamelCase ): return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
17
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class lowerCamelCase_ : '''simple docstring''' ...
17
1
"""simple docstring""" import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisio...
265
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.t...
265
1
__a : int = {str(digit): digit**5 for digit in range(1_0)} def UpperCAmelCase ( lowercase ): """simple docstring""" return sum(DIGITS_FIFTH_POWER[digit] for digit in str(lowercase ) ) def UpperCAmelCase ( ): """simple d...
522
from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, valid_ima...
522
1
'''simple docstring''' lowercase : List[Any] = [ [0, 1_6, 1_3, 0, 0, 0], [0, 0, 1_0, 1_2, 0, 0], [0, 4, 0, 0, 1_4, 0], [0, 0, 9, 0, 0, 2_0], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def __a ( A__ , A__ , A__ , A__ ...
649
'''simple docstring''' from __future__ import annotations def __a ( A__ , A__ = None , A__ = None , A__ = False , ) -> tuple[int, float, str]: lowerCAmelCase = cipher_alphabet or [chr(A__ ) for i in range(97 , 123 ...
649
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ = { "configuration_mobilenet_v2": [ "MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP", "MobileNetV2Config", "MobileNetV2OnnxConfig...
594
from __future__ import annotations from collections import Counter from random import random class _a : """simple docstring""" def __init__( self ): _lowercase ={} def __lowerCAmelCase ( self , lowerCAmelCase_ ): _lowercase ={} def __lowerCAmelCase ( ...
594
1
'''simple docstring''' 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 impor...
22
"""simple docstring""" def snake_case ( _a: int )-> int: '''simple docstring''' if not isinstance(_a , _a ): raise ValueError('Input must be an integer' ) if input_num <= 0: raise ValueError('Input must be positive' ) return sum...
510
0
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def SCREAMING_SNAKE_CASE__ ( _SCREAMING_SNAKE_CASE ): # vision encoder if "img_encoder.pos_embed" in name: lowerCAmelCase...
708
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _snake_case ( lowerCAmel...
305
0
'''simple docstring''' import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAna...
75
"""simple docstring""" import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, ...
49
0
'''simple docstring''' _UpperCAmelCase : Any = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git ''' _UpperC...
717
'''simple docstring''' _UpperCAmelCase : Optional[Any] = '''ABCDEFGHIJKLMNOPQRSTUVWXYZ''' def UpperCamelCase ( ) -> None: '''simple docstring''' lowercase =input('''Enter message: ''' ) lowercase =input('''Enter key [alphanumeric]: ''' ) lowercase =i...
145
0
"""simple docstring""" # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class ...
357
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_roformer import RoFo...
357
1
import mpmath # for roots of unity import numpy as np class snake_case__ : '''simple docstring''' def __init__( self : Optional[Any] , lowerCAmelCase_ : Optional[int]=None , lowerCAmelCase_ : List[Any]=None ) -> List[str]:...
719
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def _lowerCAmelCase ( __magic_name__ :list , __magic_name__ :list , __magic_name__ :list , ...
407
0
'''simple docstring''' def __A ( UpperCAmelCase ,UpperCAmelCase ) -> None: '''simple docstring''' _UpperCamelCase : Optional[int] = len(UpperCAmelCase ) print("The following activities are selected:" ) # The first activ...
435
'''simple docstring''' from __future__ import annotations import time lowerCAmelCase_ : Any = list[tuple[int, int]] lowerCAmelCase_ : List[str] = [ [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,...
435
1
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : int , __lowercase : int ) -> int: '''simple docstring''' return 1 if input_a == input_a else 0 def UpperCAmelCase_ ( ) -> None: '''simple docstring''' assert xnor_gate(0 ...
119
'''simple docstring''' import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNet...
119
1
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): def update_area_of_max_square(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> int: # BASE CASE if row >= rows or col >= cols: return 0 A_ : Tupl...
590
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_...
663
0
'''simple docstring''' import argparse import json import numpy import torch from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def snake_case_ ( _lowerCAm...
528
'''simple docstring''' from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__: Optional[Any] = logging.get_logger(__name__) UpperCamelCase__: Tuple = { "huggingface/t...
528
1
"""simple docstring""" def lowercase__ ( lowerCamelCase : int , lowerCamelCase : int ) -> int: return int(input_a == input_a == 0 ) def lowercase__ ( ) -> None: print("Truth Table of NOR Gate:" ) print("| Input 1 | Input ...
308
import re from filelock import FileLock try: import nltk UpperCamelCase = True except (ImportError, ModuleNotFoundError): UpperCamelCase = False if NLTK_AVAILABLE: with FileLock('.lock') as lock: nltk.download('punkt', quiet=True) def...
269
0
'''simple docstring''' from collections import deque class snake_case : """simple docstring""" def __init__( self : Dict , __A : str , __A : int , __A : int ): __UpperCamelCase = process_name # process name __UpperCamelCase = ...
434
'''simple docstring''' def lowercase__ ( __lowercase : list[int] , __lowercase : list[int] ) -> None: """simple docstring""" __UpperCamelCase = len(__lowercase ) print('The following activities are selected:' ) # The first ac...
434
1
"""simple docstring""" import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging A_ : List[str] = logging.get_logger(__name__) A_ : Optional[Any] = { 'facebook/encodec_24khz': 'https://hugging...
265
"""simple docstring""" import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE__ = logging.getLogger(__...
532
0
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version __lowercase : Tuple = { "<": operator.lt, "<=": operator.le, "==": operator.eq, "!=": operator.ne, ">=": operat...
93
"""simple docstring""" import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_comm...
93
1
from math import sqrt def A ( __UpperCamelCase = 1_000_000 ) -> List[str]: A__ = 0 A__ = 0 A__ = 42 while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_sides in range(2 , 2 * max_cuboid_size + 1 ): if sqrt(sum_short...
9
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available...
70
0
'''simple docstring''' import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import...
666
'''simple docstring''' import sys __lowerCAmelCase = ( '73167176531330624919225119674426574742355349194934' '96983520312774506326239578318016984801869478851843' '85861560789112949495459501737958331952853208805511' '1254069874715852386305071569329096329522...
666
1
"""simple docstring""" 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 ...
49
"""simple docstring""" _snake_case = { 0: '''0''', 1: '''1''', 2: '''2''', 3: '''3''', 4: '''4''', 5: '''5''', 6: '''6''', 7: '''7''', 8: '''8''', 9: '''9''', 1_0: '''a''', 1_1: '''b''', 1_2: '''c''', 1_3: '''d''', 1_4: '''e''...
580
0
"""simple docstring""" import logging import math from functools import partial from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple, Union import torch from .tensor_utils import tensor_tree_map, tree_map def _SCREAMING_SNAKE_CASE ( _lowercase...
717
"""simple docstring""" import baseaa def _SCREAMING_SNAKE_CASE ( _lowercase : str ) ->bytes: '''simple docstring''' return baseaa.aaaencode(string.encode("utf-8" ) ) def _SCREAMING_SNAKE_CASE ( _lowercase : ...
31
0
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( UpperCamelCase : int = 5000_0000 ): A__ = set() A__ = int((limit - 24) ** (1 / 2) ) A__ = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ...
574
"""simple docstring""" import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class _UpperCamelCase ( __snake_case): __lowerCamelCase = "M-CLIP" def __init__(self , lowerCamelCase__=1_0_2_4 , lowerCamel...
574
1
import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn(...
716
def UpperCamelCase__( UpperCamelCase__ : int = 50 )->int: A__ = [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...
212
0
"""simple docstring""" 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_m...
91
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import ...
388
0
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision ...
299
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Imag...
299
1
'''simple docstring''' from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration...
236
'''simple docstring''' import math import tensorflow as tf from packaging import version def UpperCAmelCase_ ( __lowercase : Optional[Any] ) -> List[str]: '''simple docstring''' _UpperCAmelCase = tf.convert_to_tensor(__lowercase ) _UpperCAmelCase = 0.5 *...
236
1
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed fr...
702
"""simple docstring""" def lowerCAmelCase_ ( SCREAMING_SNAKE_CASE__ = 10, SCREAMING_SNAKE_CASE__ = 1_000, SCREAMING_SNAKE_CASE__ = True ) -> int: assert ( isinstance(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__ ) and isinstance(SCREAMING_SNAKE_CASE__, SCREAMING_SNAKE_CASE__ ...
370
0
"""simple docstring""" import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_ma...
609
"""simple docstring""" import string import numpy def UpperCAmelCase__ (snake_case__ : int , snake_case__ : int ): """simple docstring""" return b if a == 0 else greatest_common_divisor(b % a , snake_case__ ) class lowercase: ...
609
1
'''simple docstring''' import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin lowerCAmelCase_ = get_tests_dir('fixtures/te...
715
'''simple docstring''' # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def A__ ( A : Optional[int] , A : List[str] , A : int , A : Any): '''simple docstring''' UpperCamelCase : Union[str, Any] = ...
435
0
from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): from ..mod...
242
from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __magic_name__ ( lowerCAmelCase_ ): SCREAMING_SNAKE_CAS...
242
1
import inspect import math import tempfile import unittest import numpy as np from transformers import ViTMAEConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available ...
719
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class _UpperCamelCase( __lowerCamelCase ): ...
577
0
"""simple docstring""" from __future__ import annotations _lowercase = [] def _snake_case ( snake_case__ : list[list[int]] , snake_case__ : int , snake_case__ : int ): for i in range(len(snake_case__ ) ): if board[row][i] == 1: return False for i in range(len(snake_...
91
'''simple docstring''' import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_token...
98
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase = logging.get_logger(__name__) _lowerCamelCase = { 'google/pegasus-large': 'https://huggingface.co/google/pegasus-large/resolve/main/config.json', # See all PEGASUS models at htt...
613
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from ...
613
1
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 _lowercase( ): a__ =10 a__ ...
20
import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_availabl...
475
0
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, ) _lowercase : Union[str, Any] ={ '''c...
661
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient _lowercase : Optional[Any] =WebClient(token=os.environ['''CI_SLACK_BOT_TOKEN''']) def A__ ( lowe...
661
1
'''simple docstring''' 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...
446
'''simple docstring''' def lowerCamelCase__ ( __lowerCamelCase : str = "The quick brown fox jumps over the lazy dog" , ): '''simple docstring''' _UpperCAmelCase : Optional[Any] =set() # Replace all the whitespace in our sentence _UpperCAmelCase : Dict ...
446
1
"""simple docstring""" import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_...
494
"""simple docstring""" def __lowerCamelCase ( SCREAMING_SNAKE_CASE,SCREAMING_SNAKE_CASE ) -> str: """simple docstring""" if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) _UpperCAmelCase = ...
494
1
import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepInverseScheduler, ...
302
"""simple docstring""" import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class __A : def __init__( self , a__ , a__ , a__ ): if dst_width < 0 or dst_height < 0: raise ValueError("""Destination width/height should be > 0""" ) ...
213
0
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = {name: getattr(transformers, name + 'Fast') for name in SLOW_TO_FAST_C...
576
import logging import math import os from dataclasses import dataclass, field from glob import glob from typing import Optional from torch.utils.data import ConcatDataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_WITH_LM_HEAD_MAPPING, AutoConfig, AutoModelWithLMHead, Aut...
576
1
'''simple docstring''' import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def a__ ( _SCREAMING_SNAKE_CASE : Tuple , _SCREAMING_SNAKE_CASE : Tuple=7 ) -> Any: """simple docstring""" U...
71
import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transformers.utils im...
14
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ : Any = { 'configuration_electra': ['ELEC...
350
'''simple docstring''' from typing import Dict, Iterable, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format, to_pil_image from ...image_utils impo...
350
1
from __future__ import annotations class _a : """simple docstring""" def __init__( self : List[Any] , UpperCAmelCase : str , UpperCAmelCase : str ): A_ , A_ = text, pattern A_ , A_ = l...
86
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Config...
405
0
"""simple docstring""" from math import factorial lowercase__ : Union[str, Any] = {str(d): factorial(d) for d in range(10)} def __lowercase ( _a ): return sum(DIGIT_FACTORIAL[d] for d in str(_a ) ) def __lowercase ( ): snake_case_ : Option...
713
"""simple docstring""" import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def __lowercase ( _a , _a , _a ): snake_case_ : Tuple = AutoConfig.from_pretrained(_a ) snake_case_ : Tuple = FlaxAutoModelF...
485
0
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_to...
600
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 __a ( __UpperCamelCase ): __snake_cas...
600
1
import copy import inspect import unittest from transformers import PretrainedConfig, SwiftFormerConfig 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_c...
64
from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def UpperCamelCase (lowercase_: np.ndarray , lowercase_: np.ndarray , lowercase_: np.ndarray , lowercase_: int , lowercase_: int ) -> np.ndarray: A__ : Any ...
64
1
'''simple docstring''' from typing import List, Optional from tokenizers import ByteLevelBPETokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_blenderbot_small import BlenderbotSmallTokenizer __a: List[str] = logging.get_logger(__name__...
152
'''simple docstring''' import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_cu...
120
0
from abc import ABC, abstractmethod from argparse import ArgumentParser class SCREAMING_SNAKE_CASE ( a_ ): """simple docstring""" @staticmethod @abstractmethod def SCREAMING_SNAKE_CASE ( lowerCAmelCase : ArgumentParser ) -> List[str]: ...
218
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_ (__A : int ) -> str: __lowerCAmelCase : str = int(__A ) ...
218
1