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 random import unittest import torch from diffusers import IFInpaintingPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_GUIDED_IMAGE_INPA...
81
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
0
"""simple docstring""" import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters lowerCamelCase = (720, 1_280) # Height, Width lowerCamelCase = (0.4, 0.6) # if height or width lower than this scale, drop it. low...
82
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
0
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils....
83
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
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class A_ ( unittest.TestCase ): '''simple docstring''' def ...
84
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
0
from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class snake_case ...
85
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
0
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import F...
86
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
0
from __future__ import annotations def SCREAMING_SNAKE_CASE ( lowercase_ , lowercase_ , lowercase_ , ) -> tuple[str, float]: """simple docstring""" if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('''You cannot sup...
87
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
0
"""simple docstring""" from argparse import ArgumentParser from .env import EnvironmentCommand def _snake_case ( ): """simple docstring""" _lowerCamelCase : Optional[Any] = ArgumentParser("""Diffusers CLI tool""" , usage="""diffusers-cli <command> [<args...
88
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
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available SCREAMING_SNAKE_CASE : Optional[Any] = { "configuration_ernie": ["ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP", "ErnieConfig", "ErnieOnnxConfig"], } try: if...
89
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
0
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithN...
90
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
0
"""simple docstring""" _lowercase = '''Tobias Carryer''' from time import time class lowerCAmelCase_ : '''simple docstring''' def __init__( self : List[Any] ,A_ : str ,A_ : Optional[Any] ,A_ : List[str] ,A_ : List[Any]=int(time() ) ) -> Union[str, Any]:...
91
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
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCamelCase_ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDepende...
92
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
0
"""simple docstring""" import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() __A = logging.get_logger(__name__) def __A (_SCREAMING_SNAKE_CASE ) ->Optional[int]: ...
93
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
0
'''simple docstring''' import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenizati...
94
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
0
"""simple docstring""" import inspect import unittest import warnings from math import ceil, floor from transformers import LevitConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils imp...
95
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
0
"""simple docstring""" import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokeniz...
96
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
0
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __a = logging.get_logger(__name__) class lowercase__( UpperCAmelCase ): """simple docstring""" def __init__( self : Dict , *SCREAMING_SNAKE_CAS...
97
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
0
'''simple docstring''' import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def a__ ( lowercase : Tuple, lowercase : O...
98
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
0
from __future__ import annotations def a (lowerCAmelCase__ , lowerCAmelCase__ = None ): __a = word_bank or [] # create a table __a = len(lowerCAmelCase__ ) + 1 __a = [] for _ in range(lowerCAmelCase__ ): table.append([] ) # seed value __a...
99
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
0
def __snake_case ( ) -> int: return 1 def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else five_pence(x - 5 ) +...
100
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
0
from collections import defaultdict class __lowercase : """simple docstring""" def __init__( self , lowerCAmelCase__ , lowerCAmelCase__ ): """simple docstring""" SCREAMING_SNAKE_CASE_ : ...
101
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
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ : str = logging.get_logger(__name__) __magic_name__ : Union[str, Any] = { """RWKV/rwkv-4-169m-pile""": """https://huggingface.co/RWKV/rw...
102
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
0
"""simple docstring""" import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_pr...
103
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
0
"""simple docstring""" from collections import deque from math import floor from random import random from time import time class UpperCamelCase__ : """simple docstring""" def __init__( self ) -> Tuple: A__ = {} def sna...
104
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
0
import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_available, is_vision_availabl...
105
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
0
import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accelerate.test_utils import require_...
106
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
0
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
107
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
0
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,...
108
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
0
'''simple docstring''' from PIL import Image def __magic_name__ ( __UpperCAmelCase , __UpperCAmelCase ) -> Image: '''simple docstring''' __SCREAMING_SNAKE_CASE = (259 * (level + 255)) / (255 * (259 - level)) def contrast(__UpperCAmelCase ) -> int: ...
109
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
0
"""simple docstring""" from statistics import mean, stdev def lowerCamelCase ( _snake_case ,_snake_case = 3 ): UpperCAmelCase__ : Tuple = min(_snake_case ) UpperCAmelCase__ : Any = max(_snake_case ) # normalize data return [round((x - x_min) / (x...
110
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
0
'''simple docstring''' 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, XLMRob...
585
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
0
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_ = False class a ( unittest.TestCase ): pass @nightl...
611
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
0
'''simple docstring''' import sys from collections import defaultdict class _a : def __init__( self ) -> Tuple: _snake_case = [] def _lowercase ( self ,_SCREAMING_SNAKE_CASE ) -> Dict: return self.node_positi...
185
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
0
"""simple docstring""" import secrets from random import shuffle from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def SCREAMING_SNAKE_CASE_ ( snake_case : Tuple = 8 )-> str: _lowerCamelCase = ascii_letters + digits + punctuation ...
650
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
0
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 n...
652
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
0
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
103
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
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase_ = { """configuration_swiftformer""": [ """SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwiftFormerConfig""", ...
458
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
0
from __future__ import annotations def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> Optional[Any]: if not nums: raise ValueError('List is empty' ) return sum(_UpperCAmelCase ) / len(_UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.test...
295
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
0
def __UpperCamelCase ( _lowerCAmelCase = 1000 ) -> Tuple: """simple docstring""" A : str = 2**power A : Tuple = str(_lowerCAmelCase ) A : str = list(_lowerCAmelCase ) A : Optional[int] = 0 for i in list_num: ...
662
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
0
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_ ( _SCREAMING_SNAKE_CASE ): ...
402
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
0
'''simple docstring''' def lowerCamelCase__ ( A : str ): '''simple docstring''' return str(A ) == str(A )[::-1] def lowerCamelCase__ ( A : Optional[Any] ): '''simple docstring''' return int(A ) + int(str(A )[::-1] ) def lowerCamelCase__ ( A : ...
210
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
0
'''simple docstring''' # 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 __lowerCAmelCase = Path(__file__).resolve().parents[3] / """src""" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa impo...
585
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
0
from math import isclose, sqrt def _UpperCAmelCase ( UpperCamelCase: int , UpperCamelCase: Dict , UpperCamelCase: str ): """simple docstring""" __lowerCAmelCase = point_y / 4 / point_x __lowerCAmelCase = 2 * normal_gradient / (1 + normal_gradient * normal_gradient...
611
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
0
'''simple docstring''' from bisect import bisect from itertools import accumulate def __a ( _UpperCamelCase: Any , _UpperCamelCase: Optional[int] , _UpperCamelCase: List[Any] , _UpperCamelCase: List[str] ) -> Tuple: """simple docstring""" ...
185
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
0
"""simple docstring""" 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 __a ( _lowerCAmelCase , _lowerCAmelCas...
650
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
0
import torch def SCREAMING_SNAKE_CASE__ ( ) -> str: if torch.cuda.is_available(): __lowerCamelCase : Optional[Any] = torch.cuda.device_count() else: __lowerCamelCase : Optional[Any] = 0 print(F"Successfully ran on {num_gpus} ...
652
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
0
"""simple docstring""" 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 ...tes...
103
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
0
import math def __magic_name__ ( ) -> str: """simple docstring""" lowercase_ : int = input("""Enter message: """ ) lowercase_ : Optional[int] = int(input(f"""Enter key [2-{len(lowercase ) - 1}]: """ ) ) lowercase_ :...
458
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
0
from itertools import product def SCREAMING_SNAKE_CASE ( _UpperCAmelCase , _UpperCAmelCase ) -> Dict: lowerCamelCase__ : Optional[Any] = sides_number lowerCamelCase__ : Tuple = max_face_number * dice_number lowerCamelCase__ : Any = ...
295
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
0
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): ...
662
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
0
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 snake_case__ : List[Any] = False try: snake_case__ : i...
402
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
0
'''simple docstring''' def lowerCamelCase__ ( A : Any = 2_00_00_00 ): '''simple docstring''' UpperCAmelCase = [0 for i in range(n + 1 )] UpperCAmelCase = 1 UpperCAmelCase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if...
210
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
0
'''simple docstring''' def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE ): _snake_case = len(_SCREAMING_SNAKE_CASE ) while cur > 1: # Find the maximum number in arr _snake_case = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi _s...
585
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
0
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor from...
611
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
0
'''simple docstring''' 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 accel...
185
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
0
"""simple docstring""" 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_...
650
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
0
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> str: return "".join([hex(lowerCamelCase__ )[2:].zfill(2 ).upper() for byte in list(lowerCamelCase__ )] ) def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> List[Any]: if (len(lowerCamelCase_...
652
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
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case = { """configuration_xlm_roberta_xl""": [ """XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMRobert...
103
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
0
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 tra...
458
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
0
def SCREAMING_SNAKE_CASE ( _UpperCAmelCase = 1000 ) -> Tuple: return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
295
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
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: fro...
662
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
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING snake_case__ : Optional[Any] = logging.get_logger(__name__) snake_case__ : int = { """ut/deta""": """https://huggingface.co/ut/deta/resolve/main/config.jso...
402
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
0
'''simple docstring''' from __future__ import annotations import numpy as np def lowerCamelCase__ ( A : Any ): '''simple docstring''' return np.maximum(0 , A ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
210
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
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCAmelCase = { """configuration_mask2former""": [ """MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Mask2FormerConfig"""...
585
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
0
from math import sqrt def _UpperCAmelCase ( UpperCamelCase: List[Any] ): """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...
611
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
0
'''simple docstring''' 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_tes...
185
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
0
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : List[Any] )-> Optional[int]: if number < 0: raise ValueError('number must not be negative' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest....
650
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
0
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_...
652
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
0
"""simple docstring""" import os # Precomputes a list of the 100 first triangular numbers snake_case = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def snake_case ( ) -> Tuple: _snake_case = os.path.dirname(os.path.realpath(lowerCAmelCase_ ) ) ...
103
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
0
import os import sys import unittest UpperCAmelCase_ = 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_to_te...
458
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
0
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""", ...
295
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
0
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 SCREAMING_SNAKE_CASE_:List[str] = 0B101_100_111_110_110_010_010_000_011_110_111_011_000_1...
662
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
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices snake_case__ : Any = logging.get_logger(__name__) snake_case__ : Any = { """facebook/convnextv2-tiny-1...
402
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
0
'''simple docstring''' def lowerCamelCase__ ( A : Tuple ): '''simple docstring''' for i in range(len(A ) - 1 , 0 , -1 ): UpperCAmelCase = False for j in range(A , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: ...
210
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
0
'''simple docstring''' from functools import lru_cache def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE ): _snake_case = 2 _snake_case = set() while i * i <= n: if n % i: i += 1 else: n //= i ...
585
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
0
from __future__ import annotations from collections.abc import MutableSequence class a : def __init__( self : Optional[Any] , snake_case__ : int , snake_case__ : MutableSequence[float] ): """simple docstring""" if len(_lowerCAmelCase ) != degree + 1: ...
611
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
0
'''simple docstring''' # 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...
185
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
0
"""simple docstring""" import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import...
650
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
0
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 A_ ( _lowerCAmelCase ): def __init__( self : Li...
652
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
0
"""simple docstring""" 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 clas...
103
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
0
def __magic_name__ ( lowercase ) -> List[Any]: """simple docstring""" if collection == []: return [] # get some information about the collection lowercase_ : Dict = len(lowercase ) lowercase_ : Optional[int] = ...
458
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
0
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 OnnxRuntimeM...
295
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
0
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 SCREAMING_SNAKE_CASE_:Union[str, Any] = logging.getLogger(__name__) class SCREAMING_SNAKE_CASE__ ( _lowerCAmelCase ): ...
662
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
0
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 transformers....
402
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
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase : List[str] = logging.get_logger(__name__) _lowercase : Tuple = { "...
210
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
0
'''simple docstring''' class _lowerCAmelCase : # Public class to implement a graph '''simple docstring''' def __init__(self , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase ) -> None: _snake_case = row _snake_case = col ...
585
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
0
def _UpperCAmelCase ( UpperCamelCase: Optional[int] ): """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...") UpperCamelCase_ ...
611
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
0
'''simple docstring''' from pathlib import Path import fire from tqdm import tqdm def __a ( _UpperCamelCase: List[Any]="ro" , _UpperCamelCase: Any="en" , _UpperCamelCase: Optional[Any]="wmt16" , _UpperCamelCase: Optional[int]=None ) -> List[Any]: ...
185
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
0
"""simple docstring""" from __future__ import annotations def SCREAMING_SNAKE_CASE_ ( snake_case : Any , snake_case : List[str] )-> Dict: if b == 0: return (1, 0) ((_lowerCamelCase) , (_lowerCamelCase)) = extended_euclid(snak...
650
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
0
from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class A_ ( _lowerCAmelCase ): def lowerCAmelCase ( self : Union[str, Any] ,SCREAMING_SNAKE_CASE__ : float)...
652
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
0
"""simple docstring""" def snake_case ( lowerCAmelCase_ ) -> Dict: _snake_case = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(2_7)) print(perfect_cube(4))
103
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
0
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, ...
458
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
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, Wav...
295
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
0
SCREAMING_SNAKE_CASE_:int = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ SCREAMING_SNAKE_CASE_:Optional...
662
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
0
from __future__ import annotations from math import ceil, floor, sqrt def snake_case_ ( _SCREAMING_SNAKE_CASE = 2_0_0_0_0_0_0 ): __lowercase = [0] __lowercase = 4_2 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ) ): triangle_numbers.append(triangle_numbers[-1] +...
402
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
0
'''simple docstring''' 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 TFModelTest...
210
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
0
'''simple docstring''' import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel __lowerCAmelCase = { """text_branch""": """text_model""", """audio_branch""": """audio_model.audio_encoder""", """attn""": """attention....
585
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
0
from __future__ import annotations from fractions import Fraction def _UpperCAmelCase ( UpperCamelCase: Dict , UpperCamelCase: Optional[Any] ): """simple docstring""" return ( num != den and num % 1_0 == den // 1_0 and (num // 1_0) / (den % 1_0) == num / den ) def _Upper...
611
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
0
'''simple docstring''' # # 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 --n...
185
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
0
"""simple docstring""" from __future__ import annotations class __a : def __init__( self , a__ ): _lowerCamelCase = data _lowerCamelCase = None _lowerCamelCase = None def SCREAMING_SNAKE_CASE_ ( snak...
650
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
0