code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' # Copyright 2021 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.a...
41
"""simple docstring""" import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_...
246
0
'''simple docstring''' from math import pow def SCREAMING_SNAKE_CASE__ ( __A , __A , __A , __A , __A , ) -> tuple[int, int]: if current_sum == needed_sum: # If the sum of the powers is equal to needed_sum, then we have a solution. solutions_count += 1 return cu...
42
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def UpperCamelCase ( _lowerCAmelCase : Any, _lowerCAmelCase : List[str], _lowerCAmelCase : Dict ) -> str: _UpperCAmelCase...
246
0
def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' if discount_rate < 0: raise ValueError('''Discount rate cannot be negative''' ) if not cash_flows: raise ValueError('''Cash flows list cannot be empty''' ) __UpperCamelCase :Option...
43
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowerCamelCase__ : Any = 10 def UpperCamelCase ( _lowerCAmelCase : in...
246
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a : str = logging.get_logger(__name__) _a : int = { 'uw-madison/mra-base-512-4': 'https://huggingface.co/uw-madison/mra-base-512-4/resolve/main/config.json', } class ...
44
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def UpperCamelCase ( _lowerCAmelCase : List[str] ) -> Any: _UpperCAmelCase : List[str] = [ """encoder.version""", ...
246
0
"""simple docstring""" from heapq import heappop, heappush import numpy as np def lowercase ( lowerCAmelCase__ : np.ndarray , lowerCAmelCase__ : tuple[int, int] , lowerCAmelCase__ : tuple[int, int] , lowerCAmelCase__ : bool , ) -> tuple...
45
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, res...
246
0
"""simple docstring""" import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common ...
46
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from .....
246
0
'''simple docstring''' 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 A__ ( unittest.TestCase ): def A ( self : Dict ) -> int: ...
47
"""simple docstring""" # Lint as: python3 import itertools import os import re lowerCamelCase__ : str = re.compile(r'''([A-Z]+)([A-Z][a-z])''') lowerCamelCase__ : List[Any] = re.compile(r'''([a-z\d])([A-Z])''') lowerCamelCase__ : int = re.comp...
246
0
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_...
48
"""simple docstring""" import math lowerCamelCase__ : List[Any] = 10 lowerCamelCase__ : Optional[int] = 7 lowerCamelCase__ : Dict = BALLS_PER_COLOUR * NUM_COLOURS def UpperCamelCase ( _lowerCAmelCase : int = 20 ) -> str: _UpperCAm...
246
0
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case :Any = logging.get_logger(__name__) __snake_case :int = { '''asapp/sew-d-tiny-100k''': '''https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/c...
49
"""simple docstring""" import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def UpperCamelCase ( _lowerCAmelCase : Dict, _lowerCAmelCase : int=(), _lo...
246
0
from __future__ import annotations import math def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> bool: 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 multi...
50
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets lowerCamelCase__ : List[str] = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and ...
246
0
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 snake_case_ : Any = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, 2), 5: (5, 1)...
51
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated lowerCamelCase__ : str = ...
246
0
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. team. # # 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 appl...
52
"""simple docstring""" import random class _UpperCAmelCase : @staticmethod def __snake_case ( _A ) -> tuple[list[int], list[int]]: '''simple docstring''' _UpperCAmelCase : List[Any] = [ord(_A ) for i in t...
246
0
'''simple docstring''' import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( '''The `image_to_image.py` script is outdated. Please use directly `from diffusers import''' ''' StableDiffusionImg2ImgPipeline` instead.''' )
53
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int ) -> int: if divisor % 5 == 0 or divisor % 2 == 0: return 0 _UpperCAmelCase : Optional[Any] = 1 _UpperCAmelCase : List[str] = 1 while repunit: _UpperCAmelCase : Tuple = ...
246
0
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Tuple = logging.get_logger(__name__) a__ : Tuple = { '''huggingface/time-series-transformer-tourism-monthly''': ( ...
54
"""simple docstring""" import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py lowerCamelCase__ :...
246
0
'''simple docstring''' from __future__ import annotations import math import random from typing import Any class snake_case : """simple docstring""" def __init__( self ): """simple docstring""" lowerCamelCase_ = [] lowerCame...
55
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int = 3, _lowerCAmelCase : int = 7, _lowerCAmelCase : int = 1000000 ) -> int: _UpperCAmelCase : Dict = 0 _UpperCAmelCase : int = 1 for current_denominator in range(1, limit...
246
0
'''simple docstring''' import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester f...
56
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers impor...
246
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A : Union[str, Any] = { "configuration_clipseg": [ "CLIPSEG_PRETRAINED_CONFIG_ARCHIVE_MAP", "CLIPSegConfig", "CLIPSegTextConfig",...
57
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class _UpperCAme...
246
0
'''simple docstring''' from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_sing...
58
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int, _lowerCAmelCase : int ) -> int: _UpperCAmelCase : str = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): _UpperCAmelCase : Dict = n - k # Calculat...
246
0
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar __lowerCamelCase = TypeVar("""T""") __lowerCamelCase = TypeVar("""U""") class UpperCAmelCase ( Generic[T, U] ): def __init__(self : Dict , ...
59
"""simple docstring""" import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): fr...
246
0
"""simple docstring""" from math import asin, atan, cos, radians, sin, sqrt, tan snake_case__ : Optional[Any] = 6_3_7_8_1_3_7.0 snake_case__ : Optional[Any] = 6_3_5_6_7_5_2.3_1_4_2_4_5 snake_case__ : Tuple = 6_378_137 def _snake_case ( _snake_case : float , _snak...
60
"""simple docstring""" 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, ...
246
0
"""simple docstring""" # Imports import numpy as np class A_ : '''simple docstring''' def __init__( self , lowercase_=None , lowercase_=None , lowercase_=None , lowercase_=None , lowercase_=None ): """simple docstring""" self.set_matricies(red=lowercase_ ,...
61
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObject...
246
0
import os def _UpperCAmelCase ( ): with open(os.path.dirname(SCREAMING_SNAKE_CASE__ ) + '/p022_names.txt' ) as file: __UpperCamelCase =str(file.readlines()[0] ) __UpperCamelCase =names.replace('"' , '' ).split(',' ) names.sort() ...
62
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class ...
246
0
'''simple docstring''' import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import...
63
"""simple docstring""" import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_...
246
0
"""simple docstring""" import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers...
64
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def UpperCamelCase ( _lowerCAmelCase : Any, _lowerCAmelCase : List[str], _lowerCAmelCase : Dict ) -> str: _UpperCAmelCase...
246
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING UpperCamelCase__ = logging.get_logger(__name__) Upper...
65
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowerCamelCase__ : Any = 10 def UpperCamelCase ( _lowerCAmelCase : in...
246
0
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils im...
66
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def UpperCamelCase ( _lowerCAmelCase : List[str] ) -> Any: _UpperCAmelCase : List[str] = [ """encoder.version""", ...
246
0
'''simple docstring''' import logging import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCS...
67
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, res...
246
0
from jiwer import compute_measures import datasets lowerCAmelCase__ = """\ @inproceedings{inproceedings, author = {Morris, Andrew and Maier, Viktoria and Green, Phil}, year = {2004}, month = {01}, pages = {}, title = {From WER and RIL to MER and WIL: improved evaluation measures fo...
68
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from .....
246
0
"""simple docstring""" import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_av...
69
"""simple docstring""" # Lint as: python3 import itertools import os import re lowerCamelCase__ : str = re.compile(r'''([A-Z]+)([A-Z][a-z])''') lowerCamelCase__ : List[Any] = re.compile(r'''([a-z\d])([A-Z])''') lowerCamelCase__ : int = re.comp...
246
0
'''simple docstring''' A__ : Union[str, Any] =[sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)] def UpperCamelCase__ ( lowerCAmelCase ): """simple docstring""" _lowerCAmelCase = 0 while number: ...
70
"""simple docstring""" import math lowerCamelCase__ : List[Any] = 10 lowerCamelCase__ : Optional[int] = 7 lowerCamelCase__ : Dict = BALLS_PER_COLOUR * NUM_COLOURS def UpperCamelCase ( _lowerCAmelCase : int = 20 ) -> str: _UpperCAm...
246
0
import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def A ( a_ ) -> Union[str, Any]: ...
71
"""simple docstring""" import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def UpperCamelCase ( _lowerCAmelCase : Dict, _lowerCAmelCase : int=(), _lo...
246
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ = { '''configuration_maskformer''': ['''MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MaskFormerConfig'''], ...
72
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets lowerCamelCase__ : List[str] = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and ...
246
0
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorState,...
73
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated lowerCamelCase__ : str = ...
246
0
"""simple docstring""" from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": _lowercase = input('''Enter image url: ''').strip() print(F"""Downloading image from {url} ...""") _lowercase = BeautifulSoup(requests.get(url).content, '''htm...
74
"""simple docstring""" import random class _UpperCAmelCase : @staticmethod def __snake_case ( _A ) -> tuple[list[int], list[int]]: '''simple docstring''' _UpperCAmelCase : List[Any] = [ord(_A ) for i in t...
246
0
'''simple docstring''' import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def a_ ( __snake_case : Optional[Any] ) -> Union[str, Any]: """simple docstring""" lowerCamelCase_...
75
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int ) -> int: if divisor % 5 == 0 or divisor % 2 == 0: return 0 _UpperCAmelCase : Optional[Any] = 1 _UpperCAmelCase : List[str] = 1 while repunit: _UpperCAmelCase : Tuple = ...
246
0
from ...configuration_utils import PretrainedConfig from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'facebook/s2t-small-librispeech-asr': ( 'https://huggingface.co/facebook/s2t-small-librispeech-asr/resolve/main/config.json' ), # See all Speech2Text models at h...
76
"""simple docstring""" import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py lowerCamelCase__ :...
246
0
"""simple docstring""" 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 : List[Any] = ...
77
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int = 3, _lowerCAmelCase : int = 7, _lowerCAmelCase : int = 1000000 ) -> int: _UpperCAmelCase : Dict = 0 _UpperCAmelCase : int = 1 for current_denominator in range(1, limit...
246
0
"""simple docstring""" import functools import gc import inspect import torch from .imports import is_npu_available, is_xpu_available def _lowerCAmelCase ( *lowercase_ ): if not isinstance(lowercase_ , lowercase_ ): UpperCAmelCase = list(lowerca...
78
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers impor...
246
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCamelCase_ = { '''configuration_lxmert''': ['''LXMERT_PRETRAINED_CONFIG_AR...
79
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class _UpperCAme...
246
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.generation import DisjunctiveConstraint @require_torch class lowercase_ ( unittest.TestCase ): ...
80
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int, _lowerCAmelCase : int ) -> int: _UpperCAmelCase : str = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): _UpperCAmelCase : Dict = n - k # Calculat...
246
0
"""simple docstring""" import colorsys from PIL import Image # type: ignore def _A ( lowercase , lowercase , lowercase ): """simple docstring""" a =x a =y for step in range(lowercase ): # noqa: B007 a =a * a - b * ...
81
"""simple docstring""" import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): fr...
246
0
from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils...
82
"""simple docstring""" 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, ...
246
0
'''simple docstring''' class lowercase__ : def __init__( self : List[str] ): '''simple docstring''' _UpperCamelCase : int = '' _UpperCamelCase : List[Any] = '' _UpperCamelCase : Tuple = [] def UpperCamelCase_ ( self ...
83
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObject...
246
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = {'configuration_deit': ['DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP',...
84
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class ...
246
0
'''simple docstring''' import random from .binary_exp_mod import bin_exp_mod def UpperCamelCase_( snake_case : Union[str, Any] , snake_case : str=1_0_0_0 ): '''simple docstring''' if n < 2: return False if n % 2 == 0: ...
85
"""simple docstring""" import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_...
246
0
"""simple docstring""" 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_im...
86
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def UpperCamelCase ( _lowerCAmelCase : Any, _lowerCAmelCase : List[str], _lowerCAmelCase : Dict ) -> str: _UpperCAmelCase...
246
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, ...
87
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowerCamelCase__ : Any = 10 def UpperCamelCase ( _lowerCAmelCase : in...
246
0
from __future__ import annotations from random import random from typing import Generic, TypeVar __lowerCAmelCase : str = TypeVar('KT') __lowerCAmelCase : Tuple = TypeVar('VT') class UpperCAmelCase_ ( Generic[KT, VT] ): '''simple docstring''' ...
88
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def UpperCamelCase ( _lowerCAmelCase : List[str] ) -> Any: _UpperCAmelCase : List[str] = [ """encoder.version""", ...
246
0
'''simple docstring''' import shutil import tempfile import unittest from unittest.mock import patch from transformers import ( DefaultFlowCallback, IntervalStrategy, PrinterCallback, ProgressCallback, Trainer, TrainerCallback, TrainingArguments, is_torch_available, ) from transfor...
89
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, res...
246
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __A = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FNetConfig"]} try:...
90
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from .....
246
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) UpperCAmelCase_ : Dict = { """uclanlp/visualbert-vqa""": """https://huggingface.co/uclanlp/visualbert-vqa/resolve/mai...
91
"""simple docstring""" # Lint as: python3 import itertools import os import re lowerCamelCase__ : str = re.compile(r'''([A-Z]+)([A-Z][a-z])''') lowerCamelCase__ : List[Any] = re.compile(r'''([a-z\d])([A-Z])''') lowerCamelCase__ : int = re.comp...
246
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCamelCase__ = {"""configuration_deit""": ["""DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DeiTConfig""", """DeiTOnnxConfi...
92
"""simple docstring""" import math lowerCamelCase__ : List[Any] = 10 lowerCamelCase__ : Optional[int] = 7 lowerCamelCase__ : Dict = BALLS_PER_COLOUR * NUM_COLOURS def UpperCamelCase ( _lowerCAmelCase : int = 20 ) -> str: _UpperCAm...
246
0
'''simple docstring''' def snake_case_ ( __SCREAMING_SNAKE_CASE : Optional[int] ): """simple docstring""" lowercase_ : List[str] = [0] * len(__SCREAMING_SNAKE_CASE ) lowercase_ : Union[str, Any] = ...
93
"""simple docstring""" import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def UpperCamelCase ( _lowerCAmelCase : Dict, _lowerCAmelCase : int=(), _lo...
246
0
import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
94
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets lowerCamelCase__ : List[str] = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and ...
246
0
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCAmelCase : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase : List[str] = { """vocab_file""": ...
95
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated lowerCamelCase__ : str = ...
246
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) lowercase__ = { """configuration_blip""": [ """BLI...
96
"""simple docstring""" import random class _UpperCAmelCase : @staticmethod def __snake_case ( _A ) -> tuple[list[int], list[int]]: '''simple docstring''' _UpperCAmelCase : List[Any] = [ord(_A ) for i in t...
246
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __snake_case = { '''configuration_layoutlmv2''': ['''LAYOUTLMV2_PRETRAINED_CONFIG_...
97
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int ) -> int: if divisor % 5 == 0 or divisor % 2 == 0: return 0 _UpperCAmelCase : Optional[Any] = 1 _UpperCAmelCase : List[str] = 1 while repunit: _UpperCAmelCase : Tuple = ...
246
0
"""simple docstring""" import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging lowerCAmelCase__ : List[Any]...
98
"""simple docstring""" import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py lowerCamelCase__ :...
246
0
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration lowercase : List[Any] = { """tiny.en""": """https://openaipublic.azureedge.net/main/whi...
99
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int = 3, _lowerCAmelCase : int = 7, _lowerCAmelCase : int = 1000000 ) -> int: _UpperCAmelCase : Dict = 0 _UpperCAmelCase : int = 1 for current_denominator in range(1, limit...
246
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 # #...
100
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers impor...
246
0
def UpperCamelCase ( lowerCAmelCase__ ): '''simple docstring''' lowercase = abs(lowerCAmelCase__ ) lowercase = 0 while n > 0: res += n % 10 n //= 10 return res def UpperCamelCase ( lowerCAmelCase__ ): '''simpl...
101
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class _UpperCAme...
246
0
"""simple docstring""" import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": SCREAMING_SNAKE_CASE : Optional[Any] = argparse.ArgumentParser() parser.add_argument( """--checkpoint_path""", def...
102
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int, _lowerCAmelCase : int ) -> int: _UpperCAmelCase : str = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): _UpperCAmelCase : Dict = n - k # Calculat...
246
0
import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available from .transformer_engine import ...
103
"""simple docstring""" import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): fr...
246
0
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example lowerCAmelCase__ = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0,...
104
"""simple docstring""" 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, ...
246
0
"""simple docstring""" from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class __UpperCamelCase ( a__ ...
105
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObject...
246
0
"""simple docstring""" from __future__ import annotations __UpperCamelCase : Dict = 1.6021e-19 # units = C def __SCREAMING_SNAKE_CASE ( A_ , A_ , A_ , ): if (conductivity, electron_conc, mobility).count(0 ) != 1: raise ValueError('''You cannot supply mo...
106
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class ...
246
0
from __future__ import annotations __lowerCAmelCase : int = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] __lowerCAmelCase : Any = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def __magic_name__ ( A : list[float] ): '''simple docstr...
107
"""simple docstring""" import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_...
246
0
"""simple docstring""" import os def a__ ( SCREAMING_SNAKE_CASE : str = "matrix.txt" ): '''simple docstring''' with open(os.path.join(os.path.dirname(SCREAMING_SNAKE_CASE ) , SCREAMING_SNAKE_CASE ) ) as in_file: lowerCAmelCase : Any = i...
108
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def UpperCamelCase ( _lowerCAmelCase : Any, _lowerCAmelCase : List[str], _lowerCAmelCase : Dict ) -> str: _UpperCAmelCase...
246
0
"""simple docstring""" from __future__ import annotations def _snake_case ( UpperCamelCase : list[int] ): if len(UpperCamelCase ) == 0: return array UpperCAmelCase , UpperCAmelCase : Optional[Any] = min(UpperCamelCase ), max(UpperCamelCase ) # Compute the varia...
109
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowerCamelCase__ : Any = 10 def UpperCamelCase ( _lowerCAmelCase : in...
246
0
'''simple docstring''' from urllib.parse import quote import pytest from datasets.utils.hub import hf_hub_url @pytest.mark.parametrize('repo_id' , ['canonical_dataset_name', 'org-name/dataset-name'] ) @pytest.mark.parametrize('path' , ['filename.csv', 'filename with blanks.csv'] ) @pytest.mark.p...
53
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def UpperCamelCase ( _lowerCAmelCase : List[str] ) -> Any: _UpperCAmelCase : List[str] = [ """encoder.version""", ...
246
0
import argparse import json import os from collections import OrderedDict import torch from transformers import LukeConfig, LukeForMaskedLM, MLukeTokenizer, XLMRobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def lowerCamelCase_ ( ...
90
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, res...
246
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_t...
252
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from .....
246
0
import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class __lowercase (unittest.TestCase ): @property de...
275
"""simple docstring""" # Lint as: python3 import itertools import os import re lowerCamelCase__ : str = re.compile(r'''([A-Z]+)([A-Z][a-z])''') lowerCamelCase__ : List[Any] = re.compile(r'''([a-z\d])([A-Z])''') lowerCamelCase__ : int = re.comp...
246
0
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokenizerFast, ) ...
207
"""simple docstring""" import math lowerCamelCase__ : List[Any] = 10 lowerCamelCase__ : Optional[int] = 7 lowerCamelCase__ : Dict = BALLS_PER_COLOUR * NUM_COLOURS def UpperCamelCase ( _lowerCAmelCase : int = 20 ) -> str: _UpperCAm...
246
0
from typing import TYPE_CHECKING from ....utils import _LazyModule _snake_case = {'''tokenization_tapex''': ['''TapexTokenizer''']} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _snake_case = _LazyModule(__name__, globals()['''__file__'''], _...
157
"""simple docstring""" import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def UpperCamelCase ( _lowerCAmelCase : Dict, _lowerCAmelCase : int=(), _lo...
246
0
'''simple docstring''' def SCREAMING_SNAKE_CASE_ (UpperCamelCase , UpperCamelCase ) -> None: lowerCamelCase__ : Any = len(_lowerCAmelCase ) print("""The following activities are selected:""" ) # The first acti...
41
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets lowerCamelCase__ : List[str] = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and ...
246
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowercase__ : Union[str, Any] = logging.get_logger(__name__) lowercase__ : Any =...
264
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated lowerCamelCase__ : str = ...
246
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { '''google/canine-s''': '''https://huggingface.co/google/canine-s/resolve/main/config.json''', # See all C...
162
"""simple docstring""" import random class _UpperCAmelCase : @staticmethod def __snake_case ( _A ) -> tuple[list[int], list[int]]: '''simple docstring''' _UpperCAmelCase : List[Any] = [ord(_A ) for i in t...
246
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers import AutoTokenize...
331
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int ) -> int: if divisor % 5 == 0 or divisor % 2 == 0: return 0 _UpperCAmelCase : Optional[Any] = 1 _UpperCAmelCase : List[str] = 1 while repunit: _UpperCAmelCase : Tuple = ...
246
0
from collections import defaultdict def _lowercase ( UpperCamelCase_ , UpperCamelCase_ ) -> bool: '''simple docstring''' SCREAMING_SNAKE_CASE__ = first_str.lower().strip() SCREAMING_SNAKE_CASE__ = second_str.lower().strip() # Remove whitespace ...
176
"""simple docstring""" import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py lowerCamelCase__ :...
246
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a__ : List[str] ={ '''configuration_encodec''': [ '''ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''EncodecConfig''', ]...
53
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int = 3, _lowerCAmelCase : int = 7, _lowerCAmelCase : int = 1000000 ) -> int: _UpperCAmelCase : Dict = 0 _UpperCAmelCase : int = 1 for current_denominator in range(1, limit...
246
0
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging __A =...
90
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers impor...
246
0
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, 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,...
252
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class _UpperCAme...
246
0
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def _lowercase ( lowercase__ ): return (data["data"], data["t...
275
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int, _lowerCAmelCase : int ) -> int: _UpperCAmelCase : str = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): _UpperCAmelCase : Dict = n - k # Calculat...
246
0
import numpy as np from transformers import Pipeline def a ( lowerCamelCase_ ): '''simple docstring''' lowercase__ = np.max(_lowerCAmelCase , axis=-1 , keepdims=_lowerCAmelCase ) lowercase__ = np.exp(outputs - maxes ) return shifted_exp / shifted_exp...
207
"""simple docstring""" import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): fr...
246
0
from __future__ import annotations import math def _UpperCamelCase ( snake_case__, snake_case__, snake_case__, snake_case__, snake_case__ ) -> int: if depth < 0: raise ValueError("Depth cannot be less than 0" ) if not scores: ...
157
"""simple docstring""" 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, ...
246
0
'''simple docstring''' def SCREAMING_SNAKE_CASE_ () -> int: return [ a * b * (1000 - a - b) for a in range(1 , 999 ) for b in range(_lowerCAmelCase , 999 ) if (a * a + b * b == (1000 - a - b) ** 2)...
41
"""simple docstring""" import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObject...
246
0
"""simple docstring""" import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transfor...
264
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class ...
246
0
'''simple docstring''' 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...
162
"""simple docstring""" import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_...
246
0
'''simple docstring''' import re def lowerCamelCase ( lowerCAmelCase : str ): """simple docstring""" return [char.split() for char in re.split(R'[^ a-z A-Z 0-9 \s]' , str_ )] def lowerCamelCase ( lowerCAmelCase : str ): """simple docstring""" __magic_name__ ...
331
"""simple docstring""" import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def UpperCamelCase ( _lowerCAmelCase : Any, _lowerCAmelCase : List[str], _lowerCAmelCase : Dict ) -> str: _UpperCAmelCase...
246
0
import tempfile import unittest import numpy as np from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import BertConfig, is_flax_available from transformers.testing_utils import TOKEN, USER, is_staging_test, require_flax if is_flax_available(): import ...
176
"""simple docstring""" from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. lowerCamelCase__ : Any = 10 def UpperCamelCase ( _lowerCAmelCase : in...
246
0
'''simple docstring''' 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,...
53
"""simple docstring""" import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def UpperCamelCase ( _lowerCAmelCase : List[str] ) -> Any: _UpperCAmelCase : List[str] = [ """encoder.version""", ...
246
0
import argparse from pathlib import Path from typing import Dict, OrderedDict, Tuple import torch from audiocraft.models import MusicGen from transformers import ( AutoFeatureExtractor, AutoTokenizer, EncodecModel, MusicgenDecoderConfig, MusicgenForConditionalGeneration, ...
90
"""simple docstring""" from typing import Dict, Iterable, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, res...
246
0
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_torch class ...
252
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from .....
246
0
import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils import is_torch_available ...
275
"""simple docstring""" # Lint as: python3 import itertools import os import re lowerCamelCase__ : str = re.compile(r'''([A-Z]+)([A-Z][a-z])''') lowerCamelCase__ : List[Any] = re.compile(r'''([a-z\d])([A-Z])''') lowerCamelCase__ : int = re.comp...
246
0
import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import BytesIO from pathlib import Path from url...
207
"""simple docstring""" import math lowerCamelCase__ : List[Any] = 10 lowerCamelCase__ : Optional[int] = 7 lowerCamelCase__ : Dict = BALLS_PER_COLOUR * NUM_COLOURS def UpperCamelCase ( _lowerCAmelCase : int = 20 ) -> str: _UpperCAm...
246
0
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner import Spl...
157
"""simple docstring""" import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def UpperCamelCase ( _lowerCAmelCase : Dict, _lowerCAmelCase : int=(), _lo...
246
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A : Dict ={ '''configuration_nllb_moe''': [ '''NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''NllbMoeConfig''...
41
"""simple docstring""" from sklearn.metrics import matthews_corrcoef import datasets lowerCamelCase__ : List[str] = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and ...
246
0
"""simple docstring""" def __lowercase ( _a , _a ): snake_case_ : str = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): snake_case_ : Dict = n - k # Calculate C(n,k) for i in range(_lowerCAmelCase ): result *= n - i ...
264
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated lowerCamelCase__ : str = ...
246
0
'''simple docstring''' import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mod...
162
"""simple docstring""" import random class _UpperCAmelCase : @staticmethod def __snake_case ( _A ) -> tuple[list[int], list[int]]: '''simple docstring''' _UpperCAmelCase : List[Any] = [ord(_A ) for i in t...
246
0