code
stringlengths
81
54k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''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 class ...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int , _UpperCAmelCase : int ) -> str: if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("iterations must be defined as integers" ) if not isinstance(_UpperCAmelCase , ...
680
1
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int ) -> list[int]: if num <= 0: raise ValueError("Input must be a positive integer" ) __snake_case = [True] * (num + 1) __snake_case = 2 while p * p <= num: if primes[p]: f...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int ) -> str: if number > 0: raise ValueError("input must be a negative integer" ) __snake_case = len(bin(_UpperCAmelCase )[3:] ) __snake_case = bin(abs(_UpperCAmelCase ) - (1 << binary_number_length)...
680
1
'''simple docstring''' 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 f...
680
'''simple docstring''' from timeit import timeit def __UpperCAmelCase ( _UpperCAmelCase : int ) -> int: if number < 0: raise ValueError("the value of input must not be negative" ) __snake_case = 0 while number: number &= number - 1 result += 1 r...
680
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor a : Tuple = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( _UpperCamelCase ): def __init__( self : ...
680
'''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 a : Dict = '''...
680
1
'''simple docstring''' from random import shuffle import tensorflow as tf from numpy import array def __UpperCAmelCase ( _UpperCAmelCase : str , _UpperCAmelCase : Union[str, Any] ) -> str: __snake_case = int(_UpperCAmelCase ) assert noofclusters < len(_Uppe...
680
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transf...
680
1
'''simple docstring''' import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel a : T...
680
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("dataset_size" , [None, 4_00 * 2**20, 6_00 * 2**20] ) @pytest.mark.parametrize("input_in_memory_max_size" , ["default", 0, 1_00 * 2**20, 9_00 *...
680
1
'''simple docstring''' import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def __UpperCAmelCase ( _UpperCAmelCase : List[Any] , _UpperCAmelCase : Union[str, Any] , _UpperCAmelCase : int , ...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : float ) -> float: if edge <= 0 or not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("Length must be a positive." ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) d...
680
1
'''simple docstring''' import math def __UpperCAmelCase ( _UpperCAmelCase : list , _UpperCAmelCase : int = 0 , _UpperCAmelCase : int = 0 ) -> list: __snake_case = end or len(_UpperCAmelCase ) for i in range(_UpperCAmelCase , _UpperCAmelCase ...
680
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a : Any = 6_378_137.0 a : List[Any] = 6_356_752.314_245 a : Dict = 6_378_137 def __UpperCAmelCase ( _UpperCAmelCase : float...
680
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 transfor...
680
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray , _UpperCAmelCase : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. __snake_case = math.sqrt...
680
1
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from...
680
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : def __init__( self : Any , a_ : Dict , a_ : Union[str, Any] , a_ : Tuple ): """simple docstring""" __snake_case = name __snake_case = value __snak...
680
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/licens...
680
'''simple docstring''' import os from math import logaa def __UpperCAmelCase ( _UpperCAmelCase : str = "base_exp.txt" ) -> int: __snake_case = 0 __snake_case = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(_UpperCAmelCase ) , _UpperCAmelCase )...
680
1
'''simple docstring''' import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm impor...
680
'''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[Any] = log...
680
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a : Union[str, Any] = { '''configuration_nezha''': ['''NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NezhaConfig'''], ...
680
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : str = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''],...
680
1
'''simple docstring''' import numpy as np def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray ) -> np.ndarray: return 1 / (1 + np.exp(-vector )) def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray ) -> np.ndarray: return vector * sigmoid(_UpperCAmelCase ) ...
680
'''simple docstring''' # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format,...
680
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE__ ( metaclass=_UpperCamelCase ): __SCREAMING_SNAKE_CASE = ["""flax""", """transformers"""] def __init__( self : int , *a_ : List[str] , **a_ : Opt...
680
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def __UpperCAmelCase ( _UpperCAmelCase : Dict ...
680
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) a : Optional[int] = {} try: if not is_sentencepiece...
680
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) ...
680
1
'''simple docstring''' import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin from .feature_extraction_wavaveca import WavaVecaFeatureExtractor from .tokenization_wavaveca import WavaVecaCTCTokenizer class SCREAMING_SNAKE_CASE__ ( _UpperCamel...
680
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : List[Any] = { ...
680
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) ...
680
'''simple docstring''' import logging 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, ...
680
1
'''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 ...
680
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_devic...
680
1
'''simple docstring''' import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( _UpperCamelCase ): __SCREAMING_SNAKE_CASE = (DDPMParallelScheduler,) def A ( self : List...
680
'''simple docstring''' import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class SCREAMING_SNAKE_CASE__ : __SCREAMING_SNAKE_CASE = None __SCREAMING_SNAKE_CASE = False __SCREAMING_SNAKE_CASE = ...
680
1
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : def __init__( self : Dict , a_ : int , a_ : int=None , a_ : Optional[Any]=None ): """simple docstring""" __snake_case = data __snake_case = previous ...
680
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a : Optional[Any] = False class ...
680
1
'''simple docstring''' from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 a : str = { # 1536-bit 5: { ...
680
'''simple docstring''' import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('''>=''', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_...
680
1
'''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_dif...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int , _UpperCAmelCase : int ) -> str: if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("iterations must be defined as integers" ) if not isinstance(_UpperCAmelCase , ...
680
1
'''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(): fro...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int ) -> str: if number > 0: raise ValueError("input must be a negative integer" ) __snake_case = len(bin(_UpperCAmelCase )[3:] ) __snake_case = bin(abs(_UpperCAmelCase ) - (1 << binary_number_length)...
680
1
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int = 2_00_00_00 ) -> int: __snake_case = [0 for i in range(n + 1 )] __snake_case = 1 __snake_case = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for ...
680
'''simple docstring''' from timeit import timeit def __UpperCAmelCase ( _UpperCAmelCase : int ) -> int: if number < 0: raise ValueError("the value of input must not be negative" ) __snake_case = 0 while number: number &= number - 1 result += 1 r...
680
1
'''simple docstring''' import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink ...
680
'''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 a : Dict = '''...
680
1
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : float , _UpperCAmelCase : float ) -> float: if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bu...
680
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transf...
680
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a : Dict = logging.get_logger(__name__) a : List[Any] = { '''alibaba-damo/mgp-str-base''': '''https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config....
680
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("dataset_size" , [None, 4_00 * 2**20, 6_00 * 2**20] ) @pytest.mark.parametrize("input_in_memory_max_size" , ["default", 0, 1_00 * 2**20, 9_00 *...
680
1
'''simple docstring''' import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, ...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : float ) -> float: if edge <= 0 or not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("Length must be a positive." ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) d...
680
1
'''simple docstring''' # flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorForma...
680
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a : Any = 6_378_137.0 a : List[Any] = 6_356_752.314_245 a : Dict = 6_378_137 def __UpperCAmelCase ( _UpperCAmelCase : float...
680
1
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : def __init__( self : Any , a_ : int ): """simple docstring""" __snake_case = n __snake_case = [None] * self.n __snake_case = 0 # index of the first element ...
680
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray , _UpperCAmelCase : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. __snake_case = math.sqrt...
680
1
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def __UpperCAmelCase ( _UpperCAmelCase : Dict ...
680
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : def __init__( self : Any , a_ : Dict , a_ : Union[str, Any] , a_ : Tuple ): """simple docstring""" __snake_case = name __snake_case = value __snak...
680
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, lo...
680
'''simple docstring''' import os from math import logaa def __UpperCAmelCase ( _UpperCAmelCase : str = "base_exp.txt" ) -> int: __snake_case = 0 __snake_case = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(_UpperCAmelCase ) , _UpperCAmelCase )...
680
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) a : int = { '''configuration_resnet''': ['''RESNET_PRETRAINED_CONFIG_ARCH...
680
'''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[Any] = log...
680
1
'''simple docstring''' import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('''>=''', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_...
680
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : str = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''],...
680
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/licens...
680
'''simple docstring''' # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format,...
680
1
'''simple docstring''' from math import sqrt def __UpperCAmelCase ( _UpperCAmelCase : int ) -> bool: assert isinstance(_UpperCAmelCase , _UpperCAmelCase ) and ( number >= 0 ), "'number' must been an int and positive" __snake_case = True # 0 and 1 ...
680
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def __UpperCAmelCase ( _UpperCAmelCase : Dict ...
680
1
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : list[list] ) -> list[list]: __snake_case = current_set.copy() for row_index, row in enumerate(_UpperCAmelCase ): __snake_case = row[0] for column_index, column in enumerate(_UpperCAmelCase ): ...
680
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) ...
680
1
'''simple docstring''' import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module,...
680
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : List[Any] = { ...
680
1
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a : List[str] = logging.get_logger(__name__)...
680
'''simple docstring''' import logging 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, ...
680
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor a : Union[str, Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( _UpperCamelCase ): def __init__( self : int ...
680
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_devic...
680
1
'''simple docstring''' import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def __UpperCAmelCase ( _UpperCAmelCase : int , _UpperCAmelCase : ...
680
'''simple docstring''' import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class SCREAMING_SNAKE_CASE__ : __SCREAMING_SNAKE_CASE = None __SCREAMING_SNAKE_CASE = False __SCREAMING_SNAKE_CASE = ...
680
1
'''simple docstring''' from manim import * class SCREAMING_SNAKE_CASE__ ( _UpperCamelCase ): def A ( self : Any ): """simple docstring""" __snake_case = Rectangle(height=0.5 , width=0.5 ) __snake_case = Re...
680
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a : Optional[Any] = False class ...
680
1
'''simple docstring''' import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...g...
680
'''simple docstring''' import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('''>=''', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_...
680
1
'''simple docstring''' import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) f...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int , _UpperCAmelCase : int ) -> str: if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("iterations must be defined as integers" ) if not isinstance(_UpperCAmelCase , ...
680
1
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : def __init__( self : str , a_ : list[int] ): """simple docstring""" __snake_case = len(a_ ) __snake_case = [0] * len_array if len_array > 0: __s...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int ) -> str: if number > 0: raise ValueError("input must be a negative integer" ) __snake_case = len(bin(_UpperCAmelCase )[3:] ) __snake_case = bin(abs(_UpperCAmelCase ) - (1 << binary_number_length)...
680
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/LI...
680
'''simple docstring''' from timeit import timeit def __UpperCAmelCase ( _UpperCAmelCase : int ) -> int: if number < 0: raise ValueError("the value of input must not be negative" ) __snake_case = 0 while number: number &= number - 1 result += 1 r...
680
1
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging a : int ...
680
'''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 a : Dict = '''...
680
1
'''simple docstring''' from collections import Counter from timeit import timeit def __UpperCAmelCase ( _UpperCAmelCase : str = "" , ) -> bool: return sum(c % 2 for c in Counter(input_str.replace(" " , "" ).lower() ).values() ) < 2 def __UpperCAmelCase ( _...
680
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transf...
680
1
'''simple docstring''' from __future__ import annotations a : List[Any] = 1.6021e-19 # units = C def __UpperCAmelCase ( _UpperCAmelCase : float , _UpperCAmelCase : float , _UpperCAmelCase : float , ) -> tuple[str, float]: if (conduc...
680
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("dataset_size" , [None, 4_00 * 2**20, 6_00 * 2**20] ) @pytest.mark.parametrize("input_in_memory_max_size" , ["default", 0, 1_00 * 2**20, 9_00 *...
680
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : str = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''],...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : float ) -> float: if edge <= 0 or not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("Length must be a positive." ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) d...
680
1
'''simple docstring''' import comet # From: unbabel-comet import torch import datasets a : Union[str, Any] = datasets.logging.get_logger(__name__) a : Optional[Any] = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinh...
680
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a : Any = 6_378_137.0 a : List[Any] = 6_356_752.314_245 a : Dict = 6_378_137 def __UpperCAmelCase ( _UpperCAmelCase : float...
680
1
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a : Optional[Any] = False class ...
680
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray , _UpperCAmelCase : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. __snake_case = math.sqrt...
680
1
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray , _UpperCAmelCase : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. __snake_case = math.sqrt...
680
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : def __init__( self : Any , a_ : Dict , a_ : Union[str, Any] , a_ : Tuple ): """simple docstring""" __snake_case = name __snake_case = value __snak...
680
1
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable a : List[str] = {'''configuration_gpt_neox''': ['''GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
680
'''simple docstring''' import os from math import logaa def __UpperCAmelCase ( _UpperCAmelCase : str = "base_exp.txt" ) -> int: __snake_case = 0 __snake_case = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(_UpperCAmelCase ) , _UpperCAmelCase )...
680
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : Dict = { '''configuration_swinv2''': ['''SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Swinv2Config'''], } try: if not is_tor...
680
'''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[Any] = log...
680
1
'''simple docstring''' import os from datetime import datetime as dt from github import Github a : Tuple = [ '''good first issue''', '''good second issue''', '''good difficult issue''', '''enhancement''', '''new pipeline/model''', '''new scheduler''', ...
680
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : str = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''],...
680
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : List[Any] = { ...
680
'''simple docstring''' # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format,...
680
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available a : List[str] = { '''configuration_ernie''': ['''ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ErnieConfig''', ''...
680
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def __UpperCAmelCase ( _UpperCAmelCase : Dict ...
680
1
'''simple docstring''' # limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class SCREAMING_SNAKE_CASE__ ( _UpperCamelCase ): def __init__( self : Dict , a_ : ...
680
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) ...
680
1
'''simple docstring''' import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger a : Optional[int] = get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( enum.Enum ): __SCREAMING_SNAKE_CASE ...
680
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : List[Any] = { ...
680
1
'''simple docstring''' from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class SCREAMING_SNAKE_CASE__ ...
680
'''simple docstring''' import logging 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, ...
680
1
'''simple docstring''' # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format,...
680
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_devic...
680
1
'''simple docstring''' import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() a : int = logging.get_logger(__name__) a : List[Any] = {name: getattr(trans...
680
'''simple docstring''' import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class SCREAMING_SNAKE_CASE__ : __SCREAMING_SNAKE_CASE = None __SCREAMING_SNAKE_CASE = False __SCREAMING_SNAKE_CASE = ...
680
1
'''simple docstring''' import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ...
680
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a : Optional[Any] = False class ...
680
1
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing imp...
680
'''simple docstring''' import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('''>=''', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_...
680
1
'''simple docstring''' import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": a : List[str] = argparse.ArgumentParser( description=( '''Extraction some layers of the full RobertaForMaskedL...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int , _UpperCAmelCase : int ) -> str: if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("iterations must be defined as integers" ) if not isinstance(_UpperCAmelCase , ...
680
1
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a : Any = 6_378_137.0 a : List[Any] = 6_356_752.314_245 a : Dict = 6_378_137 def __UpperCAmelCase ( _UpperCAmelCase : float...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int ) -> str: if number > 0: raise ValueError("input must be a negative integer" ) __snake_case = len(bin(_UpperCAmelCase )[3:] ) __snake_case = bin(abs(_UpperCAmelCase ) - (1 << binary_number_length)...
680
1
'''simple docstring''' from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize("repo_id" , ["canonical_dataset_name", "org-name/dataset-name"] ) @pytest.mark.parametrize("path" , ["filename.csv", "filename with blanks.csv"] )...
680
'''simple docstring''' from timeit import timeit def __UpperCAmelCase ( _UpperCAmelCase : int ) -> int: if number < 0: raise ValueError("the value of input must not be negative" ) __snake_case = 0 while number: number &= number - 1 result += 1 r...
680
1
'''simple docstring''' import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow a : Dict = False class SCREAMING_SNAKE_CASE__ ( unittest.Te...
680
'''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 a : Dict = '''...
680
1
'''simple docstring''' from PIL import Image def __UpperCAmelCase ( _UpperCAmelCase : Image , _UpperCAmelCase : int ) -> Image: __snake_case = (2_59 * (level + 2_55)) / (2_55 * (2_59 - level)) def contrast(_UpperCAmelCase : int ) -> int: return i...
680
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transf...
680
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging a : str = logging.get_logger(__name__) a : str = { '''naver-clova-ix/donut-base''': '''https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json'''...
680
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("dataset_size" , [None, 4_00 * 2**20, 6_00 * 2**20] ) @pytest.mark.parametrize("input_in_memory_max_size" , ["default", 0, 1_00 * 2**20, 9_00 *...
680
1
'''simple docstring''' 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, ...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : float ) -> float: if edge <= 0 or not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("Length must be a positive." ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) d...
680
1
'''simple docstring''' import csv import tweepy # Twitter API credentials a : List[str] = '''''' a : int = '''''' a : List[Any] = '''''' a : Optional[int] = '''''' def __UpperCAmelCase ( _UpperCAmelCase : str ) -> None: ...
680
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a : Any = 6_378_137.0 a : List[Any] = 6_356_752.314_245 a : Dict = 6_378_137 def __UpperCAmelCase ( _UpperCAmelCase : float...
680
1
'''simple docstring''' # DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from ...
680
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray , _UpperCAmelCase : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. __snake_case = math.sqrt...
680
1
'''simple docstring''' import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, tor...
680
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : def __init__( self : Any , a_ : Dict , a_ : Union[str, Any] , a_ : Tuple ): """simple docstring""" __snake_case = name __snake_case = value __snak...
680
1
'''simple docstring''' import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set...
680
'''simple docstring''' import os from math import logaa def __UpperCAmelCase ( _UpperCAmelCase : str = "base_exp.txt" ) -> int: __snake_case = 0 __snake_case = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(_UpperCAmelCase ) , _UpperCAmelCase )...
680
1
'''simple docstring''' import doctest import glob import importlib import inspect import os import re from contextlib import contextmanager from functools import wraps from unittest.mock import patch import numpy as np import pytest from absl.testing import parameterized import datasets fr...
680
'''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[Any] = log...
680
1
'''simple docstring''' import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import Toke...
680
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a : str = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''],...
680
1
'''simple docstring''' import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def __UpperCAmelCase ( _UpperCAmelCase : List[Any] , _UpperCAmelCase : Tuple...
680
'''simple docstring''' # HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format,...
680
1
'''simple docstring''' from string import ascii_uppercase a : List[str] = {char: i for i, char in enumerate(ascii_uppercase)} a : str = dict(enumerate(ascii_uppercase)) def __UpperCAmelCase ( _UpperCAmelCase : str , _UpperCAmelCase : str ) -> ...
680
'''simple docstring''' import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def __UpperCAmelCase ( _UpperCAmelCase : Dict ...
680
1
'''simple docstring''' import argparse import copy def __UpperCAmelCase ( _UpperCAmelCase : str ) -> List[Any]: __snake_case = {} with open(_UpperCAmelCase ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __snake_case ...
680
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) ...
680
1
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class SCREAMING_SNAKE_CA...
680
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : List[Any] = { ...
680
1
'''simple docstring''' import os import sys import unittest a : List[str] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import get_test_info # noqa: E402 from get_test_info import ( # noqa:...
680
'''simple docstring''' import logging 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, ...
680
1
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import _LazyModule a : Any = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys a : Tuple ...
680
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_devic...
680
1
'''simple docstring''' import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
680
'''simple docstring''' import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class SCREAMING_SNAKE_CASE__ : __SCREAMING_SNAKE_CASE = None __SCREAMING_SNAKE_CASE = False __SCREAMING_SNAKE_CASE = ...
680
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Any = logging.get_logger(__name__) a : int = { '''facebook/x...
680
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a : Optional[Any] = False class ...
680
1
'''simple docstring''' import glob import os import random from string import ascii_lowercase, digits import cva a : Any = '''''' a : List[str] = '''''' a : List[Any] = '''''' a : List[Any] = 1 # (0 is vertical, 1 is horizontal) def __Uppe...
680
'''simple docstring''' import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version('''>=''', FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_...
680
1
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @da...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int , _UpperCAmelCase : int ) -> str: if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("iterations must be defined as integers" ) if not isinstance(_UpperCAmelCase , ...
680
1
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int ) -> str: if number > 0: raise ValueError("input must be a negative integer" ) __snake_case = len(bin(_UpperCAmelCase )[3:] ) __snake_case = bin(abs(_UpperCAmelCase ) - (1 << binary_number_length)...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : int ) -> str: if number > 0: raise ValueError("input must be a negative integer" ) __snake_case = len(bin(_UpperCAmelCase )[3:] ) __snake_case = bin(abs(_UpperCAmelCase ) - (1 << binary_number_length)...
680
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 a : Dict = '''...
680
'''simple docstring''' from timeit import timeit def __UpperCAmelCase ( _UpperCAmelCase : int ) -> int: if number < 0: raise ValueError("the value of input must not be negative" ) __snake_case = 0 while number: number &= number - 1 result += 1 r...
680
1
'''simple docstring''' import argparse from collections import defaultdict import yaml a : Dict = '''docs/source/en/_toctree.yml''' def __UpperCAmelCase ( _UpperCAmelCase : Optional[int] ) -> Tuple: __snake_case = defaultdict(_UpperCAmelCase ) __snake_...
680
'''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 a : Dict = '''...
680
1
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging a : Dict = logging.get_logger...
680
'''simple docstring''' import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transf...
680
1
'''simple docstring''' import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger a : Any = '''<<<<<<< This should probably be modified because it mentions: ''' ...
680
'''simple docstring''' import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("dataset_size" , [None, 4_00 * 2**20, 6_00 * 2**20] ) @pytest.mark.parametrize("input_in_memory_max_size" , ["default", 0, 1_00 * 2**20, 9_00 *...
680
1
'''simple docstring''' import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesC...
680
'''simple docstring''' def __UpperCAmelCase ( _UpperCAmelCase : float ) -> float: if edge <= 0 or not isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise ValueError("Length must be a positive." ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) * (edge**2) d...
680
1
'''simple docstring''' import logging 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, ...
680
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance a : Any = 6_378_137.0 a : List[Any] = 6_356_752.314_245 a : Dict = 6_378_137 def __UpperCAmelCase ( _UpperCAmelCase : float...
680
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 ...u...
680
'''simple docstring''' import math import sys import cva import numpy as np def __UpperCAmelCase ( _UpperCAmelCase : np.ndarray , _UpperCAmelCase : float ) -> np.ndarray: # For applying gaussian function for each element in matrix. __snake_case = math.sqrt...
680
1
'''simple docstring''' from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge a : Union[str, Any] = [ '''Prosecutor: "No videos were used in the crash investigation" German ...
680
'''simple docstring''' class SCREAMING_SNAKE_CASE__ : def __init__( self : Any , a_ : Dict , a_ : Union[str, Any] , a_ : Tuple ): """simple docstring""" __snake_case = name __snake_case = value __snak...
680
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/LI...
680
'''simple docstring''' import os from math import logaa def __UpperCAmelCase ( _UpperCAmelCase : str = "base_exp.txt" ) -> int: __snake_case = 0 __snake_case = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(_UpperCAmelCase ) , _UpperCAmelCase )...
680
1
'''simple docstring''' import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _...
680
'''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[Any] = log...
680
1