code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class SCREAMING_SNAKE_CASE ( UpperCAmelCase__ ): """simple docstring""" lowercase__ = ["image_processor", "tokenizer"] ...
106
"""simple docstring""" import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor UpperCAmelCase_ : Any = logging.get_logger(__name__) class lowerCAmelCase__ ( UpperCAmelCase__ ): '''simple docstring''' def __ini...
91
0
import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require_tf, require_torch from t...
109
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
109
1
'''simple docstring''' # limitations under the License. # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from .pipelines import DiffusionPipeline, ImagePipelineOutput # noqa: F401 from .utils imp...
318
'''simple docstring''' import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
318
1
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor fr...
22
import os import unittest from transformers import MobileBertTokenizer, MobileBertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils i...
22
1
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils import FrozenDi...
233
lowerCamelCase : Tuple = {'''a''': ['''c''', '''b'''], '''b''': ['''d''', '''e'''], '''c''': [], '''d''': [], '''e''': []} lowerCamelCase : int = ['''a''', '''b''', '''c''', '''d''', '''e'''] def snake_case_ ( lowerCAmelCase_ : Optional[int] , low...
233
1
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version lowerCAmelCase_ = { '''<''': operator.lt, '''<=''': operator.le, '''==''': operator.eq, '''!=''': operator.ne, '''>=''': operator.ge, '''>''': operator.gt, } ...
363
import time from contextlib import contextmanager from pathlib import Path import pytest import requests from huggingface_hub.hf_api import HfApi, HfFolder lowerCAmelCase_ = '''__DUMMY_TRANSFORMERS_USER__''' lowerCAmelCase_ = '''Dummy User''' lowerCAmelCase_ = '''hf_hZEmnoOEYISjraJtbySaKCNnSu...
279
0
"""simple docstring""" from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, i...
289
def _a ( UpperCAmelCase ) -> bool: """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...') _A : ...
142
0
"""simple docstring""" import math def lowercase__ ( snake_case_ :int ): __UpperCAmelCase = [] __UpperCAmelCase = 2 __UpperCAmelCase = int(math.sqrt(snake_case_ ) ) # Size of every segment __UpperCAmelCase = [True] * (end + ...
352
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=_lowerCAmelCase ): a__ : Union[str, Any] = ["onnx"] def __init__( self : Any , *_lowercase : Dict , **_lowercase : Any ): requir...
86
0
"""simple docstring""" import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClas...
191
"""simple docstring""" def __lowerCamelCase ( a_ : Union[str, Any] ) -> Optional[int]: __SCREAMING_SNAKE_CASE :List[str] = 1 __SCREAMING_SNAKE_CASE :Dict = 2 while i * i <= n: __SCREAMING_SNAKE_CASE :Tuple = 0 ...
191
1
import unittest from typing import Dict, List, Optional, Union import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepa...
366
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class lowercas...
152
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_mobilebert import MobileBertTokenizer UpperCamelCase__ = logging.get_logger(__name__) Uppe...
65
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 A ( UpperCAmelCase_ ): __UpperCAm...
65
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __A =logging.get_logger(__name__) __A ={'''ctrl''': '''https://huggingface.co/ctrl/resolve/main/config.json'''} class _SCREAMING_SNAKE_CASE ( snake_case_ ): lowerCAmelCase__ = 'ctrl' lowerCAmelCas...
47
from sklearn.metrics import recall_score import datasets __A =''' Recall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation: Recall = TP / (TP + FN) Where TP is the true positives and FN is the false negatives. ''' __A =''' Arg...
47
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) lowercase_ = { "configuration_trocr": ["TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP", "T...
211
'''simple docstring''' from ...utils import logging from ..ta.modeling_tf_ta import TFTaEncoderModel, TFTaForConditionalGeneration, TFTaModel from .configuration_mta import MTaConfig __lowercase = logging.get_logger(__name__) __lowercase = '''T5Config''' class a__( lowerCAmelCas...
272
0
from collections import deque def a( A : str ) -> List[Any]: """simple docstring""" a = len(A ) a = deque() a = [False for _ in range(A )] a = [-1 for _ in range(A )] a = index_of[:] def strong_connect(A :...
71
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase: Optional[Any] = logging.get_logger(__name__) _lowercase: Any = { "microsoft/git-base": "https://huggingface.co/microsoft/git-base/resolve/main/c...
71
1
from __future__ import annotations from dataclasses import dataclass @dataclass class __lowercase : """simple docstring""" _UpperCAmelCase : float _UpperCAmelCase : TreeNode | None = None _UpperCAmelCase : TreeNode | None = None ...
13
import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _lowerCa...
326
0
'''simple docstring''' import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICom...
187
'''simple docstring''' import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( ...
187
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase : Tuple ={ '''configuration_deberta''': ['...
223
'''simple docstring''' import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('''Googling.....''') lowerCAmelCase : str ='''https://www.google.com/search?q=''' + ''' '''.join(sys.ar...
223
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case_ : List[str] = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "Mask2FormerConfig", ],...
351
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class __snake_case ...
7
0
'''simple docstring''' import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device UpperCAmelCase : str = False class lowerCAm...
267
'''simple docstring''' import argparse import os from . import ( ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, BART_PRETRAINED_MODEL_ARCHIVE_LIST, BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CAMEMBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, CTRL_PRETRAINED_CONFIG_ARCHIVE_MAP, DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_M...
267
1
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class __magic_name__ ( tf.keras.layers.Layer ): def __init__( self , snake_case , snake_case , snake_case , snake_case , snake_case=1 , snake_case=Fals...
365
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( __lowerCamelCase : list[int] ): '''simple docstring''' if not nums: return 0 _UpperCAmelCase : Tuple =nums[0] _UpperCAmelCase : int ...
242
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { 'uclanlp/visualbert-vqa': 'https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json', 'uclanlp/visu...
29
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ : Dict = logging.get_logger(__name__) lowerCAmelCase_ : int = { 'bigcode/gpt_bigcode-santacoder': 'https://huggingface.co/bigcode/gpt_bigcode-santacod...
63
0
'''simple docstring''' import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import...
352
'''simple docstring''' import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers i...
107
0
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 PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImageProcessor from transformers.utils imp...
26
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from transformers.model...
277
0
def _UpperCamelCase ( snake_case__, snake_case__ ) -> List[Any]: __UpperCAmelCase : List[str] = "" for i in table: res += inp[i - 1] return res def _UpperCamelCase ( snake_case__ ) -> Union[str, Any]: retu...
358
import unittest import numpy as np from transformers import DistilBertConfig, 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.numpy as jnp ...
342
0
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class __SCREAMING_SNAKE_CASE : def __init__( self : int , A : Collection[float] | None = None ) ->None: if components is None: ...
142
from typing import Any class __SCREAMING_SNAKE_CASE : def __init__( self : List[Any] , A : Any ) ->Optional[int]: lowerCamelCase__ : Optional[int] = data lowerCamelCase__ : Any = None class __SCREAMING_SNAK...
142
1
# coding=utf-8 # Copyright 2023 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 applic...
354
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE_:Any = { """configuration_mobilenet_v2""": [ """MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MobileNetV2Config""", ...
115
0
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent UpperCAmelCase_ = {'UserAgent': UserAgent().random} def lowerCAmelCase_ ( __UpperCAmelCase: str ) -> dict: UpperCamelCase__ ...
201
'''simple docstring''' import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixi...
304
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.0 #...
332
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase ( metaclass=__lowerCAmelCase ): snake_case_ = ['''note_seq'''] def __init__( self, *lowercase_, **lowercase_ ) -> str: requires_backends(self, ['note_seq'] ) @cla...
332
1
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
78
"""simple docstring""" from __future__ import annotations from typing import Generic, TypeVar _SCREAMING_SNAKE_CASE : Optional[Any] = TypeVar('''T''') class a ( Generic[T] ): def __init__( self : List[str] ...
183
0
'''simple docstring''' from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType __a...
43
'''simple docstring''' import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @requir...
43
1
'''simple docstring''' def snake_case_ (_a : int , _a : int ): return "\n".join( F"{number} * {i} = {number * i}" for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_terms=10)) ...
34
'''simple docstring''' from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": A =input('Enter image url: ').strip() print(f"""Downloading image from {url} ...""") A =BeautifulSoup(requests.get(url).content, 'html.parser') # The image URL ...
34
1
'''simple docstring''' import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unorder...
350
'''simple docstring''' 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...
98
0
"""simple docstring""" import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators impor...
91
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms imp...
91
1
"""simple docstring""" import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline A: Optional[Any] = version....
362
"""simple docstring""" import math import sys def _snake_case ( UpperCamelCase : str ): UpperCAmelCase : Dict = """""" try: with open(UpperCamelCase , """rb""" ) as binary_file: UpperCAmelCase : str = binary_file.read() for dat in data: UpperC...
76
0
def lowerCamelCase__ ( snake_case_ : str = "The quick brown fox jumps over the lazy dog" , ) -> bool: __snake_case = set() # Replace all the whitespace in our sentence __snake_case = input_str.replace(''' ''' , '''''' ...
24
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_tok...
107
0
'''simple docstring''' from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar a_ : Optional[Any] = TypeVar("T") def _A (lowerCAmelCase__ :int ) -> int: '''simple docstring''' r...
104
'''simple docstring''' import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoImageProcessor, ViTImageProcessor from transform...
104
1
from ..utils import DummyObject, requires_backends class lowercase_ ( metaclass=lowercase ): '''simple docstring''' __snake_case = ['''torch''', '''transformers''', '''onnx'''] def __init__( self : Dict , ...
0
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_available,...
43
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimen...
363
from typing import TYPE_CHECKING from ...utils import _LazyModule lowerCamelCase_ : Dict = {"""tokenization_byt5""": ["""ByT5Tokenizer"""]} if TYPE_CHECKING: from .tokenization_byta import ByTaTokenizer else: import sys lowerCamelCase_ : Any = _LazyModule(__name__, globals(...
223
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusion...
71
from math import factorial def UpperCAmelCase__ ( _A : int = 1_00 ): '''simple docstring''' return sum(int(_A ) for x in str(factorial(_A ) ) ) if __name__ == "__main__": print(solution(int(input('''Enter the Number: ''').strip())))
188
0
import math def SCREAMING_SNAKE_CASE_ ( __magic_name__ : int ) -> int: """simple docstring""" if not isinstance(__magic_name__ , __magic_name__ ): UpperCamelCase :Optional[Any] = f"""Input value of [number={number}] must be an integer""" raise T...
62
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _SCREAMING_SNAKE_CASE ( _a ): snake_case__ ...
62
1
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attention_paths, renew...
336
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, E...
208
0
import argparse import json import os import time import zipfile from get_ci_error_statistics import download_artifact, get_artifacts_links from transformers import logging a_ = logging.get_logger(__name__) def __lowercase ( lowerCamelCase : Tuple , lowerCamelCase : Any ): Upp...
50
import math import flax.linen as nn import jax.numpy as jnp def __lowercase ( lowerCamelCase : jnp.ndarray , lowerCamelCase : int , lowerCamelCase : float = 1 , lowerCamelCase : float = 1 , lowerCamelCase : float = 1.0e4 , lowerCamelCase : bool = False , lowerCa...
50
1
import flax.linen as nn import jax import jax.numpy as jnp class SCREAMING_SNAKE_CASE__ ( nn.Module ): A_ : int A_ : jnp.dtype = jnp.floataa def a (self : str ): """simple docstring""" _...
24
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from ...
116
0
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging a : Dict = logging.get_logger(__name__) a : List[Any] = { """microsoft/unispeech-sat-base-100h-libri-ft""": ( ...
150
"""simple docstring""" from pathlib import Path import fire from tqdm import tqdm def lowercase__(A="ro" , A="en" , A="wmt16" , A=None ) ->None: """simple docstring""" try: import datasets except (ModuleNotFound...
150
1
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torch_device from diffusers.utils...
19
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils import FrozenDict fro...
19
1
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { '''asapp/sew-tiny-100k''': '''https://huggingface.co/asapp/sew-tiny-100k/resolve/main/confi...
370
def _lowerCAmelCase ( __lowerCAmelCase = 50 ) -> int: """simple docstring""" snake_case__ : Optional[int] = [1] * (length + 1) for row_length in range(3 , length + 1 ): for block_length in range(3 , row_length + 1 ): for bloc...
44
0
"""simple docstring""" from __future__ import annotations from typing import Any def a__ ( lowerCAmelCase ) -> None: create_state_space_tree(lowerCAmelCase , [] , 0 ) def a__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ) -> None:...
171
"""simple docstring""" import copy import random from transformers import CLIPTokenizer class lowerCamelCase ( lowerCAmelCase__ ): '''simple docstring''' def __init__(self , *_lowerCamelCase , **_lowerCamelCase ): """simple docstring""" super().__init__(*_...
171
1
"""simple docstring""" import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedData...
263
"""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 import r...
263
1
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def __A ( a_ :Tu...
160
"""simple docstring""" import math def _snake_case ( lowerCamelCase__ : list , lowerCamelCase__ : int ) -> int: lowerCamelCase_ : int =len(lowerCamelCase__ ) lowerCamelCase_ : List[Any] =int(math.floor(math.sqrt(lowerCamelCase__...
144
0
import itertools import os from collections import Counter, defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed import numpy as np import datasets from .execute import check_correctness lowercase : List[str] = """\ @misc{chen2021evaluating, title={Evaluating La...
362
def A_ ( A__ ) -> int: if not isinstance(A__ , A__ ): raise TypeError('only integers accepted as input' ) else: a__ : List[Any] = str(abs(A__ ) ) a__ : Optional[int] = [list(A__ ) for char in range(le...
225
0
"""simple docstring""" 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 ImageProcessingSavin...
260
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge A : Optional[int] = [ "Prosecutor: \"No videos were used in the crash investigation\" German papers say they saw a cell phone...
184
0
from math import ceil, sqrt def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : int = 1_0_0_0_0_0_0 ): '''simple docstring''' __snake_case : List[str] = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: __snake...
356
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
20
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor __UpperCamelCase = logging.get_logger(__name__) class UpperCamelCase ( lowerCAmelCase__ ): def __init__( self, *lowerCAmelCase__, **l...
69
import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate from flax.training.common_utils import sh...
329
0
import argparse import os import re lowerCamelCase__ : str = 'src/transformers' # Pattern that looks at the indentation in a line. lowerCamelCase__ : Tuple = re.compile(r'^(\s*)\S') # Pattern that matches `"key":" and puts `key` in group 0. lowerCamelCase__ : ...
352
def UpperCAmelCase_ ( __UpperCAmelCase : int , __UpperCAmelCase : int ) -> int: return int((input_a, input_a).count(0 ) != 0 ) def UpperCAmelCase_ ( ) -> None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 ...
210
0
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class __lowerCAmelCase ( lowerC...
82
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() A__ = logging.get_logger...
82
1
import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = {"""vocab_file""": """vocab.json"""} UpperCamelCase__ = { ""...
102
from pathlib import Path import fire from tqdm import tqdm def _a ( SCREAMING_SNAKE_CASE_ : Dict="ro" , SCREAMING_SNAKE_CASE_ : Union[str, Any]="en" , SCREAMING_SNAKE_CASE_ : Optional[Any]="wmt16" , SCREAMING_SNAKE_CASE_ : List[str]=None ...
102
1
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging ...
24
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor from...
295
0
"""simple docstring""" import math def snake_case_ ( A_ : int ): '''simple docstring''' assert isinstance(A_, A_ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes ...
175
"""simple docstring""" import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() lowerCAmelCase__ = [ '''word_e...
175
1
import flax.linen as nn import jax import jax.numpy as jnp class a__ ( nn.Module ): """simple docstring""" __lowerCamelCase = 42 __lowerCamelCase = jnp.floataa def UpperCamelCase ( self ) -> Any: '''simple docstring''' A__ ...
68
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTest...
68
1
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, reca...
371
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common i...
146
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__...
271
'''simple docstring''' from __future__ import annotations __lowerCAmelCase = [-1_0, -5, 0, 5, 5.1, 1_1, 1_3, 2_1, 3, 4, -2_1, -1_0, -5, -1, 0] __lowerCAmelCase = [-5, 0, 5, 5.1, 1_1, 1_3, 2_1, -1, 4, -1, -1_0, -5, -1, 0, -1] def UpperCAmelCase_ (__a : list[float] ): ...
271
1
from math import pow, sqrt def __lowercase ( *__lowerCAmelCase : float ): a__ = len(__lowerCAmelCase ) > 0 and all(value > 0.0 for value in values ) return result def __lowercase ( __lowerCAmelCase : float , __lower...
370
def __lowercase ( __lowerCAmelCase : Optional[Any] ): return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], 7...
109
0
from __future__ import annotations from typing import Any class lowerCAmelCase : def __init__( self : Tuple , UpperCAmelCase : int , UpperCAmelCase : int , UpperCAmelCase : float = 0 ) -> None: lowerCamelCase__ , lowerCamelCase__ : st...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : Optional[int] = { """configuration_git""": ["""GIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GitConfig""", """GitVisionConfig"""], """processing_git...
265
0
'''simple docstring''' import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available...
283
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .modeling_utils import ModelMixin from ....
283
1
import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision, slow, torch_device from...
343
'''simple docstring''' def _A ( ): return [list(range(1000 - i , -1000 - i , -1 ) ) for i in range(1000 )] __A = generate_large_matrix() __A = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]], [[3, 2], [1, 0]], [[7, 7, ...
164
0
'''simple docstring''' def a__ ( lowercase : list ) -> float: """simple docstring""" _UpperCamelCase = 0 while len(lowerCAmelCase__ ) > 1: _UpperCamelCase = 0 # Consider two files with minimum cost to be merged for _ in range(2 ): ...
366
'''simple docstring''' import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC lowercase__ : List[Any] = parse(importlib.metadata.version('torch')) def a__ ( lowercase : Union[str, Version], lo...
287
0
from torch import nn def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(f"""Unsupporte...
43
"""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....
224
0
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_sco...
206
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowercase ( a ): lowercase__ : Dict ...
206
1
import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _lowerCamelCase : List[Any] = logging....
14
A_ : List[Any] = {'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []} A_ : int = ['a', 'b', 'c', 'd', 'e'] def __a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) -> List[Any]: '''simple docstring''...
333
0
'''simple docstring''' import string def _A ( _lowerCAmelCase ): """simple docstring""" for key in range(len(string.ascii_uppercase ) ): __lowercase ='' for symbol in message: if symbol in string.ascii_uppercase: ...
48
'''simple docstring''' from __future__ import annotations import requests def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase =f"""https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty""" return requests.get(_lowerCAmelCase ).json() ...
48
1
import math def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : Tuple ) -> str: """simple docstring""" return math.sqrt(_A ) * math.sqrt(_A ) == num def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : Optional[Any] ) -> int: ...
219
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class A ( __UpperCAmelCase ): __snake_case = (UnCLIPScheduler,) def SCREAMING_SNAKE_CASE__ ( self, **UpperCamelCase__ ): """simple docstring""" lo...
278
0
"""simple docstring""" from math import factorial, pi def __snake_case ( SCREAMING_SNAKE_CASE__ : float , SCREAMING_SNAKE_CASE__ : int = 30 ) -> float: '''simple docstring''' if not isinstance(SCREAMING_SNAKE_CASE__ , (int, float) ): ...
202
"""simple docstring""" import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import D...
202
1
"""simple docstring""" from typing import Optional, Union import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models.modeling_utils import ModelMixin class UpperCamelCase ( lowercase_ , lowercase_ ): @register_to_config ...
213
"""simple docstring""" import argparse import struct import unittest class UpperCamelCase : def __init__( self ,__UpperCamelCase ) -> None: '''simple docstring''' lowercase_ : str = data # Initialize hash values lowercase_ : Op...
213
1
'''simple docstring''' import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def lowerCamelCase ( UpperCAmelCase__ : Dict ) -> List[str]: lowercase_ : Tuple = args.pruning_method ...
21
'''simple docstring''' import copy import tempfile import unittest from huggingface_hub import HfFolder, delete_repo from parameterized import parameterized from requests.exceptions import HTTPError from transformers import AutoConfig, GenerationConfig from transformers.testing_utils import TOKEN, USER, is_stagin...
21
1
"""simple docstring""" # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # no...
66
"""simple docstring""" import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPI...
247
0
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, ConditionalDetrForObjectDetection, ConditionalDetrFor...
252
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless re...
252
1
from __future__ import annotations import unittest import numpy as np from transformers import OPTConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFMode...
305
from __future__ import annotations def UpperCamelCase ( __magic_name__ : list[float] , __magic_name__ : list[float] ) -> float: """simple docstring""" lowercase__ = sorted(numsa + numsa ) lowercase__ , lowercase__ = divmod(l...
305
1
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": lowerCamelCase : Optional[Any] = argparse.ArgumentParser() parser.add_argument("--dump_path",...
208
import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_gpu, require_torch_...
208
1
"""simple docstring""" from ...utils import deprecate from ..controlnet.multicontrolnet import MultiControlNetModel # noqa: F401 from ..controlnet.pipeline_controlnet import StableDiffusionControlNetPipeline # noqa: F401 deprecate( "stable diffusion controlnet", "0.22.0", "Importing...
165
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnP...
261
0
'''simple docstring''' import argparse import torch from transformers import RemBertConfig, RemBertModel, load_tf_weights_in_rembert from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase__ ( lowerCamelCase : Union[str, Any] ,lowerCamelCase : ...
227
'''simple docstring''' import operator as op A : List[str] = '''scaler.pt''' A : Optional[int] = '''pytorch_model''' A : Union[str, Any] = '''random_states''' A : List[Any] = '''optimizer''' A : Optional[Any] = '''sche...
227
1
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.tokenization_transfo_xl import CORPUS_NAME...
303
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
18
0
"""simple docstring""" import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcess...
215
"""simple docstring""" from ...processing_utils import ProcessorMixin class __A ( _SCREAMING_SNAKE_CASE ): """simple docstring""" __lowerCAmelCase = "WhisperFeatureExtractor" __lowerCAmelCase = "WhisperTokenizer" def __init__( self ...
215
1
'''simple docstring''' def snake_case_ ( lowerCAmelCase_ )-> Union[str, Any]: '''simple docstring''' _UpperCAmelCase : Optional[int] = len(lowerCAmelCase_ ) _UpperCAmelCase : Optional[Any] = sum(lowerCAmelCase_ ) _UpperCAmelCase : ...
215
'''simple docstring''' import tempfile import torch from diffusers import IPNDMScheduler from .test_schedulers import SchedulerCommonTest class lowercase ( _lowerCamelCase ): """simple docstring""" UpperCAmelCase = (IPNDMScheduler,) UpperCAmelCase = (("""num_inferen...
215
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) A : Dict = { 'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRAINED_CONFIG_...
360
import argparse import torch from transformers import GPTaLMHeadModel, RobertaForMaskedLM if __name__ == "__main__": A : Union[str, Any] = argparse.ArgumentParser( description=( 'Extraction some layers of the full RobertaForMaskedLM or GPT2LMHeadModel for Transfer Lear...
33
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = { "facebook/dpr-ctx_encoder-single-nq-base": ( "https://huggingface.co/facebook/dpr-ctx_encoder-single-nq-base/resol...
100
import json import os import unittest from transformers import AutoTokenizer, GPTaTokenizer, GPTaTokenizerFast from transformers.models.gpta.tokenization_gpta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
235
0
'''simple docstring''' from __future__ import annotations def _A (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , ) -> Any: '''simple docstring''' if (stress, tangential_force, area).count(0 ) != 1: raise ValueError('...
370
'''simple docstring''' import unittest from transformers import DebertaConfig, 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_com...
104
0
'''simple docstring''' def __UpperCAmelCase ( A : str ) -> Optional[Any]: UpperCAmelCase_ : Optional[Any] = [0] * len(A ) UpperCAmelCase_ : Any = [] UpperCAmelCase_ : Optional[int] = [1] * len(A ) for values in graph.values(): for i in...
304
'''simple docstring''' import functools def __UpperCAmelCase ( A : str , A : str ) -> int: UpperCAmelCase_ : Optional[Any] = len(A ) UpperCAmelCase_ : List[str] = len(A ) @functools.cache def min_distance(A : int , A : ...
304
1
import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class _snake_case ( lowercase__): UpperCamelCase__ : str ...
351
def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): lowercase__ = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): lowercase__ = n - k # Calculate C(n,k) for i in range(SCREAMING_SNAKE_CASE_ ): result *=...
224
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase_ (metaclass=snake_case__ ): '''simple docstring''' __UpperCamelCase: Optional[int] = ["sentencepiece"] def __init__( self : Any , *A : Any , *...
31
'''simple docstring''' def UpperCamelCase_ ( _UpperCAmelCase : list ) -> list: """simple docstring""" _UpperCAmelCase : List[Any] = len(_UpperCAmelCase ) for _ in range(_UpperCAmelCase ): for i in range(_ % 2 , arr_siz...
31
1
"""simple docstring""" import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def __lowerCamelCase ( a_ : Optional[int] , a_ : List[str] , ...
239
"""simple docstring""" def __lowerCamelCase ( a_ : Union[str, Any] , a_ : Optional[Any] ) -> Union[str, Any]: return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def __lowerCamelCase ( a_ : Optional[int] ,...
239
1
"""simple docstring""" def A ( snake_case__ ): '''simple docstring''' assert isinstance(snake_case__ , snake_case__ ), f"""The input value of [n={number}] is not an integer""" if number == 1: return 2 elif number < 1: SCREAMING_SNAKE_CASE__ ...
165
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassific...
165
1
import gc import random import unittest import torch from diffusers import ( IFImgaImgPipeline, IFImgaImgSuperResolutionPipeline, IFInpaintingPipeline, IFInpaintingSuperResolutionPipeline, IFPipeline, IFSuperResolutionPipeline, ) from diffusers.models.attention_processo...
208
# HF Trainer benchmarking tool # # This tool can be used to run and compare multiple dimensions of the HF Trainers args. # # It then prints a report once in github format with all the information that needs to be shared # with others and second time in a console-friendly format, so it's easier to use for...
208
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCamelCase = { """configuration_pix2struct""": [ """PIX2STRUCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Pix2StructConfig""", ...
59
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _a ( __a ): __a : int = ["""image_processor""", """tokenizer"""] __a : Union[str, Any] = """ChineseCLIPImage...
34
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_test, nes...
352
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) snake_case : Any = pytest.mark.integration @pytest.mark.parametrize('''path''' , ['''paws''', ''...
281
0
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin ...
268
"""simple docstring""" from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def snake_case ( A__ ,A__ ,A__ ): if not arr: return None, None, 0 if low == high: return low, high, arr[...
268
1
# Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def lowerCamelCase__ ( UpperCamelCase__ : Dict ) -> Dict: '''simple docstring''' re...
295
from collections.abc import Sequence def lowerCamelCase__ ( UpperCamelCase__ : Sequence[float] , UpperCamelCase__ : bool = False ) -> float: '''simple docstring''' if not arr: return 0 _snake_case = 0 if allow_empty_subar...
295
1
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): def SCREAMING_SNAKE_CASE ( self : Optional...
32
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TextClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from .te...
32
1
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = ...
365
import unittest import numpy as np from transformers import RobertaConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transfo...
335
0
import math def lowerCAmelCase_ ( _snake_case : float , _snake_case : float ) -> float: '''simple docstring''' return math.pow(_snake_case , 2 ) - a def lowerCAmelCase_ ( _snake_case : float ) -> float: '''simple docstri...
281
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a nice m...
281
1
'''simple docstring''' # Imports import numpy as np class lowercase_ : """simple docstring""" def __init__( self : List[Any] ,lowercase__ : int=None ,lowercase__ : str=None ,lowercase__ : List[Any]=None ,lowercase__ : Dict=None ,lo...
52
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], } try: if not is_torch...
52
1