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''' lowerCamelCase = 8.3_1_4_4_5_9_8 def _A ( _lowerCAmelCase , _lowerCAmelCase ): """simple docstring""" if temperature < 0: raise Exception('Temperature cannot be less than 0 K' ) if molar_mass <= 0: ...
166
'''simple docstring''' import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin lowerCamelCase = get_tests_dir("""...
166
1
import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_utils import replicate ...
60
import ast import os import re import shutil import tempfile import unittest from unittest import mock import torch from accelerate.test_utils.examples import compare_against_test from accelerate.test_utils.testing import TempDirTestCase, require_trackers, run_command, slow from accelerate.utils impor...
60
1
"""simple docstring""" from datetime import datetime import requests def lowercase__ ( snake_case_ :str ): __UpperCAmelCase = '''https://downloadgram.net/wp-json/wppress/video-downloader/video?url=''' __UpperCAmelCase = requests.get(base_url + url ).json()...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule _lowercase : int = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys ...
332
1
"""simple docstring""" from __future__ import annotations import numpy as np def __lowerCAmelCase ( lowercase : list[float] ) -> Any: """simple docstring""" return np.maximum(0 , lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5])...
112
"""simple docstring""" def __lowerCAmelCase ( lowercase : int , lowercase : int , lowercase : list[list[int]] ) -> int: """simple docstring""" def update_area_of_max_square(lowercase : int , lowercase : int ) -> int: # BASE...
112
1
'''simple docstring''' from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin...
1
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def __lowerCamelCase ( lowerCamelCase__ : str , lowerCamelCase__ : str , **lowerCamelCase__ : Tuple ): '''simple docstring''' lowerCamelCase = AutoConfig.from_pret...
252
0
import math import unittest def _lowerCamelCase( lowercase__ ) -> bool: '''simple docstring''' assert isinstance(lowerCAmelCase__ , lowerCAmelCase__ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes ...
361
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device lowerCAmelCase = False class A ( unittest.TestCase ): pass @...
304
0
'''simple docstring''' import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup __lowerCAmelCase = logging.get_logger(__name__) ...
271
from math import loga def A_ ( A__ ) -> int: if a < 0: raise ValueError('Input value must be a positive integer' ) elif isinstance(A__ , A__ ): raise TypeError('Input value must be a \'int\' type' ) return 0 if (a == 0) else int(loga(a & -a ...
99
0
'''simple docstring''' import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from tra...
246
'''simple docstring''' 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 ...
246
1
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BertTok...
17
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFe...
273
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowercase : int = logging.get_logger(__name__) lowercase : Union[str, Any] = { 'ut/deta': 'https://huggingface.co/ut/deta/resolve/main/config.json'...
370
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accele...
151
0
'''simple docstring''' import os import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer from ...test_tokenization_common import TokenizerTesterMixin class __lowerCAmelCase (lowerCamelCase_ , unittest.TestCase ): '''simple docstri...
2
'''simple docstring''' _snake_case = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) _snake_case = frozenset(['prompt', 'negative_p...
250
0
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_common ...
171
def UpperCAmelCase_ (_lowerCAmelCase : int = 1_00 ): __UpperCamelCase : Tuple = n * (n + 1) * (2 * n + 1) / 6 __UpperCamelCase : List[str] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F"""{s...
171
1
from typing import TYPE_CHECKING from ...utils import _LazyModule A__ = {'tokenization_bertweet': ['BertweetTokenizer']} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys A__ = _LazyModule(__name__, globals()['''__fil...
230
"""simple docstring""" import requests from bsa import BeautifulSoup def _SCREAMING_SNAKE_CASE ( __snake_case : str = "AAPL" ): '''simple docstring''' lowercase = f'https://in.finance.yahoo.com/quote/{symbol}?s={symbol}' lowercase = BeautifulSoup(...
220
0
"""simple docstring""" import sys import turtle def lowercase ( A_ , A_ )-> tuple[float, float]: '''simple docstring''' return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def lowercase ( A_ , A_ , A_ , A_ , ...
352
"""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 lowercase ( ...
226
0
import argparse import os import re import packaging.version a_ = '''examples/''' a_ = { '''examples''': (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), '''check_min_version("VERSION")\n'''), '''init''': (re.compile(r'^__version__\s+=\s+"([^"]+)"\s*$', re.MULTILIN...
175
"""simple docstring""" from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class ...
264
0
'''simple docstring''' __lowerCAmelCase = [ (1_000, '''M'''), (900, '''CM'''), (500, '''D'''), (400, '''CD'''), (100, '''C'''), (90, '''XC'''), (50, '''L'''), (40, '''XL'''), (10, '''X'''), (9, '''IX'''), (5, '''V'''), (4, '''IV'''), (1, '''I''')...
359
'''simple docstring''' from binascii import hexlify from hashlib import shaaaa from os import urandom # RFC 3526 - More Modular Exponential (MODP) Diffie-Hellman groups for # Internet Key Exchange (IKE) https://tools.ietf.org/html/rfc3526 __lowerCAmelCase = { # 1536-bit 5: { '''p...
107
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_engi...
322
import os from datetime import datetime as dt from github import Github _a = [ '''good first issue''', '''feature request''', '''wip''', ] def _a ( ) -> List[Any]: """simple docstring""" __lowerCAmelCase: Dict = Github(os.envi...
322
1
'''simple docstring''' import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorState from...
229
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransformerConfig""", ...
229
1
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart import BartTokeniz...
226
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
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : List[Any]= logging.get_logger(__name__) _a : List[Any]= { "ksst...
95
"""simple docstring""" from __future__ import annotations import math def __UpperCAmelCase ( UpperCAmelCase_ : int ) -> bool: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == ...
95
1
'''simple docstring''' from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class A_ ( lowerCAmelCase_ ): def __init_...
22
'''simple docstring''' import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import T...
22
1
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def SCREAMING_SNAKE_CASE ( lowercase_ ) -> str: """simple docstring""" if "model" in orig_key: A__ = orig_key.replace('''model.''' , '''''' ) if "norm1" ...
231
from __future__ import annotations from collections import Counter from random import random class UpperCamelCase_ : '''simple docstring''' def __init__( self : Any) ->Optional[Any]: '''simple docstring''' A__ = {} def SCREAMING_SN...
231
1
from __future__ import annotations def lowerCAmelCase_ ( snake_case_,snake_case_,snake_case_ ): if days_between_payments <= 0: raise ValueError("""days_between_payments must be > 0""" ) if daily_interest_rate < 0: raise ValueError("""daily_interest_rate mu...
26
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAva...
278
0
from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _inter...
363
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPMSchedule...
34
0
'''simple docstring''' import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy ...
75
import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging __lowercase = logging.get_logger(__name__) def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase ...
43
0
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__ : str =logging.get_logger(__name__) lowerCAmelCase__ :...
355
def __lowercase ( a__ ) -> int: __SCREAMING_SNAKE_CASE = [[0 for _ in range(a__ )] for _ in range(m + 1 )] for i in range(m + 1 ): __SCREAMING_SNAKE_CASE = 1 for n in range(m + 1 ): for k in range(1 ...
118
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 ImageProcessingSavingTestMixin, p...
241
"""simple docstring""" # 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 # ...
241
1
"""simple docstring""" import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append(""".""") def SCREAMING_SNAKE_CASE__ ( snake_case : Tuple )-> Tuple: '''simp...
298
"""simple docstring""" import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCAmelCase__ ( __magic_name__ , unitt...
298
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _SCREAMING_SNAKE_CASE : List[str] = { 'configuration_r...
183
from __future__ import annotations import numpy as np from numpy import floataa from numpy.typing import NDArray def __magic_name__ ( A : NDArray[floataa], A : NDArray[floataa], A : list[int], A : int, ): '''simple docstring''' a , a = coefficient_matr...
107
0
import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings a = logging.getLogger(__name__) ...
358
"""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, At...
271
0
from itertools import product def _A ( SCREAMING_SNAKE_CASE__ : List[Any] , SCREAMING_SNAKE_CASE__ : Optional[Any] ): UpperCamelCase :Union[str, Any] = sides_number UpperCamelCase :Optional[int] = max_face_number * dice_number UpperCamelCase :...
259
"""simple docstring""" from __future__ import annotations def lowercase_ ( __UpperCAmelCase ) -> int: if not nums: return 0 lowerCAmelCase__ : List[Any] = nums[0] lowerCAmelCase__ : List[str] = 0 for num in nums[1:]: ...
242
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 DDPMSched...
366
_SCREAMING_SNAKE_CASE = { """Pillow""": """Pillow""", """accelerate""": """accelerate>=0.11.0""", """compel""": """compel==0.1.8""", """black""": """black~=23.1""", """datasets""": """datasets""", """filelock""": """filelock""", """flax""": """flax>=0.4.1""", "...
88
0
import torch from diffusers import UnCLIPScheduler from .test_schedulers import SchedulerCommonTest class lowercase__ ( UpperCamelCase_): UpperCamelCase_ = (UnCLIPScheduler,) def __A ( self : str , **UpperCamelCase__ : List[Any] ): ...
182
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __UpperCamelCase : Tuple = { 'configuration_swiftformer': [ 'SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SwiftFormerConfig', ...
182
1
def lowerCamelCase_ (): return [ a * b * (1000 - a - b) for a in range(1 , 999 ) for b in range(_SCREAMING_SNAKE_CASE , 999 ) if (a * a + b * b == (1000 - a - b) ** 2) ][0] if __name__ == "__main__": print(f"{solution() = }")
351
"""simple docstring""" import qiskit def lowerCamelCase_ (UpperCamelCase__ : int , UpperCamelCase__ : int ): _UpperCAmelCase : List[str] = qiskit.Aer.get_backend('''aer_simulator''' ) # Create a Quantum Circuit acting on the q register _UpperCAmelCase...
68
0
"""simple docstring""" import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transfor...
179
"""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...
179
1
# 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 _SCREAMING_SNAKE_CASE ( ...
350
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase_ : Optional[int] = { '''configuration_jukebox''': [ '''JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''JukeboxConfig''', '''JukeboxPriorCo...
62
0
import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class _SCREAMING_SNAKE_CASE ( ...
38
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) a__ : int = { 'configuration_layoutlmv3': [ ...
349
0
"""simple docstring""" import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common impo...
320
"""simple docstring""" import importlib import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Union import torch from ..utils import BaseOutput UpperCAmelCase : Optional[Any] = 'scheduler_config.json' class lowerCamelCase__ ...
320
1
"""simple docstring""" SCREAMING_SNAKE_CASE : Optional[Any] = { """A""": """.-""", """B""": """-...""", """C""": """-.-.""", """D""": """-..""", """E""": """.""", """F""": """..-.""", """G""": """--.""", """H""": """....""", """I""": """..""", """J""": """.---""", """K""": """-.-""", """L""": "...
102
"""simple docstring""" def lowercase ( _snake_case : int , _snake_case : int ) ->str: """simple docstring""" if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) __snake_case : Tuple = str(bin(_snake_case ) ...
102
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, Wava...
37
'''simple docstring''' import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" ...
37
1
class UpperCAmelCase : '''simple docstring''' def __init__( self : List[str] , lowerCAmelCase_ : Any ): """simple docstring""" _A: Optional[Any] = arr.split(''',''' ) def __magic_name__ ( self : Optional[Any] ): ...
121
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __snake_case = r''' [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read...
310
0
"""simple docstring""" from __future__ import annotations def lowerCamelCase__ ( __snake_case, __snake_case ) -> list[int]: """simple docstring""" _UpperCamelCase = 0 _UpperCamelCase = len(__snake_case ) - 1 whi...
100
"""simple docstring""" import numpy class _UpperCAmelCase: def __init__( self , __a , __a) -> None: '''simple docstring''' _UpperCamelCase = input_array # Random initial weights are assigned where first argument is the ...
100
1
import os from datetime import datetime as dt from github import Github _UpperCAmelCase : Optional[Any] = [ "good first issue", "good second issue", "good difficult issue", "enhancement", "new pipeline/model", "new scheduler", "wip", ] def A ( ) -> int...
222
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : Union[str, Any] = { "configuration_instructblip": [ "INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "InstructBlipConfig", "InstructBlipQFor...
222
1
"""simple docstring""" import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class _UpperCAmelCase : '''simple docstring''' def __init__(self , a_ , a_ , a_ ): '''simple docstring''' if dst_width < 0 or dst_height < 0: ...
368
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=__snake_case ): '''simple docstring''' lowerCamelCase__ =['transformers', 'torch', 'note_seq'] def __init__(self , *a_ , **a_ ): '''simple docstring'...
24
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __A = { "configuration_convbert": ["CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ConvBertConfig", "ConvBertOnnxCon...
10
from typing import Any def lowerCAmelCase_ ( __a , __a , __a , __a , __a , ) -> list: """simple docstring""" _validation( __a , __a , __a , __a , __a , ) # Creates data structures and fill initial step lowerCamelCase__: dict ={}...
10
1
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_pipeline_test, nested_simplify, requ...
185
from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTester from ....
185
1
import comet # From: unbabel-comet import torch import datasets __lowerCAmelCase = datasets.logging.get_logger(__name__) __lowerCAmelCase = """\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon}, ...
196
"""simple docstring""" def _lowerCamelCase( a = 1_0_0_0 ): __a = 3 __a = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 1_5 == 0: result -= a a += 1 return re...
261
0
def lowerCAmelCase__ ( lowerCamelCase : list ,lowerCamelCase : list ,lowerCamelCase : int ): _A : Dict = len(lowerCamelCase ) _A : List[Any] = [[0] * n for i in range(lowerCamelCase )] for i in range(lowerCamelCase ...
357
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import tor...
227
0
"""simple docstring""" UpperCAmelCase__ : Tuple = frozenset( [ 'prompt', 'height', 'width', 'guidance_scale', 'negative_prompt', 'prompt_embeds', 'negative_prompt_embeds', 'cross_attention_kwargs', ] ) Upp...
25
"""simple docstring""" def lowercase_ ( _snake_case ,_snake_case ): if not (isinstance(_snake_case ,_snake_case ) and isinstance(_snake_case ,_snake_case )): raise ValueError("""longest_common_substring() takes two strings for inputs""" ) SCREAM...
25
1
from __future__ import annotations def _A ( lowerCAmelCase_ : List[str] , lowerCAmelCase_ : Optional[int] ): """simple docstring""" lowerCAmelCase__ = 0 lowerCAmelCase__ = len(__snake_case ) - 1 while i < j: ...
362
import collections.abc from typing import Optional, Tuple, Union import torch import torch.utils.checkpoint from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithNoAttention, ImageC...
221
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _UpperCAmelCase : Any = {"""configuration_ibert""": ["""IBERT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """IBertConfig""", """IBertOnnxConfig"""]} try: ...
174
'''simple docstring''' from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder _SCREAMING_SNAKE_CASE = datasets.utils.logging.get_logger(__name__) class lowerCAmelCase_ ( folder_based_builde...
158
0
'''simple docstring''' import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import Tokeniz...
18
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvail...
18
1
from __future__ import annotations from sys import maxsize from typing import Generic, TypeVar _snake_case : str = TypeVar("T") def lowerCAmelCase_ ( __lowerCamelCase ): return (position - 1) // 2 def lowerCAmelCase_ ( __lowerCamelCase ): return (2 *...
123
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.models....
275
0
"""simple docstring""" import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_config...
354
"""simple docstring""" def snake_case ( A__ ): UpperCAmelCase_ : Optional[Any] = 0 for ch in input_str: UpperCAmelCase_ : Tuple = ord(A__ ) UpperCAmelCase_ : Dict = pow(2 ,A__ ) # If we already turned on bit ...
253
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_bert import BertTokenizer __lowerCAmelCase = logging.get_logger(__name__) __lowerCAm...
196
from __future__ import annotations def _lowerCamelCase( lowercase__ , lowercase__ ) -> Any: '''simple docstring''' if len(lowercase__ ) <= 1 or n <= 1: return insert_next(lowercase__ , n - 1 ) rec_insertion_sort(lowercase__ , n - 1 ) def _lowerCamelCase( lo...
295
0
from __future__ import annotations import math import numpy as np from numpy.linalg import norm def snake_case ( snake_case__ :np.ndarray , snake_case__ :np.ndarray): return math.sqrt(sum(pow(a - b , 2) for a, b in zip(snake_case__ , snake_case__))...
352
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def snake_case ( ) -> List[Any]: _A = ArgumentParser( description=( """PyTorch TPU...
81
0
def a__ ( UpperCAmelCase : int ) -> str: if len(SCREAMING_SNAKE_CASE__ ) <= 1: return lst UpperCAmelCase : Optional[int] = 1 while i < len(SCREAMING_SNAKE_CASE__ ): if lst[i - 1] <= lst[i]: i += 1 else: UpperCAmelCase , UpperCAmelCase ...
336
import os import re 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 lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ ...
8
0
"""simple docstring""" import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def _snake_case ( lowercase__ : Tuple ) -> int: '''simple docstring'...
366
"""simple docstring""" from typing import Optional import numpy as np import torch from torch import nn from transformers import GPTaConfig, GPTaLMHeadModel from transformers.modeling_utils import ModuleUtilsMixin from ...configuration_utils import ConfigMixin, register_to_config from ...model...
1
0
'''simple docstring''' import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def __snake_case ( UpperCAmelCase_ : Tuple ): if "model" in orig_key: lowerCamelCase_ = orig_key.replace("model." , "" ) if "norm1" in orig_key: ...
55
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np a__ : Optional[int] = re.compile(R'\b(a|an|the)\b', re.UNICODE) a__ : int = None def _UpperCamelCase ( ) -> Dict...
80
0
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py UpperCamelCase__ : str = '.' if __name__ == "__main__": UpperCamelCase__ : List[str] = os.path.join(REPO_PATH, """ut...
367
import re def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> str: """simple docstring""" if len(re.findall('''[ATCG]''', snake_case_ ) ) != len(snake_case_ ): raise ValueError('''Invalid Strand''' ) return dna.translate(dna.maketrans('''AT...
330
0
from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffusionScheduler from ...utils ...
123
import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils import enable_full_determin...
123
1
'''simple docstring''' import math from numpy import inf from scipy.integrate import quad def __magic_name__( lowerCamelCase): if num <= 0: raise ValueError('''math domain error''') return quad(lowerCamelCase, 0, lowerCamelCase, args=(lowerCamelCase))[0...
358
'''simple docstring''' import json import os import unittest from transformers import DebertaTokenizer, DebertaTokenizerFast from transformers.models.deberta.tokenization_deberta import VOCAB_FILES_NAMES from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTest...
9
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/config.json''', '''funnel-transfo...
87
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class A ( datasets.BeamBasedBuilder ): '''simpl...
298
0
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ...
367
def __a ( lowerCAmelCase_ : Dict ) -> Dict: '''simple docstring''' return [ { 0: [1, 2], 1: [0, 2], 2: [0, 1, 3, 5], 3: [2, 4], 4: [3], 5: [2, 6, 8], 6: [5, 7], ...
277
0
'''simple docstring''' def __snake_case ( UpperCAmelCase_ : int = 50000000 ): lowerCamelCase_ = set() lowerCamelCase_ = int((limit - 24) ** (1 / 2) ) lowerCamelCase_ = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.add(2 ) for p in range(...
55
'''simple docstring''' import math def __snake_case ( UpperCAmelCase_ : float , UpperCAmelCase_ : float ): return math.pow(UpperCAmelCase_ , 2 ) - a def __snake_case ( UpperCAmelCase_ : float ): return 2 * x d...
55
1
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING _lowercase : Optional[Any] = logging.get_logger(__name__) class UpperCamelCase__( lowerCAmelCase ): ...
91
'''simple docstring''' from __future__ import annotations from typing import Any class UpperCamelCase__: def __init__( self : Any , lowerCAmelCase : int , lowerCAmelCase : int , lowerCAmelCase : float = 0 )-> None: """simple docstring""...
91
1
import os def UpperCAmelCase_ ( ) -> str: SCREAMING_SNAKE_CASE_ = os.path.dirname(os.path.realpath(__UpperCAmelCase ) ) SCREAMING_SNAKE_CASE_ = os.path.join(__UpperCAmelCase , 'triangle.txt' ) with open(__UpperCAmelCase ) as f: ...
225
class lowerCamelCase_ : '''simple docstring''' def __init__( self : List[Any] ): SCREAMING_SNAKE_CASE_ = {} def lowerCAmelCase_ ( self : List[str] ): print(self.vertex ) for i in self.vertex: print(_lowerCAm...
225
1
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer if TYPE_CHECKING: f...
370
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _SCREAMING_SNAKE_CASE = {"""configuration_yolos""": ["""YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """YolosConfig""", """YolosOnnxConfig"""]} try: if not is_visio...
165
0
'''simple docstring''' import unittest from transformers import TrOCRConfig from transformers.testing_utils import is_torch_available, require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mod...
97
import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) if is_onnx_available(): import onnxruntime as or...
225
0
lowerCAmelCase__ : int =[ 'Audio', 'Array2D', 'Array3D', 'Array4D', 'Array5D', 'ClassLabel', 'Features', 'Sequence', 'Value', 'Image', 'Translation', 'TranslationVariableLanguages', ] from .audio import Audio from .features import ArrayaD,...
162
def a__ ( A__ ): SCREAMING_SNAKE_CASE_ : int = [] SCREAMING_SNAKE_CASE_ : int = [] SCREAMING_SNAKE_CASE_ : Optional[int] = { '^': 3, '*': 2, '/': 2, '%': 2, '+': 1, '-': 1, } # Prio...
162
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE :Dict = { 'configuration_transfo_xl': ['TRANSFO_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TransfoXLConfig'], 'tokenization_transfo_xl': ['Tran...
15
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu __UpperCAmelCase = get_tests_...
119
0
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...ut...
354
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 import ANY if is_vision_availab...
169
0
"""simple docstring""" from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): fro...
61
"""simple docstring""" import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transfo...
61
1
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelT...
189
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: str , lowerCAmelCase: str ) -> bool: _UpperCAmelCase : Optional[Any] = len(lowerCAmelCase ) + 1 _UpperCAmelCase : Optional[int] = len(lowerCAmelCase ) + 1 # dp is a 2d matrix where dp[i][j]...
189
1
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example a : Optional[int] = [ [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, ...
56
# 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 # # U...
189
0
"""simple docstring""" import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py SCREAMI...
230
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCAmelCase_ ( A_ ): lowercase__ = ['''image_processor''', '''tokenizer'''] lowercase__ = '''ViTImageProcessor''' ...
230
1
from typing import Any class A_ : def __init__(self :Tuple , _UpperCamelCase :Any )-> Dict: __A = data __A = None def __repr__(self :List[Any] )-> str: return f"""Node({self.data})""" cla...
117
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
117
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor a_ = logging.get_logger(__name__) class snake_case ( _UpperCamelCase): def __init__( self : Optional[int] , *a__ : str ...
163
"""simple docstring""" import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import...
163
1
def A_ ( _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: list[list[int]] = [[0 for _ in range(_UpperCAmelCase )] for _ in range(m + 1 )] for i in range(m + 1 ): SCREAMING_SNAKE_CASE_: List[str] = 1 for n in range(m + 1 ): for k in range(...
13
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule, ...
13
1
"""simple docstring""" def __UpperCAmelCase ( __lowerCamelCase ) -> Any: lowercase__ : str = [] lowercase__ : Tuple = [] lowercase__ : int = { '''^''': 3, '''*''': 2, '''/''': 2, '''%''': 2...
302
"""simple docstring""" import math def __UpperCAmelCase ( __lowerCamelCase ) -> str: lowercase__ : Tuple = 0 lowercase__ : Tuple = 0 while num > 0: lowercase__ : int = num % 8 lowercase__ : Tu...
302
1
import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_: Optional[Any] , SCREAMING_SNAKE_CASE_: List[str]=1 ) -> str: '''simple docstring''' if n_shave_prefix_s...
68
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.test...
68
1
'''simple docstring''' def _lowerCAmelCase ( __snake_case : str ) -> str: if not all(char in '01' for char in bin_string ): raise ValueError('Non-binary value was passed to the function' ) if not bin_string: raise ValueError('Empty ...
190
'''simple docstring''' import argparse lowercase__ : Any = '''docs/source/_static/js/custom.js''' def _lowerCAmelCase ( __snake_case : Union[str, Any] ) -> str: with open(__snake_case , encoding='utf-8' , newline='\n' )...
190
1
'''simple docstring''' import argparse import os import re import numpy as np import PIL import torch from timm import create_model from torch.optim.lr_scheduler import OneCycleLR from torch.utils.data import DataLoader, Dataset from torchvision.transforms import Compose, RandomResizedCrop, Resize, ToTens...
63
'''simple docstring''' import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def __magic_name__ ( __UpperCAmelCase ) -> str: '''simple docstring''' snake_case_ = [ '''encoder.version''', ...
56
0
'''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 NestedDa...
21
'''simple docstring''' import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import x...
21
1
'''simple docstring''' from statistics import mean import numpy as np def lowerCamelCase (_SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : List[str] , _SCREAMING_SNAKE_CASE : Tuple , _SCREAMING_SNAKE_CASE : Optional[Any] ): __a ...
27
from math import factorial class __a : def __init__( self : Union[str, Any] , SCREAMING_SNAKE_CASE : Tuple , SCREAMING_SNAKE_CASE : Optional[int] ): '''simple docstring''' UpperCamelCase__ : Tuple ...
189
0
"""simple docstring""" import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor _lowercase : Tuple = logging.getLogger(__name__) ...
371
"""simple docstring""" from __future__ import annotations import bisect def lowercase__ ( snake_case_ :list[int] , snake_case_ :int , snake_case_ :int = 0 , snake_case_ :int = -1 ): if hi < 0: __UpperCAmelCase = len(snake_case_ ) while lo < hi: ...
86
0
'''simple docstring''' from __future__ import annotations def _a( UpperCamelCase__ : list[int], UpperCamelCase__ : int, UpperCamelCase__ : int, UpperCamelCase__ : int ): '''simple docstring''' if (direction == 1 and array[indexa] > arra...
152
'''simple docstring''' import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging a_ = logging.get_logger(__nam...
152
1
# flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatter, format_table, query_table, ) from...
141
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES A_ : Union[str, Any] = logging.get_logger(__name__) A_ : int = OrderedDict( [ # Ba...
141
1
from __future__ import annotations _UpperCAmelCase : Tuple = 8.988e9 # units = N * m^s * C^-2 def A ( lowercase , lowercase , lowercase , lowercase ) -> dict[str, float]: '''simple docstring''' UpperCamelCase = abs(chargea * chargea ) if (fo...
222
def A ( lowercase ) -> list: '''simple docstring''' UpperCamelCase = len(lowercase ) for i in range(1 , lowercase ): UpperCamelCase = collection[i] UpperCamelCase = 0 UpperCamelCase = i - 1 while low <= high: UpperCamelCase = (low + hig...
222
1
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def __snake_case ( SCREAMING_SNAKE_CASE__ : Tuple , SCREAMING_SNAKE_CASE__ : List[str]=7 ) -> Tuple: '''simple do...
202
"""simple docstring""" from collections.abc import Callable class UpperCAmelCase_ : def __init__( self : Dict , A : Callable | None = None ): # Stores actual heap items. _UpperCAmelCase : list = [] # Stores ...
202
1
import operator as op lowercase : List[Any] = """scaler.pt""" lowercase : int = """pytorch_model""" lowercase : Union[str, Any] = """random_states""" lowercase : Optional[Any] = """optimizer""" lowercase : Any = ...
99
import argparse from collections import defaultdict import yaml lowercase : int = """docs/source/en/_toctree.yml""" def A_ ( A__ ) -> Tuple: a__ : int = defaultdict(A__ ) a__ : List[str] = [] a__ : Any = [] for doc in doc_list:...
99
1
"""simple docstring""" import enum import shutil import sys UpperCAmelCase__ , UpperCAmelCase__ = shutil.get_terminal_size() UpperCAmelCase__ = {'UP': 'A', 'DOWN': 'B', 'RIGHT': 'C', 'LEFT': 'D'} class lowerCAmelCase__ ( enum.Enum ): __a = 0 __a = 1 ...
354
"""simple docstring""" from timeit import timeit UpperCAmelCase__ = { 'MALAYALAM': True, 'String': False, 'rotor': True, 'level': True, 'A': True, 'BB': True, 'ABC': False, 'amanaplanacanalpanama': True, # "a man a plan a canal panama" } # Ensure our test d...
40
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available UpperCamelCase = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "Mask2FormerConfig", ], } try: if not is_vi...
186
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require...
85
0
from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestCommand from datasets.ut...
99
import unittest 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 if is_torch_available(): import torch if is_vision_availa...
99
1
'''simple docstring''' import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor _lowercase : int = logging.get_logger(__name__) class lowerCAmelCase__ ( lowerCamelCase_ ): def __init__( self ...
93
"""simple docstring""" import argparse from pathlib import Path import torch from transformers import OPTConfig, OPTModel from transformers.utils import logging logging.set_verbosity_info() A = logging.get_logger(__name__) def __A ( a_ :Tuple) -> Tu...
160
0
'''simple docstring''' import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import Ada...
354
'''simple docstring''' from collections.abc import Iterable from typing import Any class lowerCamelCase_ : def __init__( self : List[Any] , _A : int | None = None ): '''simple docstring''' UpperCAmelCase__ : List[A...
299
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 ...
219
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _A = {'configuration_vit_mae': ['VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMAEConfig']} try: if not is_torch_availab...
62
0
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def _lowerCAmelCase ( ): '''simple docstring''' UpperCamelCase__ : List[Any] =ArgumentPar...
371
"""simple docstring""" import torch from diffusers import StableDiffusionPipeline _SCREAMING_SNAKE_CASE : Optional[int] = """path-to-your-trained-model""" _SCREAMING_SNAKE_CASE : Optional[Any] = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""") ...
157
0
"""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.uti...
60
'''simple docstring''' import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig fr...
56
0
import torch from transformers import AutoModel class __SCREAMING_SNAKE_CASE ( torch.nn.Module ): '''simple docstring''' def __init__( self , snake_case_="sayef/fsner-bert-base-uncased" ): '''simple docstring''' super(__snake_case , self ).__init_...
358
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __SCREAMING_SNAKE_CASE ( lowerCamelCase_ ): '''simple docstring''' lowerCamelCase_ :Tuple = ['''image_processor''', '''tokenizer'...
274
0