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
from __future__ import annotations import math 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...
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 ): '''simple docstring''' __lowercase = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
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 json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached_file, get...
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 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
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 zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def snake_case ( lowerCamelCase , lowerCamelCase=7 ): '''simple docstring''' __lowercase = None if token is not None: __lowercase = {"""Accep...
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
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multiple reposi...
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 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
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 gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import load_numpy,...
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
def snake_case ( lowerCamelCase ): '''simple docstring''' if number < 0: raise ValueError("""number must not be negative""" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
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
import numpy as np class __UpperCamelCase : def __init__( self : Optional[int] ) -> Dict: """simple docstring""" __lowercase = (0, 0) __lowercase = None __lowercase = 0 __lowercase = 0 __lowercase = 0 def __...
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 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
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''' __lowercase = len(lowerCamelCase ) while cur > 1: # Find the maximum number in arr __lowercase = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi __lowercase = arr[mi::-1] +...
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 os import sys import unittest __UpperCamelCase : Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get_model_...
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 pathlib import Path import fire def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = Path(lowerCamelCase ) __lowercase = Path(lowerCamelCase ) dest_dir.mkdir(exist_ok=lowerCamelCase ...
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 itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness __UpperCamelCase : int = """\ @misc{chen2021evaluating, title={Evaluating Large ...
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 __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase = 10**-10 ): '''simple docstring''' __lowercase = a while True: __lowercase ...
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 time import warnings from abc import ABC from copy import deepcopy from typing import Optional import torch from ..utils import add_start_docstrings, logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : Union[str, Any] = r""" Args: in...
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 typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase : List[Any] = { """configuration_longformer""": [ """LONGFORMER_PRETRAINED_CONFIG_AR...
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
__UpperCamelCase : List[str] = """Alexander Joslin""" import operator as op from .stack import Stack def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = {"""*""": op.mul, """/""": op.truediv, """+""": op.add, """-""": op.sub} __lowercase ...
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
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices __UpperCamelCase : Any = logging.get_logger(__name__) __UpperCamelCase : Any = { """facebook/convnext...
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 List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _...
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 typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import ( BackboneOutput, BaseModelOutputWithNoAttention, BaseModelOutputWi...
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 argparse import os import torch from transformers import FlavaImageCodebook, FlavaImageCodebookConfig def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = s.rsplit(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
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
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 argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel __UpperCamelCase : Dict = { """text_branch""": """text_model""", """audio_branch""": """audio_model.audio_encoder""", """attn""": """attention.self...
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 collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCamelCase : Tuple = logging.get_logger(__name__) __UpperCamelCase : Union[str, Any] = { """bert-bas...
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 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
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 copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : int = { """ut/deta""": """https://huggingface.co/ut/deta/resolve/main/c...
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
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
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 itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): fr...
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
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class __UpperCamelCase ( nn.Module ): __snake_case :int __snake_case :int __snake_case :float = 0....
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 List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_util...
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 json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils i...
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
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path __UpperCamelCase : Optional[Any] = Path(__file__).resolve().parents[3] / """src""" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa...
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 secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def snake_case ( lowerCamelCase = 8 ): '''simple docstring''' __lowercase = ascii_letters + digits + punctuation return "".join(secrets.choice(...
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 typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase : Dict = { """configuration_xlm_roberta_xl""": [ """XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMRobertaXLConfig""", """XLMRo...
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''' if not head: return True # split the list to two parts __lowercase , __lowercase = head.next, head while fast and fast.next: __lowercase = fast.next.next __lowercase = slow.next __lowe...
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 math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import Conf...
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 def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' if (direction == 1 and array[indexa] > array[indexa]) or ( direction == 0 and array[indexa] < array[indexa] ): __lowerc...
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 unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __UpperCamelCase ( unittest.TestCase ): @pr...
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
def snake_case ( ): '''simple docstring''' for n in range(1 , 1_000_000 ): yield n * (n + 1) // 2 def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = 1 __lowercase = 2 while i * i <= n: __lowercase = 0...
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
from bisect import bisect from itertools import accumulate def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = sorted(zip(lowerCamelCase , lowerCamelCase ) , key=lambda lowerCam...
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
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
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 warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class __UpperCamelCase ( _lowerCAmelCase ): __...
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 os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand __UpperCamelCase : Optional[int] = ( """4S 3H 2C 7S 5H""", """9D 8H 2C 6S 7H""", """2D 6D 9D TH 7D""", """TC 8C 2S JH 6C""", """JH 8S TH AH QH""", """TS KS ...
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 json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset __UpperCamelCase : Optional[Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1...
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
def snake_case ( lowerCamelCase ): '''simple docstring''' if len(lowerCamelCase ) <= 1: return [tuple(lowerCamelCase )] __lowercase = [] def generate(lowerCamelCase , lowerCamelCase ): if k == 1: res.append(tuple(arr[:] ) ) return ...
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
import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorch_model from transforme...
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 unittest from transformers import XLMConfig, 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 ...test_modeling_common import ModelTesterMixin, ...
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 os import time import pytest from datasets.utils.filelock import FileLock, Timeout def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = FileLock(str(tmpdir / """foo.lock""" ) ) __lowercase = FileLock(str(tmpdir / """foo.lock...
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
from math import isclose, sqrt def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = point_y / 4 / point_x __lowercase = 2 * normal_gradient / (1 + normal_gradient * normal_gradient) __lowercase ...
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
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
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
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version __UpperCamelCase : Optional[int] = version.parse(importlib_metadata.version("""nltk""")) if NLTK_VERSION >= version.Version("""3.6.4"""): from nltk import word_t...
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 gc import unittest from transformers import CTRLConfig, 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 ...test_modeling_common import ModelTe...
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_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __UpperCamelCase : Optional[int] = { """configuration_rembert""": ["""REMBERT...
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
def snake_case ( lowerCamelCase ): '''simple docstring''' return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print("""Program to check whether a number is a Perfect number or not...""") __UpperCamelCas...
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
__UpperCamelCase : int = tuple[float, float, float] __UpperCamelCase : Optional[int] = tuple[float, float, float] def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = end_pointa[0] - end_pointa[0] __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 re def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = re.compile( r"""^(?:0|94|\+94|0{2}94)""" r"""7(0|1|2|4|5|6|7|8)""" r"""(-| |)""" r"""\d{7}$""" ) return bool(re.search(lowerCamelCase , lowerCamelCase ) ) if __n...
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 __future__ import annotations def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = sorted(numsa + numsa ) __lowercase , __lowercase = divmod(len(lowerCamelCase ) , 2 ) if mod == 1: retu...
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 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
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 __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class __UpperCamelCase ( _lowerCAmelCase ): def _a ( self : Union[str, Any] , _lowerCAmelCase : float ) -> float: """simpl...
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 builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP __UpperCamelCase : List[Any] = False try: __UpperCamel...
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 from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_utils import OnnxRunti...
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 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
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 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
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
class __UpperCamelCase : # Public class to implement a graph def __init__( self : str , _lowerCAmelCase : int , _lowerCAmelCase : int , _lowerCAmelCase : list[list[bool]] ) -> None: """simple docstring""" __lowercase ...
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 pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaskedLM, XLMRobertaXLForSequence...
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
def snake_case ( lowerCamelCase ): '''simple docstring''' if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __lowercase = sorted(string.lower() ) return len(lowerCamelCase ) == len(set(...
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
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class __UpperCamelCase ( pl.LightningModule ): def __init__( self : Any , _lowerCAmelCase : Optional[Any] ) -...
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_tf_available, is_torch_available, is_vision_available, ) __UpperCamelCase : Optional[Any] = { """configuration_convnext""": ["""CONVNEXT_PRETRAINED_CONFIG_ARCHIVE_MAP""",...
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 json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, require_torch_multi_gpu, ) lo...
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 unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_tokenization_common 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
from __future__ import annotations from math import ceil, floor, sqrt def snake_case ( lowerCamelCase = 2_000_000 ): '''simple docstring''' __lowercase = [0] __lowercase = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangl...
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 __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, r...
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 functools import lru_cache def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = 2 __lowercase = set() while i * i <= n: if n % i: i += 1 else: n //= i factors.add(lowerCamelCase ) if n > 1: factors.add(lowerCamelCase ...
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 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
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 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
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 argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTensor from accelerate import Ac...
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 typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCamelCase : Tuple = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig""", """Gro...
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 class __UpperCamelCase : def __init__( self : Dict , _lowerCAmelCase : int ) -> None: """simple docstring""" __lowercase = data __lowercase = None __lowercase = None def snake_c...
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 typing import Optional import pyspark from .. import Features, NamedSplit from ..download import DownloadMode from ..packaged_modules.spark.spark import Spark from .abc import AbstractDatasetReader class __UpperCamelCase ( _lowerCAmelCase ): def __init__( self : List[str] ...
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
def snake_case ( lowerCamelCase , lowerCamelCase , lowerCamelCase ): '''simple docstring''' def count_of_possible_combinations(lowerCamelCase ) -> int: if target < 0: return 0 if target == 0: return 1 return sum(count_of_possible_combinations(target - item ...
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 __future__ import annotations def snake_case ( lowerCamelCase ): '''simple docstring''' if not nums: raise ValueError("""List is empty""" ) return sum(lowerCamelCase ) / len(lowerCamelCase ) if __name__ == "__main__": import doctest doctest.t...
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
def snake_case ( lowerCamelCase , lowerCamelCase ): '''simple docstring''' __lowercase = len(lowerCamelCase ) + 1 __lowercase = len(lowerCamelCase ) + 1 # dp is a 2d matrix where dp[i][j] denotes whether prefix string of # length i of input_string ma...
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 inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import C...
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 isqrt 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
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 from typing import Any class __UpperCamelCase : def __init__( self : Optional[Any] , _lowerCAmelCase : int , _lowerCAmelCase : int , _lowerCAmelCase : float = 0 ) -> None: """simple docstring""" ...
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 ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : int = { """caidas/swin2sr-classicalsr-x2-64""": ( """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/r...
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 shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartTokenizer, MBartTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) ...
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
# # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnodes 1 torch-distributed-...
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 __future__ import annotations from collections.abc import MutableSequence class __UpperCamelCase : def __init__( self : Optional[Any] , _lowerCAmelCase : int , _lowerCAmelCase : MutableSequence[float] ) -> None: """simple docstring""" ...
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 __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import Con...
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
from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, va...
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 unittest import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DDPMScheduler, PriorTransformer, StableUnCLIPPipeline, UNetaDConditionModel, ) from diffusers.p...
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 copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=_lowerCAmelCase ) class __UpperCamelCase ( _lowerCAmelCase ): __snake_case :str = field(default='au...
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 Generator from math import sin def snake_case ( lowerCamelCase ): '''simple docstring''' if len(lowerCamelCase ) != 32: raise ValueError("""Input must be of length 32""" ) __lowercase = b"""""" for i in [3, 2, 1, 0]: little_end...
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 __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class __UpperCamelCase : __snake_case :int __snake_case :int class __UpperCamelCase : def __init__( self : Any ...
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
def snake_case ( lowerCamelCase ): '''simple docstring''' for i in range(len(lowerCamelCase ) - 1 , 0 , -1 ): __lowercase = False for j in range(lowerCamelCase , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: __lowercase , __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
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
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