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
import os # Precomputes a list of the 100 first triangular numbers __UpperCamelCase : Dict = [int(0.5 * n * (n + 1)) for n in range(1, 101)] def snake_case ( ): '''simple docstring''' __lowercase = os.path.dirname(os.path.realpath(lowerCamelCase ) ) __lo...
80
from sklearn.metrics import matthews_corrcoef import datasets __UpperCamelCase : Union[str, Any] = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes...
80
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_torch, require_vision from transformers.uti...
80
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Dict = { """vocab_file""": """vocab...
80
1
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils import FrozenDi...
80
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : int = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", ...
80
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
80
import os import tempfile import unittest from transformers import DistilBertConfig, 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_common import ModelTesterMixin, ids_ten...
80
1
from __future__ import annotations from dataclasses import dataclass @dataclass class __UpperCamelCase : __snake_case :float __snake_case :TreeNode | None = None __snake_case :TreeNode | None = None def snake_case ( lowerCamelCase ): '''simple doc...
80
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class __UpperCamelCase ( _lowerCAmelCase ): # to overwrite at feature extractactor specific tests...
80
1
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): ...
80
def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = [[] for _ in range(lowerCamelCase )] __lowercase = key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""" ) if key == 1 or len(lower...
80
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import logging loggi...
80
def snake_case ( lowerCamelCase = 2_000_000 ): '''simple docstring''' __lowercase = [0 for i in range(n + 1 )] __lowercase = 1 __lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in range(i * i ...
80
1
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __UpperCamelCase : Dict = logging.get_logger(__name__) class __UpperCamelCase ( _lowerCAmelCase , _...
80
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import ...
80
1
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_...
80
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __UpperCamelCase ( unittest.TestCase ): def _a ( self : List[str] ) -> str: """sim...
80
1
def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase = 0 , lowerCamelCase = 0 ): '''simple docstring''' __lowercase = right or len(lowerCamelCase ) - 1 if left > right: return -1 elif list_data[left] == key: return left elif list_data[right]...
80
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Optional[Any] = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConfig"""], "...
80
1
def snake_case ( lowerCamelCase = 10 , lowerCamelCase = 1_000 , lowerCamelCase = True ): '''simple docstring''' assert ( isinstance(lowerCamelCase , lowerCamelCase ) and isinstance(lowerCamelCase , lowerCamelCase ) and isinstance(lowerCamelCase ...
80
import os from collections.abc import Iterator def snake_case ( lowerCamelCase = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(lowerCamelCase ): __lowercase = [d for d in dir_names if d != """scripts""" and d[0] not in """._"""] for f...
80
1
import numpy as np import torch from imwatermark import WatermarkEncoder # Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66 __UpperCamelCase : List[str] = 0B10_11_00_11_11_10_11_00_10_01_00_00_01_11_10_...
80
from math import factorial def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' if n < k or k < 0: raise ValueError("""Please enter positive integers for n and k where n >= k""" ) return factorial(lowerCamelCase ) // (factorial(lowerCamelCase...
80
1
import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.utils import write_b...
80
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def snake_case ( ): '''simple docstring''' __lowercase = [randint(-1_000 , 1_000 ) for i in range(10 )] __lowercase = randint(-5_0...
80
1
def snake_case ( lowerCamelCase = 1_000 ): '''simple docstring''' __lowercase = 2**power __lowercase = str(lowerCamelCase ) __lowercase = list(lowerCamelCase ) __lowercase = 0 for i in list_num: sum_of_num += int(lowerCamelCase ...
80
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever __UpperCamelCase : Union[str, Any] = logging.getLogger(__name__) class __UpperCamelCase ( _lowerCAmelCase ): ...
80
1
from __future__ import annotations def snake_case ( lowerCamelCase ): '''simple docstring''' return len(set(lowerCamelCase ) ) == len(lowerCamelCase ) if __name__ == "__main__": import doctest doctest.testmod()
80
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ): __snake_c...
80
1
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class __UpperCamelCase ...
80
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __UpperCamelCase : Tuple = TypeVar("""T""") class __UpperCamelCase ( Generic[T] ): def __init__( self : Optional[Any] , _lowerCAmelCase : T ) -...
80
1
import torch def snake_case ( ): '''simple docstring''' if torch.cuda.is_available(): __lowercase = torch.cuda.device_count() else: __lowercase = 0 print(F'Successfully ran on {num_gpus} GPUs' ) if __name__ == "__main__": main()
80
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __UpperCamelCase : Union[str, Any] = False class __UpperCamelCase ...
80
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : List[str] = logging.get_logger(__name__) __UpperCamelCase : Dict = { """asapp/sew-tiny-100k""": """https://huggingface.co/asapp/sew-tiny-100k/resolv...
80
from __future__ import annotations from collections.abc import MutableSequence class __UpperCamelCase : def __init__( self : Optional[Any] , _lowerCAmelCase : int , _lowerCAmelCase : MutableSequence[float] ) -> None: """simple docstring""" ...
80
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, PNDMScheduler, StableDiffusionInpaintPipeline, UNetaDConditionModel from diffusers.utils import floats_tensor,...
80
def snake_case ( lowerCamelCase ): '''simple docstring''' if collection == []: return [] # get some information about the collection __lowercase = len(lowerCamelCase ) __lowercase = max(lowerCamelCase ) __lowercase = min(lowerCamelCase ...
80
1
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore __UpperCamelCase : Any = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" __UpperCamelCase : Tuple = [file ...
80
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from .....
80
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : List[Any] = logging.get_logger(__name__) __UpperCamelCase : str = { """sayakpaul/vit-msn-base""": """https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json""", # ...
80
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES __UpperCamelCase : List[str] = logging.get_logger(__name__) __UpperCamelCase : List[str] ...
80
1
def snake_case ( lowerCamelCase ): '''simple docstring''' return 10 - x * x def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' if equation(lowerCamelCase ) * equation(lowerCamelCase ) >= 0: raise ValueError("""Wrong ...
80
from typing import TYPE_CHECKING from ...utils import _LazyModule __UpperCamelCase : int = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys __Upp...
80
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCamelCase : List[Any] = { """configuration_perceiver""": ["""PERCEIVER_PRETRAINED_CONFIG_ARCHIVE_M...
80
from sklearn.metrics import matthews_corrcoef import datasets __UpperCamelCase : Union[str, Any] = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes...
80
1
from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean __UpperCamelCase : List[Any] = 0 __UpperCamelCase : Optional[int] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0,...
80
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Dict = { """vocab_file""": """vocab...
80
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase : Union[str, Any] = {} try: if not is_sentencepiece_available(): r...
80
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : int = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", ...
80
1
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import floats_tenso...
80
import os import tempfile import unittest from transformers import DistilBertConfig, 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_common import ModelTesterMixin, ids_ten...
80
1
from __future__ import annotations import numpy as np def snake_case ( lowerCamelCase ): '''simple docstring''' return np.maximum(0 , lowerCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
80
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class __UpperCamelCase ( _lowerCAmelCase ): # to overwrite at feature extractactor specific tests...
80
1
from math import ceil, sqrt def snake_case ( lowerCamelCase = 1_000_000 ): '''simple docstring''' __lowercase = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: __lowercase = max(ceil(sqrt(outer_width**2 - limit )...
80
def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = [[] for _ in range(lowerCamelCase )] __lowercase = key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""" ) if key == 1 or len(lower...
80
1
from collections import deque class __UpperCamelCase : def __init__( self : Union[str, Any] , _lowerCAmelCase : str , _lowerCAmelCase : int , _lowerCAmelCase : int ) -> None: """simple docstring""" __lowercase = pr...
80
def snake_case ( lowerCamelCase = 2_000_000 ): '''simple docstring''' __lowercase = [0 for i in range(n + 1 )] __lowercase = 1 __lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in range(i * i ...
80
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : int = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", ...
80
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import ...
80
1
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu __UpperCamelCase : str = get_...
80
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __UpperCamelCase ( unittest.TestCase ): def _a ( self : List[str] ) -> str: """sim...
80
1
import math def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = [] __lowercase = 2 __lowercase = int(math.sqrt(lowerCamelCase ) ) # Size of every segment __lowercase = [True] * (end + 1) __lowercase = ...
80
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Optional[Any] = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConfig"""], "...
80
1
from math import asin, atan, cos, radians, sin, sqrt, tan __UpperCamelCase : Optional[Any] = 6_3_7_8_1_3_7.0 __UpperCamelCase : Tuple = 6_3_5_6_7_5_2.3_1_4_2_4_5 __UpperCamelCase : Any = 6378137 def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelC...
80
import os from collections.abc import Iterator def snake_case ( lowerCamelCase = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(lowerCamelCase ): __lowercase = [d for d in dir_names if d != """scripts""" and d[0] not in """._"""] for f...
80
1
import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available, logging from .ben...
80
from math import factorial def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' if n < k or k < 0: raise ValueError("""Please enter positive integers for n and k where n >= k""" ) return factorial(lowerCamelCase ) // (factorial(lowerCamelCase...
80
1
import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import numpy as np from utils_multiple_choice import MultipleChoiceDataset, Split, processors import transformers from transformers import ( AutoConfig, AutoModelForMultipleChoice, AutoTokenizer, ...
80
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def snake_case ( ): '''simple docstring''' __lowercase = [randint(-1_000 , 1_000 ) for i in range(10 )] __lowercase = randint(-5_0...
80
1
def snake_case ( lowerCamelCase = 100 ): '''simple docstring''' __lowercase = n * (n + 1) * (2 * n + 1) / 6 __lowercase = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F'''{solution() = }''')
80
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever __UpperCamelCase : Union[str, Any] = logging.getLogger(__name__) class __UpperCamelCase ( _lowerCAmelCase ): ...
80
1
import inspect import unittest import numpy as np from tests.test_modeling_common import floats_tensor from transformers import DetrConfig, MaskFormerConfig, SwinConfig, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, ...
80
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ): __snake_c...
80
1
from maths.prime_check import is_prime def snake_case ( lowerCamelCase ): '''simple docstring''' if not isinstance(lowerCamelCase , lowerCamelCase ): __lowercase = F'Input value of [number={number}] must be an integer' raise TypeError(lowerCamelCase ) i...
80
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __UpperCamelCase : Tuple = TypeVar("""T""") class __UpperCamelCase ( Generic[T] ): def __init__( self : Optional[Any] , _lowerCAmelCase : T ) -...
80
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __UpperCamelCase : int = {"""configuration_speech_encoder_decoder""": ["""SpeechEncoderDecoderConfig"""]} try: if not is_torch_available(): ra...
80
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __UpperCamelCase : Union[str, Any] = False class __UpperCamelCase ...
80
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, PNDMScheduler, StableDiffusionLDMaDPipeline, UNetaDConditionModel, ) from diffusers.utils import nightly, slo...
80
from __future__ import annotations from collections.abc import MutableSequence class __UpperCamelCase : def __init__( self : Optional[Any] , _lowerCAmelCase : int , _lowerCAmelCase : MutableSequence[float] ) -> None: """simple docstring""" ...
80
1
from pathlib import Path import fire from tqdm import tqdm def snake_case ( lowerCamelCase="ro" , lowerCamelCase="en" , lowerCamelCase="wmt16" , lowerCamelCase=None ): '''simple docstring''' try: import datasets except (ModuleNotFoundError, ImportError): raise Impo...
80
def snake_case ( lowerCamelCase ): '''simple docstring''' if collection == []: return [] # get some information about the collection __lowercase = len(lowerCamelCase ) __lowercase = max(lowerCamelCase ) __lowercase = min(lowerCamelCase ...
80
1
import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import...
80
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from .....
80
1
from collections.abc import Sequence from queue import Queue class __UpperCamelCase : def __init__( self : Optional[Any] , _lowerCAmelCase : Tuple , _lowerCAmelCase : List[Any] , _lowerCAmelCase : Union[str, Any] , _lowerCAmelCase ...
80
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES __UpperCamelCase : List[str] = logging.get_logger(__name__) __UpperCamelCase : List[str] ...
80
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __UpperCamelCase : Any = { """configuration_swiftformer""": [ """SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwiftFormerConfig""", ...
80
from typing import TYPE_CHECKING from ...utils import _LazyModule __UpperCamelCase : int = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys __Upp...
80
1
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils import loggi...
80
from sklearn.metrics import matthews_corrcoef import datasets __UpperCamelCase : Union[str, Any] = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes...
80
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Optional[Any] = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConfig"""], "...
80
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Dict = { """vocab_file""": """vocab...
80
1
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class __UpperCamelCase ( unittest.TestCase...
80
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : int = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", ...
80
1
def snake_case ( lowerCamelCase = 1_000 ): '''simple docstring''' return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
80
import os import tempfile import unittest from transformers import DistilBertConfig, 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_common import ModelTesterMixin, ids_ten...
80
1
from ... import PretrainedConfig __UpperCamelCase : int = { """sijunhe/nezha-cn-base""": """https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json""", } class __UpperCamelCase ( _lowerCAmelCase ): __snake_case :Any = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP ...
80
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class __UpperCamelCase ( _lowerCAmelCase ): # to overwrite at feature extractactor specific tests...
80
1
from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, blenderbot, blen...
80
def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = [[] for _ in range(lowerCamelCase )] __lowercase = key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""" ) if key == 1 or len(lower...
80
1
import os from collections.abc import Iterator def snake_case ( lowerCamelCase = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(lowerCamelCase ): __lowercase = [d for d in dir_names if d != """scripts""" and d[0] not in """._"""] for f...
80
def snake_case ( lowerCamelCase = 2_000_000 ): '''simple docstring''' __lowercase = [0 for i in range(n + 1 )] __lowercase = 1 __lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in range(i * i ...
80
1
import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin __UpperCamelCase : int = get_tests_dir("""fixtures/test_sent...
80
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import ...
80
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __UpperCamelCase : Union[str, Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvai...
80
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __UpperCamelCase ( unittest.TestCase ): def _a ( self : List[str] ) -> str: """sim...
80
1
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class __UpperCamelCase (...
80
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Optional[Any] = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConfig"""], "...
80
1
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table im...
80
import os from collections.abc import Iterator def snake_case ( lowerCamelCase = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(lowerCamelCase ): __lowercase = [d for d in dir_names if d != """scripts""" and d[0] not in """._"""] for f...
80
1
from __future__ import annotations __UpperCamelCase : Optional[Any] = list[list[int]] # assigning initial values to the grid __UpperCamelCase : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], ...
80
from math import factorial def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' if n < k or k < 0: raise ValueError("""Please enter positive integers for n and k where n >= k""" ) return factorial(lowerCamelCase ) // (factorial(lowerCamelCase...
80
1
def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = set() # To detect a back edge, keep track of vertices currently in the recursion stack __lowercase = set() return any( node not in visited and depth_first_search(lowerCamelCase , lowerCa...
80
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def snake_case ( ): '''simple docstring''' __lowercase = [randint(-1_000 , 1_000 ) for i in range(10 )] __lowercase = randint(-5_0...
80
1
from math import sqrt def snake_case ( lowerCamelCase ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False #...
80
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever __UpperCamelCase : Union[str, Any] = logging.getLogger(__name__) class __UpperCamelCase ( _lowerCAmelCase ): ...
80
1
from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class __UpperCamelCase ( _lowerCAmelCase ): ...
80
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ): __snake_c...
80
1
def snake_case ( lowerCamelCase ): '''simple docstring''' return "".join([hex(lowerCamelCase )[2:].zfill(2 ).upper() for byte in list(lowerCamelCase )] ) def snake_case ( lowerCamelCase ): '''simple docstring''' if (len(lowerCamelCase...
80
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __UpperCamelCase : Tuple = TypeVar("""T""") class __UpperCamelCase ( Generic[T] ): def __init__( self : Optional[Any] , _lowerCAmelCase : T ) -...
80
1
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_cp from torch.distributed.checkpo...
80
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __UpperCamelCase : Union[str, Any] = False class __UpperCamelCase ...
80
1
__UpperCamelCase : Optional[int] = frozenset( [ """prompt""", """height""", """width""", """guidance_scale""", """negative_prompt""", """prompt_embeds""", """negative_prompt_embeds""", """cross_attention_kwargs""", ] ) __UpperCa...
80
from __future__ import annotations from collections.abc import MutableSequence class __UpperCamelCase : def __init__( self : Optional[Any] , _lowerCAmelCase : int , _lowerCAmelCase : MutableSequence[float] ) -> None: """simple docstring""" ...
80
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
80
def snake_case ( lowerCamelCase ): '''simple docstring''' if collection == []: return [] # get some information about the collection __lowercase = len(lowerCamelCase ) __lowercase = max(lowerCamelCase ) __lowercase = min(lowerCamelCase ...
80
1
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging __UpperCamelCase : Optional[int] = loggi...
80
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from .....
80
1
from itertools import product def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = sides_number __lowercase = max_face_number * dice_number __lowercase = [0] * (max_total + 1) __lowercase = 1 __lowercas...
80
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES __UpperCamelCase : List[str] = logging.get_logger(__name__) __UpperCamelCase : List[str] ...
80
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : List[Any] = { """EleutherAI/gpt-neox-20b""": """https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.json""", ...
80
from typing import TYPE_CHECKING from ...utils import _LazyModule __UpperCamelCase : int = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys __Upp...
80
1
import sys from collections import defaultdict class __UpperCamelCase : def __init__( self : Any ) -> Tuple: """simple docstring""" __lowercase = [] def _a ( self : int , _lowerCAmelCase : Tuple ) -> Dict: """simple do...
80
from sklearn.metrics import matthews_corrcoef import datasets __UpperCamelCase : Union[str, Any] = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes...
80
1
def snake_case ( lowerCamelCase ): '''simple docstring''' return "".join(chr(ord(lowerCamelCase ) - 32 ) if """a""" <= char <= """z""" else char for char in word ) if __name__ == "__main__": from doctest import testmod testmod()
80
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Dict = { """vocab_file""": """vocab...
80
1
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, ...
80
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : int = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", ...
80
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Dict = logging.get_logger(__name__) __UpperCamelCase : Dict = { """SCUT-DLVCLab/lilt-roberta-en-base""": ( """https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve...
80
import os import tempfile import unittest from transformers import DistilBertConfig, 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_common import ModelTesterMixin, ids_ten...
80
1
def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = [0] * len(lowerCamelCase ) __lowercase = [] __lowercase = [] __lowercase = 0 for values in graph.values(): for i in values: indegree[i] += 1 for i in range(len(lo...
80
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class __UpperCamelCase ( _lowerCAmelCase ): # to overwrite at feature extractactor specific tests...
80
1
__UpperCamelCase : Tuple = { """a""": """AAAAA""", """b""": """AAAAB""", """c""": """AAABA""", """d""": """AAABB""", """e""": """AABAA""", """f""": """AABAB""", """g""": """AABBA""", """h""": """AABBB""", """i""": """ABAAA""", """j""": """BBBAA""", """k""":...
80
def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = [[] for _ in range(lowerCamelCase )] __lowercase = key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""" ) if key == 1 or len(lower...
80
1
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def snake_case ( ): '''simple docstring''' __lowercase = [randint(-1_000 , 1_000 ) for i in range(10 )] __lowercase = randint(-5_0...
80
def snake_case ( lowerCamelCase = 2_000_000 ): '''simple docstring''' __lowercase = [0 for i in range(n + 1 )] __lowercase = 1 __lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in range(i * i ...
80
1
def snake_case ( lowerCamelCase = 2_000_000 ): '''simple docstring''' __lowercase = [0 for i in range(n + 1 )] __lowercase = 1 __lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in range(i * i ...
80
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import ...
80
1
import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization import from_bytes, to_byt...
80
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __UpperCamelCase ( unittest.TestCase ): def _a ( self : List[str] ) -> str: """sim...
80
1
import argparse import json import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( VideoMAEConfig, VideoMAEForPreTraining, VideoMAEForVideoClassification, VideoMAEImageProcessor, ) def snake_case ( lowerCamelCase ): ...
80
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Optional[Any] = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConfig"""], "...
80
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __UpperCamelCase : Dict = { """configuration_mega""": ["""MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MegaConfig""", """MegaOnnxConfig"""], } try: if not ...
80
import os from collections.abc import Iterator def snake_case ( lowerCamelCase = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(lowerCamelCase ): __lowercase = [d for d in dir_names if d != """scripts""" and d[0] not in """._"""] for f...
80
1
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester fr...
80
from math import factorial def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' if n < k or k < 0: raise ValueError("""Please enter positive integers for n and k where n >= k""" ) return factorial(lowerCamelCase ) // (factorial(lowerCamelCase...
80
1
from math import isqrt, loga def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , lowerCamelCase , lowerCamelCase ...
80
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def snake_case ( ): '''simple docstring''' __lowercase = [randint(-1_000 , 1_000 ) for i in range(10 )] __lowercase = randint(-5_0...
80
1
import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": __UpperCamelCase : Tuple = argparse.ArgumentParser() parser.add_argument( """--checkpoint_path""", default...
80
import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever __UpperCamelCase : Union[str, Any] = logging.getLogger(__name__) class __UpperCamelCase ( _lowerCAmelCase ): ...
80
1
import logging import random import ray from transformers import RagConfig, RagRetriever, RagTokenizer from transformers.models.rag.retrieval_rag import CustomHFIndex __UpperCamelCase : str = logging.getLogger(__name__) class __UpperCamelCase : def __init__( self : Union...
80
import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ): __snake_c...
80
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : List[Any] = logging.get_logger(__name__) __UpperCamelCase : Tuple = { """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config.json""", # Se...
80
from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar __UpperCamelCase : Tuple = TypeVar("""T""") class __UpperCamelCase ( Generic[T] ): def __init__( self : Optional[Any] , _lowerCAmelCase : T ) -...
80
1
from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neuroncore, ) from tran...
80
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __UpperCamelCase : Union[str, Any] = False class __UpperCamelCase ...
80
1
def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = [[] for _ in range(lowerCamelCase )] __lowercase = key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""" ) if key == 1 or len(lower...
80
from __future__ import annotations from collections.abc import MutableSequence class __UpperCamelCase : def __init__( self : Optional[Any] , _lowerCAmelCase : int , _lowerCAmelCase : MutableSequence[float] ) -> None: """simple docstring""" ...
80
1
import operator as op __UpperCamelCase : int = """scaler.pt""" __UpperCamelCase : int = """pytorch_model""" __UpperCamelCase : Union[str, Any] = """random_states""" __UpperCamelCase : Any = """optimizer""" __UpperCamelCase : Tuple = """scheduler""" __...
80
def snake_case ( lowerCamelCase ): '''simple docstring''' if collection == []: return [] # get some information about the collection __lowercase = len(lowerCamelCase ) __lowercase = max(lowerCamelCase ) __lowercase = min(lowerCamelCase ...
80
1
from __future__ import annotations from fractions import Fraction def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' return ( num != den and num % 10 == den // 10 and (num // 10) / (den % 10) == num / den ) def snake_case ( lowerCamelCas...
80
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from .....
80
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCamelCase : List[str] = logging.get_logger(__name__) __UpperCamelCase : Tuple = { """google/bigbird...
80
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES __UpperCamelCase : List[str] = logging.get_logger(__name__) __UpperCamelCase : List[str] ...
80
1
def snake_case ( lowerCamelCase ): '''simple docstring''' return str(lowerCamelCase ) == str(lowerCamelCase )[::-1] def snake_case ( lowerCamelCase ): '''simple docstring''' return int(lowerCamelCase ) + int(str(lowerCamelCase )[::-1]...
80
from typing import TYPE_CHECKING from ...utils import _LazyModule __UpperCamelCase : int = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys __Upp...
80
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __UpperCamelCase : Dict = { """configuration_mask2former""": [ """MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Mask2FormerConfig""", ...
80
from sklearn.metrics import matthews_corrcoef import datasets __UpperCamelCase : Union[str, Any] = """ Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes...
80
1
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_squeezebert import SqueezeBertTokenizer __UpperCamelCase : Union[str, Any] = logging.get_logger(__...
80
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __UpperCamelCase : str = logging.get_logger(__name__) __UpperCamelCase : Dict = { """vocab_file""": """vocab...
80
1
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase = "x" , lowerCamelCase = 10**-10 , lowerCamelCase = 1 , ): '''simple docstring''' __lowercase = symbols(lowe...
80
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : int = { """unc-nlp/lxmert-base-uncased""": """https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json""", ...
80
1
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class __UpperCamelCase ( unittest.TestCase ): def _a ( self : Dict ) -> Tuple: """simple docstring""" __lowercase ...
80
import os import tempfile import unittest from transformers import DistilBertConfig, 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_common import ModelTesterMixin, ids_ten...
80
1
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transformers.testing_utils import TOKEN, USER, get_tes...
80
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class __UpperCamelCase ( _lowerCAmelCase ): # to overwrite at feature extractactor specific tests...
80
1
import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import...
80
def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = [[] for _ in range(lowerCamelCase )] __lowercase = key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""" ) if key == 1 or len(lower...
80
1
from __future__ import annotations import math class __UpperCamelCase : def __init__( self : List[str] , _lowerCAmelCase : int ) -> None: """simple docstring""" __lowercase = size # approximate the overall size of segment tree with given val...
80
def snake_case ( lowerCamelCase = 2_000_000 ): '''simple docstring''' __lowercase = [0 for i in range(n + 1 )] __lowercase = 1 __lowercase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j in range(i * i ...
80
1
class __UpperCamelCase : def __init__( self : List[Any] , _lowerCAmelCase : int , _lowerCAmelCase : List[Any] ) -> List[Any]: """simple docstring""" __lowercase = name __lowercase = val def __str__( self : U...
80
import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available from ...test_backbone_common import ...
80
1
import os import time import numpy as np import onnxruntime as ort __UpperCamelCase : int = """1""" __UpperCamelCase : Dict = """0""" __UpperCamelCase : str = """1""" __UpperCamelCase : int = ort.SessionOptions() __UpperCamelCase : Dict = ort.GraphO...
80
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class __UpperCamelCase ( unittest.TestCase ): def _a ( self : List[str] ) -> str: """sim...
80
1
import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transformers.utils import lo...
80
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Optional[Any] = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConfig"""], "...
80
1
import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock from .logging import get_l...
80
import os from collections.abc import Iterator def snake_case ( lowerCamelCase = "." ): '''simple docstring''' for dir_path, dir_names, filenames in os.walk(lowerCamelCase ): __lowercase = [d for d in dir_names if d != """scripts""" and d[0] not in """._"""] for f...
80
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
80
from math import factorial def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' if n < k or k < 0: raise ValueError("""Please enter positive integers for n and k where n >= k""" ) return factorial(lowerCamelCase ) // (factorial(lowerCamelCase...
80
1