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''' import tempfile import unittest from make_student import create_student_by_copying_alternating_layers from transformers import AutoConfig from transformers.file_utils import cached_property from transformers.testing_utils import require_torch __snake_case ="""sshleifer/bart-tin...
356
'''simple docstring''' def a_ ( lowerCamelCase : float ): return 10 - x * x def a_ ( lowerCamelCase : float , lowerCamelCase : float ): # Bolzano theory in order to find if there is a root between a and b if equation(lowerCamelCase ...
55
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor __snake_case =logging.get_logger(__name__) class UpperCAmelCase_ ( __lowercase ): def __init__( self : Optional[Any] , *UpperCAmelCase__ : ...
357
'''simple docstring''' import math def a_ ( lowerCamelCase : int ): lowerCAmelCase = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(lowerCamelCase ) def a_ ( lowerCamelCase : float = 1 ...
55
0
'''simple docstring''' import requests from bsa import BeautifulSoup def a_ ( lowerCamelCase : str = "AAPL" ) -> Optional[int]: lowerCAmelCase = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' lowerCAmelCase = BeautifulSoup(requests...
358
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, 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 i...
55
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from diffusers import DDIMScheduler, KandinskyVaaPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel from diffusers.utils import floats_tensor, load_numpy, slow, torch_device from diffusers.utils.testi...
359
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def a_ ( lowerCamelCase : Iterable[str] , lowerCamelCase : int ): lowerCAmelCase = iter(lowerCamelCase ) while True: lowerCAmelCase...
55
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin,...
360
'''simple docstring''' from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, D...
55
0
'''simple docstring''' import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fs...
361
'''simple docstring''' from __future__ import annotations def a_ ( lowerCamelCase : list[float] , lowerCamelCase : list[float] ): lowerCAmelCase = sorted(numsa + numsa ) lowerCAmelCase , lowerCAmelCase = divmod(len(lowerCamelCas...
55
0
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=__lowercase ) class UpperCAmelCase_ ( __lowercase ): # `task` is not a ...
362
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __snake_case =TypeVar("""T""") class UpperCAmelCase_ ( Generic[T] ): def __init__( self : int , UpperCAmelCase__ : T )...
55
0
'''simple docstring''' def a_ ( lowerCamelCase : list[int] ): if not nums: # Makes sure that the list is not empty raise ValueError('List is empty' ) lowerCAmelCase = sum(lowerCamelCase ) / len(lowerCamelCase ) # Calculate the average return sum(...
363
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class UpperCAmelCase_ ( __lowercase ): def __init__( self : Tuple ) -> Tuple: # test for the above condition self.test() def __UpperC...
55
0
'''simple docstring''' import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested...
364
'''simple docstring''' import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask __snake_case =logging.getLogger(__name__) class UpperCAmelCase_ ( __lowercase ): ...
55
0
'''simple docstring''' import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class UpperCAmelCase_ ( ctypes.Structure ): # _fields is a specific attr expected by ctypes ...
365
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, lo...
55
0
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig,...
366
'''simple docstring''' import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common im...
55
0
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_f...
367
'''simple docstring''' def a_ ( lowerCamelCase : list[int] ): if not nums: # Makes sure that the list is not empty raise ValueError('List is empty' ) lowerCAmelCase = sum(lowerCamelCase ) / len(lowerCamelCase ) # Calculate the average return sum(...
55
0
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, 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_...
368
'''simple docstring''' import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def a_ ( ): lowerCAmelCase = ArgumentParser( description=( 'PyTorch T...
55
0
'''simple docstring''' class UpperCAmelCase_ : def __init__( self : List[str] , UpperCAmelCase__ : list[int] ) -> None: lowerCAmelCase = len(UpperCAmelCase__ ) lowerCAmelCase = [0] * len_array if len_array > 0: lowerCAmelCa...
369
'''simple docstring''' import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp f...
55
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __snake_case ={ """configuration_xlm""": ["""XLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMConfig""", """XLMOnnxConfig"""], ...
370
'''simple docstring''' import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DO...
55
0
'''simple docstring''' import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class UpperCAmelCase_ ( __lowercase ): lowerCamelCase : int = (CMStochasticIterativeScheduler,) lowerCamelCase : ...
371
'''simple docstring''' import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common i...
55
0
'''simple docstring''' from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, D...
350
'''simple docstring''' import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, ...
55
0
'''simple docstring''' def a_ ( lowerCamelCase : int = 50000000 ): lowerCAmelCase = set() lowerCAmelCase = int((limit - 24) ** (1 / 2) ) lowerCAmelCase = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) ...
351
'''simple docstring''' import unittest from transformers import AutoTokenizer, FalconConfig, 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...
55
0
'''simple docstring''' from typing import Any class UpperCAmelCase_ : def __init__( self : Any , UpperCAmelCase__ : Any ) -> Optional[int]: lowerCAmelCase = data lowerCAmelCase = None class UpperCAmelCase_ : def __init__( s...
352
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class UpperCAmelCase_ : def __init__( self : Dict , UpperCAmelCase__ : list[tuple[float, float]] ) -> str: lowerCAmelCase = list_of_poin...
55
0
'''simple docstring''' import math def a_ ( lowerCamelCase : int ): lowerCAmelCase = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(lowerCamelCase ) def a_ ( lowerCamelCase : float = 1 / 12345 ): lowerC...
353
'''simple docstring''' def a_ ( ): lowerCAmelCase = [] lowerCAmelCase = 1 while len(lowerCamelCase ) < 1e6: constant.append(str(lowerCamelCase ) ) i += 1 lowerCAmelCase = ''.join(lowerCamelCase ) return ( int(co...
55
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __snake_case ={ """configuration_conditional_detr""": [ """CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
354
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __snake_case ={ """configuration_swiftformer""": [ """SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """S...
55
0
'''simple docstring''' import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs ...
355
'''simple docstring''' import requests from bsa import BeautifulSoup def a_ ( lowerCamelCase : str = "AAPL" ): lowerCAmelCase = f'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' lowerCAmelCase = BeautifulSoup(requests.get(lowerCamelCase ...
55
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case =logging.get_logger(__name__) __snake_case ={ """vinvino02/glpn-kitti""": """https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json""", # See all GLPN mode...
356
'''simple docstring''' def a_ ( lowerCamelCase : float ): return 10 - x * x def a_ ( lowerCamelCase : float , lowerCamelCase : float ): # Bolzano theory in order to find if there is a root between a and b if equation(lowerCamelCase ...
55
0
'''simple docstring''' from typing import List from .keymap import KEYMAP, get_character def a_ ( lowerCamelCase : str ): def decorator(lowerCamelCase : Optional[int] ): lowerCAmelCase = getattr(lowerCamelCase , 'handle_key' , [] ) handle...
357
'''simple docstring''' import math def a_ ( lowerCamelCase : int ): lowerCAmelCase = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(lowerCamelCase ) def a_ ( lowerCamelCase : float = 1 ...
55
0
'''simple docstring''' def a_ ( lowerCamelCase : int ) -> Union[str, Any]: if isinstance(lowerCamelCase , lowerCamelCase ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(lowerCamelCase , lowerCamelCase ): ...
358
'''simple docstring''' import unittest import numpy as np from transformers import RobertaConfig, 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 i...
55
0
'''simple docstring''' from __future__ import annotations from functools import lru_cache from math import ceil __snake_case =100 __snake_case =set(range(3, NUM_PRIMES, 2)) primes.add(2) __snake_case =42 for prime in range(3, ceil(NUM_PRIMES**0.5), 2): if prime not in primes: ...
359
'''simple docstring''' import itertools import string from collections.abc import Generator, Iterable def a_ ( lowerCamelCase : Iterable[str] , lowerCamelCase : int ): lowerCAmelCase = iter(lowerCamelCase ) while True: lowerCAmelCase...
55
0
'''simple docstring''' from timeit import timeit def a_ ( lowerCamelCase : int ): if number < 0: raise ValueError('the value of input must not be negative' ) lowerCAmelCase = 0 while number: number &= number - 1 result += 1 ret...
360
'''simple docstring''' from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, D...
55
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case =logging.get_logger(__name__) __snake_case ={ """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json""", }...
361
'''simple docstring''' from __future__ import annotations def a_ ( lowerCamelCase : list[float] , lowerCamelCase : list[float] ): lowerCAmelCase = sorted(numsa + numsa ) lowerCAmelCase , lowerCAmelCase = divmod(len(lowerCamelCas...
55
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __snake_case =logging.get_logger(__name__) __snake_case ={ """shi-labs...
362
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __snake_case =TypeVar("""T""") class UpperCAmelCase_ ( Generic[T] ): def __init__( self : int , UpperCAmelCase__ : T )...
55
0
'''simple docstring''' import math def a_ ( lowerCamelCase : float , lowerCamelCase : float ): return math.pow(lowerCamelCase , 2 ) - a def a_ ( lowerCamelCase : float ): return 2 * x def a_ ( lower...
363
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class UpperCAmelCase_ ( __lowercase ): def __init__( self : Tuple ) -> Tuple: # test for the above condition self.test() def __UpperC...
55
0
'''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_ten...
364
'''simple docstring''' import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask __snake_case =logging.getLogger(__name__) class UpperCAmelCase_ ( __lowercase ): ...
55
0
'''simple docstring''' 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, ControlNetModel, DDIMScheduler, ...
365
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, lo...
55
0
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json d...
366
'''simple docstring''' import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common im...
55
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case ={ """configuration_timesformer""": ["""TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TimesformerConfig"""], } try: ...
367
'''simple docstring''' def a_ ( lowerCamelCase : list[int] ): if not nums: # Makes sure that the list is not empty raise ValueError('List is empty' ) lowerCAmelCase = sum(lowerCamelCase ) / len(lowerCamelCase ) # Calculate the average return sum(...
55
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 ={ """configuration_distilbert""": ...
368
'''simple docstring''' import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def a_ ( ): lowerCAmelCase = ArgumentParser( description=( 'PyTorch T...
55
0
'''simple docstring''' import argparse __snake_case ="""docs/source/_static/js/custom.js""" def a_ ( lowerCamelCase : Optional[Any] ): with open(lowerCamelCase , encoding='utf-8' , newline='\n' ) as f: lowerCAmelCase = f.readlines() lowerCAmelC...
369
'''simple docstring''' import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp f...
55
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __snake_case =logging.get_logger(__name__) __snake_case ={"...
370
'''simple docstring''' import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DO...
55
0
'''simple docstring''' import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask __snake_case =logging.getLogger(__name__) class UpperCAmelCase_ ( __lowercase ): ...
371
'''simple docstring''' import inspect import unittest from transformers import BitConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common i...
55
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class __a (metaclass=UpperCamelCase_): '''simple docstring''' _SCREAMING_SNAKE_CASE :Any = ["""torch""", """transformers""", """onnx"""] def __init__( self , *_a , **_a ) -> List[An...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> bool: if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
56
1
"""simple docstring""" from __future__ import annotations def _lowercase ( __lowerCAmelCase ) -> list[int]: # This function is recursive SCREAMING_SNAKE_CASE__ : Union[str, Any] = len(__lowerCAmelCase ) # If the array contains only one element, we return it (it's ...
56
"""simple docstring""" 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 __a (tf.keras.optimizers.schedules.LearningRateSchedule): ...
56
1
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> Dict: SCREAMING_SNAKE_CASE__ : Dict = [] SCREAMING_SNAKE_CASE__ : Optional[Any] = [] SCREAMING_SNAKE_CASE__ : int = { """^""": 3, """*""": 2, """/""": 2, ...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: while b: SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ : int = b, a % b return a def _lowercase ( __lowerCAmelCase , __lowerCAmelCase )...
56
1
"""simple docstring""" import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTeste...
56
"""simple docstring""" class __a : '''simple docstring''' def __init__( self , _a ) -> Any: """simple docstring""" SCREAMING_SNAKE_CASE__ : Dict = arr.split(""",""" ) def _a ( self ) -> Any: "...
56
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer a :List[Any] = logging.get_logger(__name__) ...
56
"""simple docstring""" import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTeste...
56
1
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number | (1 << position) def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number & ~(1 << position) def _lowercase ( __lower...
56
"""simple docstring""" import math from collections.abc import Iterator from itertools import takewhile def _lowercase ( __lowerCAmelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
56
1
"""simple docstring""" import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.numpy as jnp from jax import j...
56
"""simple docstring""" import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu a :List[Any] =...
56
1
"""simple docstring""" 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 transform...
56
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParse...
56
1
"""simple docstring""" from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class __a : '''simple docstring''' _SCREAMING_SNAKE_CASE :str...
56
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging a :Optional[int] = logging.get_logger(__name__) def _lowercase ( __lowerCAmelCase ) -> List[int]: if isinstance(__lowerCAmelCase , np.nd...
56
1
"""simple docstring""" import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": a :List[Any] = argparse.ArgumentParser() parser.add_argument( "--checkpoint_path", default=None, type=str, required=True, h...
56
"""simple docstring""" import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import t...
56
1
"""simple docstring""" from __future__ import annotations def _lowercase ( __lowerCAmelCase ) -> bool: SCREAMING_SNAKE_CASE__ : str = str(__lowerCAmelCase ) return len(__lowerCAmelCase ) == 9 and set(__lowerCAmelCase ) == set("""123456789""" ) ...
56
"""simple docstring""" from ..utils import DummyObject, requires_backends class __a (metaclass=UpperCamelCase_): '''simple docstring''' _SCREAMING_SNAKE_CASE :Optional[Any] = ["""transformers""", """torch""", """note_seq"""] def __init__( self , *_a , **_a ) ...
56
1
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> Tuple: SCREAMING_SNAKE_CASE__ : Union[str, Any] = [0] * len(__lowerCAmelCase ) SCREAMING_SNAKE_CASE__ : List[Any] = [] SCREAMING_SNAKE_CASE__ : Any = [1] * len(__lowerCAmelCase ...
56
1
"""simple docstring""" import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class __a (UpperCamelCase_): '''simple docstring''' _SCREAMING_SNAKE_CASE :str = (PNDMScheduler,) _SCREAMING_SNAKE_CASE :int = (("""n...
56
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a :List[str] = logging.get_logger(__name__) a :Union[str, Any] = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve...
56
1
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common impor...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number | (1 << position) def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number & ~(1 << position) def _lowercase ( __lower...
56
1
"""simple docstring""" # 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 ...
56
"""simple docstring""" import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def _lowerca...
56
1
"""simple docstring""" from __future__ import annotations def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> list: SCREAMING_SNAKE_CASE__ : List[str] = [] SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CA...
56
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example a :str = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0...
56
1
"""simple docstring""" import gc import threading import time import psutil import torch class __a : '''simple docstring''' def __init__( self ) -> Tuple: """simple docstring""" SCREAMING_SNAKE_CASE__ : Optional[int] = psutil.Process() ...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> Dict: SCREAMING_SNAKE_CASE__ : Dict = [] SCREAMING_SNAKE_CASE__ : Optional[Any] = [] SCREAMING_SNAKE_CASE__ : int = { """^""": 3, """*""": 2, """/""": 2, ...
56
1
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> float: if principal <= 0: raise Exception("""Principal borrowed must be > 0""" ) if rate_per_annum < 0: raise Exception("""Rate of interest mus...
56
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a :List[Any] = logging.get_logger(__name__) a :Tuple = { "Salesforce/blip-vqa-base": "https://huggingface.co/Salesforce/blip-vqa-base/resolve/m...
56
"""simple docstring""" import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class __a (UpperCamelCas...
56
1
"""simple docstring""" import faiss # 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 requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklearn #...
56
"""simple docstring""" from math import loga def _lowercase ( __lowerCAmelCase ) -> int: if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError("""In...
56
1
"""simple docstring""" import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def _lowercase ( __lowerCAmelCase ) -> int: SCREAMING_SNAKE_CASE__ : Optional[int] = [ """encoder.version""", ...
56
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import...
56
1
"""simple docstring""" from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration a :int = HfArgumentParser(InitializationArguments) a :Union[str, Any] = parser.parse_args() # Load codeparrot tokenizer tr...
56
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a :Dict = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], "tokenization_rag": ["RagTokenizer"], } try: if no...
56
1
"""simple docstring""" import os import unittest from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, BertTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.te...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> bool: if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
56
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a :Tuple = { "configuration_llama": ["LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP", "LlamaC...
56
"""simple docstring""" 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 __a (tf.keras.optimizers.schedules.LearningRateSchedule): ...
56
1
"""simple docstring""" import json import os import shutil import tempfile from unittest import TestCase from transformers import BartTokenizer, BartTokenizerFast, DPRQuestionEncoderTokenizer, DPRQuestionEncoderTokenizerFast from transformers.models.bart.configuration_bart import BartConfig from transformers.model...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: while b: SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ : int = b, a % b return a def _lowercase ( __lowerCAmelCase , __lowerCAmelCase )...
56
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices a :List[str] = logging.get_logger(__name__) a :Union[str, Any] = { "google/bit-50": "https:...
56
"""simple docstring""" class __a : '''simple docstring''' def __init__( self , _a ) -> Any: """simple docstring""" SCREAMING_SNAKE_CASE__ : Dict = arr.split(""",""" ) def _a ( self ) -> Any: "...
56
1
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging a :Optional[int] = logging.get_logger(__name__) def _lowercase ( __lowerCAmelCase ) -> List[int]: if isinstance(__lowerCAmelCase , np.nd...
56
"""simple docstring""" import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTeste...
56
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, load_imag...
56
"""simple docstring""" import math from collections.abc import Iterator from itertools import takewhile def _lowercase ( __lowerCAmelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
56
1
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> set: SCREAMING_SNAKE_CASE__ : Union[str, Any] = set() # edges = list of graph's edges SCREAMING_SNAKE_CASE__ : List[str] = get_edges(__lowerCAmelCase ) # While there are still elements...
56
"""simple docstring""" import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu a :List[Any] =...
56
1
"""simple docstring""" a :int = {"a": ["c", "b"], "b": ["d", "e"], "c": [], "d": [], "e": []} a :Union[str, Any] = ["a", "b", "c", "d", "e"] def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> Union[str, Any]: SCREAMING_SNAKE_CASE__ ...
56
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParse...
56
1
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters a :Optional[Any] = (720, 1_280) # Height, Width a :Tuple = (0.4, 0.6) # if height or width lower than this scale, drop it. a :int = 1 / 100 a :...
56
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging a :Optional[int] = logging.get_logger(__name__) def _lowercase ( __lowerCAmelCase ) -> List[int]: if isinstance(__lowerCAmelCase , np.nd...
56
1
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import loggi...
56
"""simple docstring""" import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import t...
56
1
"""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 Conf...
56
"""simple docstring""" from ..utils import DummyObject, requires_backends class __a (metaclass=UpperCamelCase_): '''simple docstring''' _SCREAMING_SNAKE_CASE :Optional[Any] = ["""transformers""", """torch""", """note_seq"""] def __init__( self , *_a , **_a ) ...
56
1
"""simple docstring""" import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available ...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> Tuple: SCREAMING_SNAKE_CASE__ : Union[str, Any] = [0] * len(__lowerCAmelCase ) SCREAMING_SNAKE_CASE__ : List[Any] = [] SCREAMING_SNAKE_CASE__ : Any = [1] * len(__lowerCAmelCase ...
56
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a :Dict = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], "tokenization_rag": ["RagTokenizer"], } try: if no...
56
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a :List[str] = logging.get_logger(__name__) a :Union[str, Any] = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve...
56
1
"""simple docstring""" import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import MaskaFormerConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, tor...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number | (1 << position) def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number & ~(1 << position) def _lowercase ( __lower...
56
1
"""simple docstring""" import math from collections.abc import Iterator from itertools import takewhile def _lowercase ( __lowerCAmelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
56
"""simple docstring""" import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def _lowerca...
56
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a :Dict = logging.get_logger(__name__) a :Optional[int] = { "SCUT-DLVCLab/lilt-roberta-en-base": ( "https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.json" ...
56
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example a :str = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0...
56
1
"""simple docstring""" 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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( ...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> Dict: SCREAMING_SNAKE_CASE__ : Dict = [] SCREAMING_SNAKE_CASE__ : Optional[Any] = [] SCREAMING_SNAKE_CASE__ : int = { """^""": 3, """*""": 2, """/""": 2, ...
56
1
"""simple docstring""" from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function a :Dict = 1.0_5457_1817e-34 # unit of ℏ : J * s a :List[str] = 3e8 # unit of c : m * s^-1 def _lowercase ( __l...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> float: if principal <= 0: raise Exception("""Principal borrowed must be > 0""" ) if rate_per_annum < 0: raise Exception("""Rate of interest mus...
56
1
"""simple docstring""" import requests def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> None: SCREAMING_SNAKE_CASE__ : Union[str, Any] = {"""Content-Type""": """application/json"""} SCREAMING_SNAKE_CASE__ : int = requests.post(__lowerCAmelCase ...
56
"""simple docstring""" import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class __a (UpperCamelCas...
56
1
"""simple docstring""" import sys a :Any = ( "73167176531330624919225119674426574742355349194934" "96983520312774506326239578318016984801869478851843" "85861560789112949495459501737958331952853208805511" "12540698747158523863050715693290963295227443043557" "668966489504452445231617318564...
56
"""simple docstring""" from math import loga def _lowercase ( __lowerCAmelCase ) -> int: if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError("""In...
56
1
"""simple docstring""" import os import tempfile import unittest import uuid from pathlib import Path from transformers.testing_utils import get_tests_dir, require_soundfile, require_torch, require_vision from transformers.tools.agent_types import AgentAudio, AgentImage, AgentText from transformers.utils import is...
56
"""simple docstring""" import inspect import unittest from transformers import RegNetConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_common import...
56
1
"""simple docstring""" import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication import deduplicate_dataset from t...
56
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a :Dict = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], "tokenization_rag": ["RagTokenizer"], } try: if no...
56
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils im...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> bool: if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
56
1
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
56
"""simple docstring""" 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 __a (tf.keras.optimizers.schedules.LearningRateSchedule): ...
56
1
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> bool: SCREAMING_SNAKE_CASE__ : Tuple = len(__lowerCAmelCase ) SCREAMING_SNAKE_CASE__ : Tuple = len(__lowerCAmelCase ) SCREAMING_SNAKE_CASE__ : int = [...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: while b: SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ : int = b, a % b return a def _lowercase ( __lowerCAmelCase , __lowerCAmelCase )...
56
1
"""simple docstring""" from __future__ import annotations import math def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> list: if len(__lowerCAmelCase ) != 2 or len(a[0] ) != 2 or len(__lowerCAmelCase ) != 2 or len(b[0] ) != 2: raise Exc...
56
"""simple docstring""" class __a : '''simple docstring''' def __init__( self , _a ) -> Any: """simple docstring""" SCREAMING_SNAKE_CASE__ : Dict = arr.split(""",""" ) def _a ( self ) -> Any: "...
56
1
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> Tuple: SCREAMING_SNAKE_CASE__ : Union[str, Any] = [0] * len(__lowerCAmelCase ) SCREAMING_SNAKE_CASE__ : List[Any] = [] SCREAMING_SNAKE_CASE__ : Any = [1] * len(__lowerCAmelCase ...
56
"""simple docstring""" import unittest from transformers import DebertaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTeste...
56
1
"""simple docstring""" import importlib.metadata import operator import re import sys from typing import Optional from packaging import version a :Tuple = { "<": operator.lt, "<=": operator.le, "==": operator.eq, "!=": operator.ne, ">=": operator.ge, ">": operator.gt, } def _l...
56
"""simple docstring""" import math from collections.abc import Iterator from itertools import takewhile def _lowercase ( __lowerCAmelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: ...
56
1
"""simple docstring""" from __future__ import annotations from collections.abc import MutableSequence class __a : '''simple docstring''' def __init__( self , _a , _a ) -> None: """simple docstring""" if len(_a ) != degree + 1: ...
56
"""simple docstring""" import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu a :List[Any] =...
56
1
"""simple docstring""" import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu a :List[Any] =...
56
"""simple docstring""" import logging import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import librosa import torch from datasets import DatasetDict, load_dataset from packaging import version from torch import nn from transformers import ( HfArgumentParse...
56
1
"""simple docstring""" from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_...
56
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging a :Optional[int] = logging.get_logger(__name__) def _lowercase ( __lowerCAmelCase ) -> List[int]: if isinstance(__lowerCAmelCase , np.nd...
56
1
"""simple docstring""" import math def _lowercase ( __lowerCAmelCase ) -> list[int]: SCREAMING_SNAKE_CASE__ : Optional[int] = [] SCREAMING_SNAKE_CASE__ : Optional[Any] = 2 SCREAMING_SNAKE_CASE__ : Dict = int(math.sqrt(__lowerCAmelCase ) ...
56
"""simple docstring""" import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import t...
56
1
"""simple docstring""" import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class __a (UpperCamelCas...
56
"""simple docstring""" from ..utils import DummyObject, requires_backends class __a (metaclass=UpperCamelCase_): '''simple docstring''' _SCREAMING_SNAKE_CASE :Optional[Any] = ["""transformers""", """torch""", """note_seq"""] def __init__( self , *_a , **_a ) ...
56
1
"""simple docstring""" import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sen...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> Tuple: SCREAMING_SNAKE_CASE__ : Union[str, Any] = [0] * len(__lowerCAmelCase ) SCREAMING_SNAKE_CASE__ : List[Any] = [] SCREAMING_SNAKE_CASE__ : Any = [1] * len(__lowerCAmelCase ...
56
1
"""simple docstring""" from functools import lru_cache @lru_cache def _lowercase ( __lowerCAmelCase ) -> int: if num < 0: raise ValueError("""Number should not be negative.""" ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__m...
56
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a :List[str] = logging.get_logger(__name__) a :Union[str, Any] = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve...
56
1
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> Any: if n == 0: return 1 elif n % 2 == 1: return (binary_exponentiation(__lowerCAmelCase , n - 1 , __lowerCAmelCase ) * a) % mod ...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number | (1 << position) def _lowercase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: return number & ~(1 << position) def _lowercase ( __lower...
56
1
"""simple docstring""" # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tests ...
56
"""simple docstring""" import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sqlalchemy def _lowerca...
56
1
"""simple docstring""" import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spect...
56
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example a :str = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0...
56
1
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class __a (UpperCamelCase_): '''simple docstring''' def _a ( self , _a=None , _a=None , _a=None , **_a ) -> Any: """simple docstring""" ...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> Dict: SCREAMING_SNAKE_CASE__ : Dict = [] SCREAMING_SNAKE_CASE__ : Optional[Any] = [] SCREAMING_SNAKE_CASE__ : int = { """^""": 3, """*""": 2, """/""": 2, ...
56
1
"""simple docstring""" def _lowercase ( __lowerCAmelCase ) -> int: SCREAMING_SNAKE_CASE__ : Any = abs(__lowerCAmelCase ) SCREAMING_SNAKE_CASE__ : List[Any] = 0 while n > 0: res += n % 10 n //= 10 return res def _lowerc...
56
"""simple docstring""" def _lowercase ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> float: if principal <= 0: raise Exception("""Principal borrowed must be > 0""" ) if rate_per_annum < 0: raise Exception("""Rate of interest mus...
56
1