code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" import random from .binary_exp_mod import bin_exp_mod def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase=10_00 ): if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd __lowercase : A...
76
"""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/...
76
1
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers imp...
76
"""simple docstring""" import gc import threading import time import psutil import torch class UpperCAmelCase_ : def __init__( self ) -> str: __lowercase : List[Any] = psutil.Process() __lowercase : Any = False def ...
76
1
"""simple docstring""" import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC a_ = parse(importlib.metadata.version('torch')) def __UpperCAmelCase ( __UpperCamelCase ...
76
"""simple docstring""" import numpy as np import datasets a_ = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distan...
76
1
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from .....
76
"""simple docstring""" a_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def __UpperCAmelCase ( __UpperCamelCase ): # Make sure the supplied data is a bytes-like object if not isinstance(__UpperCamelCase , __UpperCamelCase ): ...
76
1
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are n...
76
"""simple docstring""" import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'vocab_file': 'vocab.json', ...
76
1
"""simple docstring""" from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration a_ = HfArgumentParser(InitializationArguments) a_ = parser.parse_args() # Load codepar...
76
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , ...
76
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = {} class UpperCAmelCase_ ( snake_case ): UpperCamelCase ="llama" UpperCamelCase =["past_key_va...
76
"""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_ = logging.get_logger(__name__) a...
76
1
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase = "cpu" , __UpperCamelCase = None ): __lowercase : str = torch.load(__UpperCamelCase , ma...
76
"""simple docstring""" import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput a_ = logging.getLogger(__name__) if...
76
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/licen...
76
"""simple docstring""" import math import flax.linen as nn import jax.numpy as jnp def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 1 , __UpperCamelCase = 1 , __UpperCamelCase = 1.0e4 , __UpperCamelCase = False , __UpperCame...
76
1
"""simple docstring""" import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertCo...
76
"""simple docstring""" import os import sys a_ = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Au...
76
1
"""simple docstring""" import unittest from transformers import AutoTokenizer, NystromformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTester...
76
"""simple docstring""" from math import pi, sqrt, tan def __UpperCAmelCase ( __UpperCamelCase ): if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def __UpperCAmelCase ...
76
1
"""simple docstring""" import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def __UpperCAmelCase ( __Upp...
76
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): # noqa: E741 while r - l > 1: __lowercase : int = (l + r) // 2 if v[m] >= k...
76
1
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip i...
76
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase = 4 ): __lowercase : Dict = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )]...
76
1
"""simple docstring""" from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar a_ = TypeVar('KEY') a_ = TypeVar('VAL') @dataclass(frozen=snake_case , slots=snake_case ) class UpperCAmelCase...
76
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer a_ = lo...
76
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , **UpperCam...
76
"""simple docstring""" import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , **UpperCam...
76
1
"""simple docstring""" class UpperCAmelCase_ : # Public class to implement a graph def __init__( self , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ) -> None: __lowercase : Tuple = row __lowercase : Dict ...
76
"""simple docstring""" import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def __UpperCAmelCase ( __UpperCamelCase ): # encod...
76
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) a_ = { 'configuration_speech_to_...
76
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
76
1
"""simple docstring""" import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class UpperCAmelCase_ ( unittest.TestCase ): def _lowerCamelCase ( self ) -> int: debug_...
76
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if digit_amount > 0: return round(number - int(__UpperCamelCase ) , __UpperCamelCase ) return number - int(__UpperCamelCase ) if __name__ == "__main__": print(decimal_isolate(1....
76
1
"""simple docstring""" from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class UpperCAmelCase_ : UpperCamelCase =42 ...
76
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack __lowercase : set[int] = set() return any( node not in vis...
76
1
"""simple docstring""" from __future__ import annotations from math import gcd def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase = 2 , __UpperCamelCase = 1 , __UpperCamelCase = 3 , ): # A value less than 2 can cause an infinite loop in the algorithm...
76
"""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_DOCSTRI...
76
1
"""simple docstring""" import math def __UpperCAmelCase ( __UpperCamelCase = 1_00 ): __lowercase : List[Any] = sum(i * i for i in range(1 , n + 1 ) ) __lowercase : Any = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) return sq...
76
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, ...
76
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_ = False class UpperCAmelC...
76
"""simple docstring""" a_ = { 'Pillow': 'Pillow<10.0.0', 'accelerate': 'accelerate>=0.20.3', 'av': 'av==9.2.0', 'beautifulsoup4': 'beautifulsoup4', 'black': 'black~=23.1', 'codecarbon': 'codecarbon==1.2.0', 'cookiecutter': 'cookiecutter==1.7.3', 'd...
76
1
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): print('''\nThe shortest path matrix using Floyd Warshall algorithm\n''' ) for i in range(__UpperCamelCase ): for j in range(__UpperCamelCase ): if dist[i][j] != float('''inf''' ):...
76
"""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/...
76
1
"""simple docstring""" def __UpperCAmelCase ( ): __lowercase : str = [] __lowercase : int = 1 while len(__UpperCamelCase ) < 1e6: constant.append(str(__UpperCamelCase ) ) i += 1 __lowercase : Optional[Any] = ''...
76
"""simple docstring""" import gc import threading import time import psutil import torch class UpperCAmelCase_ : def __init__( self ) -> str: __lowercase : List[Any] = psutil.Process() __lowercase : Any = False def ...
76
1
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase = 10**12 ): __lowercase : Tuple = 1 __lowercase : Optional[int] = 0 __lowercase : Union[str, Any] = 1 __lowercase : List[Any] = 1 while numer...
76
"""simple docstring""" import numpy as np import datasets a_ = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distan...
76
1
"""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=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a ...
76
"""simple docstring""" a_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def __UpperCAmelCase ( __UpperCamelCase ): # Make sure the supplied data is a bytes-like object if not isinstance(__UpperCamelCase , __UpperCamelCase ): ...
76
1
"""simple docstring""" import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..uti...
76
"""simple docstring""" import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'vocab_file': 'vocab.json', ...
76
1
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): # noqa: E741 while r - l > 1: __lowercase : int = (l + r) // 2 if v[m] >= k...
76
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , ...
76
1
"""simple docstring""" import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class UpperCAmelCase_ : UpperCamelCase =None def _lowerCamelCase ( self ) -> str: __lowercase : Union[s...
76
"""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_ = logging.get_logger(__name__) a...
76
1
"""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 im...
76
"""simple docstring""" import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput a_ = logging.getLogger(__name__) if...
76
1
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): __lowercase : Optional[Any] = word.split() def justify(__UpperCamelCase , __UpperCamelCase , __UpperCamelCase ) -> str: __lowercase : Any = max_width...
76
"""simple docstring""" import math import flax.linen as nn import jax.numpy as jnp def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 1 , __UpperCamelCase = 1 , __UpperCamelCase = 1.0e4 , __UpperCamelCase = False , __UpperCame...
76
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/...
76
"""simple docstring""" import os import sys a_ = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Au...
76
1
"""simple docstring""" from math import pi, sqrt def __UpperCAmelCase ( __UpperCamelCase ): if num <= 0: raise ValueError('''math domain error''' ) if num > 171.5: raise OverflowError('''math range error''' ) elif num - int(__UpperCamelCase ) not in (...
76
"""simple docstring""" from math import pi, sqrt, tan def __UpperCAmelCase ( __UpperCamelCase ): if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def __UpperCAmelCase ...
76
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_ = logging.get_logger(__name__) a...
76
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): # noqa: E741 while r - l > 1: __lowercase : int = (l + r) // 2 if v[m] >= k...
76
1
"""simple docstring""" import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...tes...
76
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase = 4 ): __lowercase : Dict = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )]...
76
1
"""simple docstring""" import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_...
76
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer a_ = lo...
76
1
"""simple docstring""" import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_avail...
76
"""simple docstring""" import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , **UpperCam...
76
1
"""simple docstring""" import gc import unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline...
76
"""simple docstring""" import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def __UpperCAmelCase ( __UpperCamelCase ): # encod...
76
1
"""simple docstring""" import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( '''files''' , [ ['''full:README.md''', '''dataset_infos.json'''],...
76
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
76
1
"""simple docstring""" import torch from transformers import AutoModel class UpperCAmelCase_ ( torch.nn.Module ): def __init__( self , UpperCamelCase_="sayef/fsner-bert-base-uncased" ) -> Optional[Any]: super(UpperCamelCase_ , self )....
76
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if digit_amount > 0: return round(number - int(__UpperCamelCase ) , __UpperCamelCase ) return number - int(__UpperCamelCase ) if __name__ == "__main__": print(decimal_isolate(1....
76
1
"""simple docstring""" a_ = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} a_ = ['a', 'b', 'c', 'd', 'e'] def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): __lowercase : List[str] = ...
76
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack __lowercase : set[int] = set() return any( node not in vis...
76
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'Salesforce/blip-vqa-base': 'https://huggingface.co/Salesforce/b...
76
"""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_DOCSTRI...
76
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCAmelCase_ ( metaclass=snake_case ): UpperCamelCase =["torch", "transformers", "onnx"] def __init__( self , *UpperCamelCase_ , **UpperCamelCase_ ) -> Union...
76
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, ...
76
1
"""simple docstring""" a_ = 0 # The first color of the flag. a_ = 1 # The second color of the flag. a_ = 2 # The third color of the flag. a_ = (red, white, blue) def __UpperCAmelCase ( __UpperCamelCase ): if not seq...
76
"""simple docstring""" a_ = { 'Pillow': 'Pillow<10.0.0', 'accelerate': 'accelerate>=0.20.3', 'av': 'av==9.2.0', 'beautifulsoup4': 'beautifulsoup4', 'black': 'black~=23.1', 'codecarbon': 'codecarbon==1.2.0', 'cookiecutter': 'cookiecutter==1.7.3', 'd...
76
1
"""simple docstring""" import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def __UpperCAmelCase ( *__UpperCamelCase , __UpperCamelCase = None , __UpperCamelCase=True , __UpperCamelCase=2 ): from .. import...
76
"""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/...
76
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'google/canine-s': 'https://huggingface.co/google/canine-s/resolve/main/config.json', # See all CANINE models a...
76
"""simple docstring""" import gc import threading import time import psutil import torch class UpperCAmelCase_ : def __init__( self ) -> str: __lowercase : List[Any] = psutil.Process() __lowercase : Any = False def ...
76
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class UpperCAmelCase_ ( metaclass=snake_case ): UpperCamelCase =["note_seq"] def __init__( self , *UpperCamelCase_ , **UpperCamelCase_ ) -> str: requires_backen...
76
"""simple docstring""" import numpy as np import datasets a_ = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distan...
76
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = { 'configuration_chinese_clip': [ 'CHINESE_CLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ChineseCL...
76
"""simple docstring""" a_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def __UpperCAmelCase ( __UpperCamelCase ): # Make sure the supplied data is a bytes-like object if not isinstance(__UpperCamelCase , __UpperCamelCase ): ...
76
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', ...
76
"""simple docstring""" import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'vocab_file': 'vocab.json', ...
76
1
"""simple docstring""" from __future__ import annotations import unittest from transformers import FunnelConfig, is_tf_available from transformers.testing_utils import require_tf from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin...
76
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , ...
76
1
"""simple docstring""" import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): a_ = yaml.safe_load( '\\nname: ""\nallow_empty: false\nallow_empty_text: t...
76
"""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_ = logging.get_logger(__name__) a...
76
1
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase ): if not nums: raise ValueError('''List is empty''' ) return sum(__UpperCamelCase ) / len(__UpperCamelCase ) if __name__ == "__main__": import doctest ...
76
"""simple docstring""" import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput a_ = logging.getLogger(__name__) if...
76
1
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if not (isinstance(__UpperCamelCase , __UpperCamelCase ) and isinstance(__UpperCamelCase , __UpperCamelCase )): raise ValueError('''longest_common_substring() takes two strings for inpu...
76
"""simple docstring""" import math import flax.linen as nn import jax.numpy as jnp def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 1 , __UpperCamelCase = 1 , __UpperCamelCase = 1.0e4 , __UpperCamelCase = False , __UpperCame...
76
1
"""simple docstring""" a_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def __UpperCAmelCase ( __UpperCamelCase ): # Make sure the supplied data is a bytes-like object if not isinstance(__UpperCamelCase , __UpperCamelCase ): ...
76
"""simple docstring""" import os import sys a_ = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Au...
76
1
"""simple docstring""" import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers impor...
76
"""simple docstring""" from math import pi, sqrt, tan def __UpperCAmelCase ( __UpperCamelCase ): if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def __UpperCAmelCase ...
76
1
"""simple docstring""" import os from pathlib import Path def __UpperCAmelCase ( ): from torch.utils.cpp_extension import load __lowercase : List[Any] = Path(__UpperCamelCase ).resolve().parent.parent.parent / '''kernels''' / '''deformable_detr''' ...
76
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): # noqa: E741 while r - l > 1: __lowercase : int = (l + r) // 2 if v[m] >= k...
76
1
"""simple docstring""" import argparse import datetime def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : int = { '''0''': '''Sunday''', '''1''': '''Monday''', '''2''': '''Tuesday''', '''3''': '''Wednesday''', ...
76
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase = 4 ): __lowercase : Dict = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )]...
76
1
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase = 1_00_00_00 ): __lowercase : Optional[Any] = limit + 1 __lowercase : str = [0] * limit for first_term in range(1 , __UpperCamelCase ): for n in range(__UpperCamelCase , __...
76
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer a_ = lo...
76
1
"""simple docstring""" import baseaa def __UpperCAmelCase ( __UpperCamelCase ): return baseaa.aaaencode(string.encode('''utf-8''' ) ) def __UpperCAmelCase ( __UpperCamelCase ): return baseaa.aaadecode(__UpperCamelCase ).decode('''utf-8''' ) ...
76
"""simple docstring""" import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , **UpperCam...
76
1
"""simple docstring""" import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_ava...
76
"""simple docstring""" import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def __UpperCAmelCase ( __UpperCamelCase ): # encod...
76
1
import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import DEFAULTS, task_specific_p...
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
76
0
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torc...
1
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if digit_amount > 0: return round(number - int(__UpperCamelCase ) , __UpperCamelCase ) return number - int(__UpperCamelCase ) if __name__ == "__main__": print(decimal_isolate(1....
76
0
import numpy as np import torch from torch.utils.data import Dataset, IterableDataset from ..utils.generic import ModelOutput class lowerCamelCase__ ( _A): """simple docstring""" def __init__( self : Tuple , __lowerCAmelCase : Optional[int] , __lower...
2
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack __lowercase : set[int] = set() return any( node not in vis...
76
0
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class SCREAMING_SNAKE_CASE__ ( snake_case_): def __init__( self )-> Tuple: '''simple docstring''' self.test() ...
3
"""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_DOCSTRI...
76
0
"""simple docstring""" import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration __UpperCamelCase : Optional[int] = [ # tf -> hf ('''/''', '''.'''), ...
4
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, ...
76
0
'''simple docstring''' from functools import reduce _lowercase = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443...
5
"""simple docstring""" a_ = { 'Pillow': 'Pillow<10.0.0', 'accelerate': 'accelerate>=0.20.3', 'av': 'av==9.2.0', 'beautifulsoup4': 'beautifulsoup4', 'black': 'black~=23.1', 'codecarbon': 'codecarbon==1.2.0', 'cookiecutter': 'cookiecutter==1.7.3', 'd...
76
0
def SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: str , UpperCamelCase__: str ): SCREAMING_SNAKE_CASE__ = len(UpperCamelCase__ ) SCREAMING_SNAKE_CASE__ = len(UpperCamelCase__ ) SCREAMING_SNAKE_CASE__ = [[False for _ in range(m + 1 )] for _ in...
6
"""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/...
76
0
"""simple docstring""" def _snake_case ( _snake_case : str ) -> str: '''simple docstring''' return " ".join( ''.join(word[::-1] ) if len(_snake_case ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest ...
7
"""simple docstring""" import gc import threading import time import psutil import torch class UpperCAmelCase_ : def __init__( self ) -> str: __lowercase : List[Any] = psutil.Process() __lowercase : Any = False def ...
76
0
'''simple docstring''' from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import Gr...
8
"""simple docstring""" import numpy as np import datasets a_ = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distan...
76
0
import os # Precomputes a list of the 100 first triangular numbers SCREAMING_SNAKE_CASE__ = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def A ( ) -> List[str]: A__ = os.path.dirname(os.path.realpath(__UpperCamelCase ) ) A__ = os.path.join(__UpperCamelCase ...
9
"""simple docstring""" a_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def __UpperCAmelCase ( __UpperCamelCase ): # Make sure the supplied data is a bytes-like object if not isinstance(__UpperCamelCase , __UpperCamelCase ): ...
76
0
import torch from torch import nn from transformers import CLIPPreTrainedModel, CLIPVisionModel from ...models.attention import BasicTransformerBlock from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) # pylint: disable=invalid-name class lowerCAmelCase_ ( __lowercase ):...
10
"""simple docstring""" import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'vocab_file': 'vocab.json', ...
76
0
'''simple docstring''' import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_a...
11
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , ...
76
0
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configurat...
12
"""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_ = logging.get_logger(__name__) a...
76
0
'''simple docstring''' import numpy as np import datasets A__ : Tuple = """ Compute the Mahalanobis Distance Mahalonobis distance is the distance between a point and a distribution. And not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distance. It was ...
13
"""simple docstring""" import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput a_ = logging.getLogger(__name__) if...
76
0
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_tokenizati...
14
"""simple docstring""" import math import flax.linen as nn import jax.numpy as jnp def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 1 , __UpperCamelCase = 1 , __UpperCamelCase = 1.0e4 , __UpperCamelCase = False , __UpperCame...
76
0
def UpperCamelCase ( __magic_name__ : Optional[Any] ) -> Optional[int]: """simple docstring""" lowercase__ = [0] * len(__magic_name__ ) lowercase__ = [] lowercase__ = [1] * len(__magic_name__ ) for values in graph.values(): for i in va...
15
"""simple docstring""" import os import sys a_ = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Au...
76
0
import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig __A : List[Any] = logging.get_logger(__name__) class _SCREAMING_SNAKE_CASE : ...
16
"""simple docstring""" from math import pi, sqrt, tan def __UpperCAmelCase ( __UpperCamelCase ): if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def __UpperCAmelCase ...
76
0
import torch from diffusers import DiffusionPipeline class lowerCamelCase_ ( _lowercase ): def __init__( self : Optional[int] , __A : Optional[Any] , __A : Dict ): super().__init__() self.register_modules(unet=__A , scheduler=_...
17
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): # noqa: E741 while r - l > 1: __lowercase : int = (l + r) // 2 if v[m] >= k...
76
0
'''simple docstring''' def __a(SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' _lowerCAmelCase = 0 # if input_string is "aba" than new_input_string become "a|b|a" _lowerCAmelCase = "" _lowerCAmelCase = "" # append eac...
18
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase = 4 ): __lowercase : Dict = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )]...
76
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, res...
19
"""simple docstring""" import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert import BertTokenizer a_ = lo...
76
0
def _lowercase( __a : int ): if not isinstance(__a , __a ): a__ =f"""Input value of [number={number}] must be an integer""" raise TypeError(__a ) if number < 0: return False a__ =number * number while num...
20
"""simple docstring""" import warnings from ...utils import logging from .image_processing_glpn import GLPNImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , **UpperCam...
76
0
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabl...
21
"""simple docstring""" import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def __UpperCAmelCase ( __UpperCamelCase ): # encod...
76
0
'''simple docstring''' import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _snake_case : Any = { 'facebook/mask2former-swin-small-coco-instance': ( 'https:...
22
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, ...
76
0
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py snake_case__ : int = """src/transformers""" sna...
23
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase ): if digit_amount > 0: return round(number - int(__UpperCamelCase ) , __UpperCamelCase ) return number - int(__UpperCamelCase ) if __name__ == "__main__": print(decimal_isolate(1....
76
0
'''simple docstring''' from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def _UpperCamelCase (_lowerCamelCase : float , _lowerCamelCase : float , _lowerCamelCase : bool = False )-> list[float]...
24
"""simple docstring""" def __UpperCAmelCase ( __UpperCamelCase ): __lowercase : set[int] = set() # To detect a back edge, keep track of vertices currently in the recursion stack __lowercase : set[int] = set() return any( node not in vis...
76
0
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = {'vocab_file': 'vocab.json', 'merges_file': 'm...
25
"""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_DOCSTRI...
76
0
'''simple docstring''' import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class _A ( __l...
26
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, ...
76
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available...
27
"""simple docstring""" a_ = { 'Pillow': 'Pillow<10.0.0', 'accelerate': 'accelerate>=0.20.3', 'av': 'av==9.2.0', 'beautifulsoup4': 'beautifulsoup4', 'black': 'black~=23.1', 'codecarbon': 'codecarbon==1.2.0', 'cookiecutter': 'cookiecutter==1.7.3', 'd...
76
0
'''simple docstring''' from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError("To use the rich extension, install rich with `pip install rich`")
28
"""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/...
76
0
"""simple docstring""" import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transform...
29
"""simple docstring""" import gc import threading import time import psutil import torch class UpperCAmelCase_ : def __init__( self ) -> str: __lowercase : List[Any] = psutil.Process() __lowercase : Any = False def ...
76
0
import os import sys import unittest __a = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, 'utils')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_in...
30
"""simple docstring""" import numpy as np import datasets a_ = '\nCompute the Mahalanobis Distance\n\nMahalonobis distance is the distance between a point and a distribution.\nAnd not between two distinct points. It is effectively a multivariate equivalent of the Euclidean distan...
76
0
def UpperCAmelCase_ ( ) -> Tuple: for n in range(1 , 1_00_00_00 ): yield n * (n + 1) // 2 def UpperCAmelCase_ ( __UpperCAmelCase : Union[str, Any] ) -> Union[str, Any]: SCREAMING_SNAKE_CASE_ = 1 SCREAMING_SNAKE_CASE_ = ...
31
"""simple docstring""" a_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def __UpperCAmelCase ( __UpperCamelCase ): # Make sure the supplied data is a bytes-like object if not isinstance(__UpperCamelCase , __UpperCamelCase ): ...
76
0
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass UpperCAmelCase_ = (3, 9, -11, 0, 7, 5, 1, -1) UpperCAmelCase_ = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class __UpperCamelCase : __A : int __A : Node | None...
32
"""simple docstring""" import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'vocab_file': 'vocab.json', ...
76
0
from math import acos, sin from typing import List, Tuple, Union import numpy as np import torch from PIL import Image from ...models import AutoencoderKL, UNetaDConditionModel from ...schedulers import DDIMScheduler, DDPMScheduler from ...utils import randn_tensor from ..pipeline_utils import AudioPi...
33
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , ...
76
0
"""simple docstring""" from __future__ import annotations from typing import Any class snake_case_ ( lowerCamelCase_ ): """simple docstring""" pass class snake_case_ : """simple docstring""" def __init__( self , lowerCamelCase_) -> None:...
34
"""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_ = logging.get_logger(__name__) a...
76
0
def a ( A__ = 1_0_0_0 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE__ : Optional[int] = 3 SCREAMING_SNAKE_CASE__ : Optional[int] = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a ...
35
"""simple docstring""" import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput a_ = logging.getLogger(__name__) if...
76
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .modeling_utils import ...
36
"""simple docstring""" import math import flax.linen as nn import jax.numpy as jnp def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase = 1 , __UpperCamelCase = 1 , __UpperCamelCase = 1.0e4 , __UpperCamelCase = False , __UpperCame...
76
0
from math import pi def UpperCamelCase_ ( __a , __a ) -> float: return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 10))
37
"""simple docstring""" import os import sys a_ = os.path.join(os.path.dirname(__file__), 'src') sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering, Au...
76
0
'''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 from diff...
38
"""simple docstring""" from math import pi, sqrt, tan def __UpperCAmelCase ( __UpperCamelCase ): if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def __UpperCAmelCase ...
76
0
import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class snake_case_ ( __A , unittest.TestCase ): '''simple docstring'...
39
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase , __UpperCamelCase ): # noqa: E741 while r - l > 1: __lowercase : int = (l + r) // 2 if v[m] >= k...
76
0