code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_torch_available(): import to...
513
from typing import Dict, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import flip_channel_order, resize, to_channel_dimension_format, to_pil_image from ...image_utils import ( ChannelDimension, ImageInput, ...
513
1
"""simple docstring""" import argparse import requests import torch # pip3 install salesforce-lavis # I'm actually installing a slightly modified version: pip3 install git+https://github.com/nielsrogge/LAVIS.git@fix_lavis from lavis.models import load_model_and_preprocess from PIL import Image from transformer...
579
"""simple docstring""" 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 SCREAMING_SNAKE_CASE_ = logging.get_logger(__na...
579
1
"""simple docstring""" import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase : List[str] = logging.get_logger(_...
289
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE__ : str ) -> bool: '''simple docstring''' _UpperCAmelCase : str = 0 for ch in input_str: _UpperCAmelCase : Optional[int] = ord(SCREAMING_SNAKE_...
289
1
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultist...
711
"""simple docstring""" def __lowerCAmelCase( __UpperCAmelCase ): """simple docstring""" stooge(__UpperCAmelCase ,0 ,len(__UpperCAmelCase ) - 1 ) return arr def __lowerCAmelCase( __UpperCAmelCase ,__UpperCAmelCase ,__UpperCAmelCase ): """simple docstring"...
283
0
import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def UpperCamelCase ( lowercase_ ) -> Any: '''simple...
12
def UpperCamelCase ( lowercase_ , lowercase_ , lowercase_ , lowercase_ ) -> List[str]: '''simple docstring''' global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: lowercase__ : str = mf_knapsack(i - 1 , lowercase_ , ...
12
1
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class snake_case : '''simple docstring''' _A : ...
374
"""simple docstring""" from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import Ba...
374
1
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, lo...
422
'''simple docstring''' import argparse import os # New Code # 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, s...
71
0
'''simple docstring''' import copy import random from transformers import CLIPTokenizer class __UpperCAmelCase ( _UpperCAmelCase ): def __init__( self , *_lowerCamelCase , **_lowerCamelCase ): super().__init__(*lowercase__ , **lowercase__ ) ...
704
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def snake_case_ ...
606
0
import gc import unittest from diffusers import FlaxControlNetModel, FlaxStableDiffusionControlNetPipeline 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 a...
63
import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common...
600
0
from __future__ import annotations from numpy import array, cos, cross, floataa, radians, sin from numpy.typing import NDArray def A ( a_ ,a_ ,a_ = False ) -> list[float]: if radian_mode: return [magnitude * cos(a_ ), magnitude * sin(a_ )] r...
706
from __future__ import annotations A_ :Union[str, Any] = '''#''' class __A : """simple docstring""" def __init__( self ): """simple docstring""" __UpperCamelCase : dict ={} def __lowercas...
154
0
import inspect from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel, VQModel from ...schedulers import DDIMScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowerCAmelCase__ ( _lowerCamelCa...
106
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 TokenizerTesterMixin @require_tokeni...
106
1
def _UpperCAmelCase ( A = 1000 ): '''simple docstring''' return sum(e for e in range(3 , A ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(f"""{solution() = }""")
713
# XXX: we want transformers master here - in the absense of conftest manipulating sys.path: # hack it in for now: import sys from pathlib import Path UpperCamelCase_ = Path(__file__).resolve().parents[3] / 'src' sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import...
510
0
'''simple docstring''' 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 imp...
309
"""simple docstring""" from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from acce...
553
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 __UpperCAmelCase = logging.getLogger(__name__) __UpperCAmelCase ...
251
"""simple docstring""" __UpperCAmelCase = { '''meter''': '''m''', '''kilometer''': '''km''', '''megametre''': '''Mm''', '''gigametre''': '''Gm''', '''terametre''': '''Tm''', '''petametre''': '''Pm''', '''exametre''': '''Em''', '''zettametre''': '''Zm''', '''yottametr...
251
1
import inspect import unittest from transformers import YolosConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_mod...
81
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _snake_case : Any = { "configuration_informer": [ "INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "InformerConfig", ], } ...
81
1
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _UpperCamelCase : int = { "configuration_cpmant": ["CPMANT_PRETRAINED_CONFIG_ARCHIVE_M...
706
"""simple docstring""" from .glue import GlueDataset, GlueDataTrainingArguments from .language_modeling import ( LineByLineTextDataset, LineByLineWithRefDataset, LineByLineWithSOPTextDataset, TextDataset, TextDatasetForNextSentencePrediction, ) from .squad import SquadDataset, SquadDataTraining...
645
0
from ...processing_utils import ProcessorMixin class A ( __UpperCAmelCase ): __snake_case = 'WhisperFeatureExtractor' __snake_case = 'WhisperTokenizer' def __init__( self, UpperCamelCase__, UpperCamelCase__ ): """simple docstring""" super()...
431
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils import FeatureEx...
431
1
"""simple docstring""" import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput _A = 'scheduler_config.json' class lowe...
538
"""simple docstring""" from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup _A = 'https://www.indeed.co.in/jobs?q=mobile+app+development&l=' def SCREAMING_SNAKE_CASE ( __UpperCAmelCase = "mumbai" ...
538
1
'''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 ImageProcess...
448
"""simple docstring""" def __snake_case ( UpperCamelCase__ ) -> list[int]: """simple docstring""" A = [0 for i in range(len(UpperCamelCase__ ) )] # initialize interval's left pointer and right pointer A , A = 0, 0 for i in ran...
690
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase__ = logging.get_logger(__name__) UpperCAmelCase__ = { ...
275
"""simple docstring""" from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def __UpperCAmelCase ( lower...
275
1
"""simple docstring""" import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED...
522
"""simple docstring""" from ...processing_utils import ProcessorMixin class snake_case ( __UpperCAmelCase ): '''simple docstring''' _A : Optional[int] = 'SpeechT5FeatureExtractor' _A : List[Any] = 'SpeechT...
522
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available A = { 'configuration_gpt_neo': ['GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTNeoConfig', 'GPTNeoOnnxConfig'], } try: if not is_to...
707
"""simple docstring""" 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, get_resize_output_image_size, normalize, rescale, resize, to_...
109
0
'''simple docstring''' import json import os import shutil 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 AutoConfig, BertConfig, GPTaConfig fr...
150
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path from unittest.mock imp...
34
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE__:Union[str, Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__:Tuple = { """fac...
67
"""simple docstring""" import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class snake_case__ ( snake_case_ ): def a__ ( self , lowerCamelCase ): with open(lowerCamelCase , encoding="utf-8" ) as input_file: ...
67
1
'''simple docstring''' import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CAC...
489
'''simple docstring''' from __future__ import annotations class UpperCAmelCase : """simple docstring""" def __init__( self : int , UpperCamelCase__ : list[list[int]] ) -> Tuple: _UpperCamelCase =TypeError( '''Matrices must be ...
404
0
"""simple docstring""" from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREA...
712
"""simple docstring""" import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class lowerCAmelCase_ ( A__ ): '''simple docstring''' def A__ ( self , snake_case_ ) -> Optional[int]: ...
573
0
'''simple docstring''' import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() __magic_name__ : List[str] =logging.get_logger(__name__) __magic_name__ : Optional[Any] =[ ['attention...
664
'''simple docstring''' __magic_name__ : Dict =8.3_1_4_4_6_2 # Unit - J mol-1 K-1 def __snake_case ( lowerCamelCase_ : float , lowerCamelCase_ : float , lowerCamelCase_ : float ): '''simple docstring''' if moles < 0 or kelvin < 0 or volume < 0: ...
664
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCAmelCase = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_...
700
'''simple docstring''' def _lowerCAmelCase ( lowercase : int , lowercase : int ) ->str: """simple docstring""" if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) lowercase__ = st...
318
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowerCamelCase (_a ): _lowercase = ["""image_processor""", """tokenizer"""] _lowercase = """CLIPImageProcessor""" _lowe...
1
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import TEXT_GUIDED_IM...
488
0
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is...
453
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import RealmTokenizer _UpperCAmelCas...
453
1
from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A = logging.get_logger(__name__) A = { "facebook/deit-base-distilled-patch16-22...
475
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 lowercase__ ( uni...
475
1
'''simple docstring''' # flake8: noqa # Lint as: python3 UpperCamelCase_ = [ "VerificationMode", "Version", "disable_progress_bar", "enable_progress_bar", "is_progress_bar_enabled", "experimental", ] from .info_utils import VerificationMode from .loggin...
508
'''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...
508
1
import numpy as np def lowerCAmelCase_ ( __a ) -> np.array: """simple docstring""" return 1 / (1 + np.exp(-vector )) def lowerCAmelCase_ ( __a ) -> np.array: """simple docstring""" ...
258
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transfor...
174
0
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokeniza...
173
"""simple docstring""" import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_c...
173
1
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def UpperCAmelCase__ (): '''simple docstring''' with offline(OfflineSimul...
682
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowerCAmelCase_ ( UpperCamelCase__ : str , UpperCamelCase__ : str , UpperCamelCase__ : Optional[str] = None ): ...
616
0
from __future__ import annotations import time A__ = list[tuple[int, int]] A__ = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], ...
219
import importlib.metadata import operator import re import sys from typing import Optional from packaging import version A__ = { '''<''': operator.lt, '''<=''': operator.le, '''==''': operator.eq, '''!=''': operator.ne, '''>=''': operator.ge, '''>''': operator.gt, }...
219
1
import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def UpperCAmelCase_ ( __UpperCAmelCase : str , __UpperCAmelCase : O...
31
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor lowerCamelCase__ : Union[str, Any] = logging.get_logger(__name__) class lowerCamelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( se...
31
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A : Dict = { 'configuration_informer': [ 'INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InformerConfig', ], } try: if not is_t...
75
import logging import numpy as np import pytest from scipy.linalg import eigh logging.basicConfig(level=logging.INFO, format='%(message)s') def __UpperCamelCase ( _A : np.ndarray ) ->np.ndarray: """simple docstring""" return input_array.reshape((input_array.size, 1) )...
75
1
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar _UpperCamelCase = TypeVar('''T''') _UpperCamelCase = TypeVar('''U''') class _lowerCamelCase ( Generic[T, U] ): """simple docstring""" def __init__( ...
243
import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings snake_case_ : Optional[Any] = R''' [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the mode...
691
0
import numpy as np import torch import tqdm from ...models.unet_ad import UNetaDModel from ...pipelines import DiffusionPipeline from ...utils import randn_tensor from ...utils.dummy_pt_objects import DDPMScheduler class UpperCAmelCase__ ( A__ ): """simple docstring""" def __init__( self : ...
472
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSpec from ...token...
472
1
'''simple docstring''' 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...
447
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : str = logging.get_logger(__name__) __lowerCamelCase : Tuple = { '''bigcode/gpt_bigcode-santacoder''': '''https://huggingface.co/...
653
0
from math import sqrt def _a ( SCREAMING_SNAKE_CASE : int ): """simple docstring""" assert isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) and ( number >= 0 ), "'number' must been an int and positive" UpperCamelCase__ : int = True # 0 and 1 are n...
106
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_MAPPING from ...tokenization_util...
106
1
'''simple docstring''' from timeit import timeit def _lowercase ( lowerCamelCase__ ) -> int: """simple docstring""" if number < 0: raise ValueError("the value of input must not be negative" ) __UpperCAmelCase : Dict ...
168
'''simple docstring''' import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) ...
168
1
from __future__ import annotations def __lowercase ( __lowerCAmelCase : list[int] ): # This function is recursive a__ = len(__lowerCAmelCase ) # If the array contains only one element, we return it (it's the stop condition of # recursion) if ar...
657
# 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 a...
657
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available SCREAMING_SNAKE_CASE__ = {"""tokenization_herbert""": ["""HerbertTokenizer"""]} try: if not is_tokenizers_available(): raise OptionalDe...
532
'''simple docstring''' def __A ( UpperCAmelCase ,UpperCAmelCase ) -> str: '''simple docstring''' _UpperCamelCase : str = [0 for i in range(r + 1 )] # nc0 = 1 _UpperCamelCase : List[Any] = 1 for i in ra...
435
0
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_SEQUENCE_CLASSIFI...
717
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo UpperCamelCase = """\ @misc{wu2016googles, title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Translation}, author={Yonghui Wu ...
152
0
from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE_ : """simple docstring""" def __init__( self : Tuple , lowerCAmelCase : int ) -> None: """simple docstring""" __UpperCamelCas...
279
# 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 req...
279
1
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, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
721
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments ...
608
0
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _snake_case ( __snake_case ): """simple docstring""" a = ["image_processor", "tokenizer"] a = "ViTImageProcessor" ...
338
"""simple docstring""" from __future__ import annotations def lowerCamelCase_(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , )-> None: _SCREAMING_SNAKE_CASE : Optional[Any] = le...
338
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_nump...
710
'''simple docstring''' import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_comm...
542
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase: int = logging.get_logger(__name__) _lowerCAmelCase: Any = { """bert-base-uncased"""...
20
'''simple docstring''' import argparse import collections import numpy as np import torch from flax import traverse_util from tax import checkpoints from transformers import MTaConfig, UMTaEncoderModel, UMTaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def ...
683
0
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowerCamelCase_ ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' a__ = ["image_processor", "tokenizer"] a__ = "CLIPImageProcessor" a__ = ("CLI...
704
import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCasePlus, execute_subpr...
17
0
import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class _lowerCamelCase( _a ): lowercase_ : Dict = """""" lowercase_ : str = ( None # p...
89
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_t...
37
0
import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data import DataLoader, Rand...
704
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class UpperCAmelCase__ : """simple docstring""" def __init__( self , A_ = None ) -> None: if components is None: __U...
682
0
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 Accelerator,...
32
"""simple docstring""" import os def a__ ( SCREAMING_SNAKE_CASE : int ): '''simple docstring''' lowerCAmelCase : str = len(grid[0] ) lowerCAmelCase : List[str] = len(SCREAMING_SNAKE_CASE ) lowerCAmelCase : Optional[int] = ...
645
0
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 from transformers.models...
488
import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import TEXT_GUIDED_...
488
1
import socket def lowerCAmelCase_ (): """simple docstring""" UpperCAmelCase_: Union[str, Any] = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) UpperCAmelCase_: Optional[int] = socket.gethostname() UpperCAmelCase_: List[...
556
'''simple docstring''' def _lowerCAmelCase ( _UpperCamelCase : int ) -> "list[int]": """simple docstring""" if upper_limit < 0: raise ValueError('Limit for the Catalan sequence must be ≥ 0' ) _SCREAMING_SNAKE_CASE =[0] * (upper_limit + 1) # Base cas...
405
0
"""simple docstring""" 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...
217
"""simple docstring""" import math def __a ( ) ->None: a__: int = input('Enter message: ' ) a__: List[str] = int(input(F'Enter key [2-{len(_SCREAMING_SNAKE_CASE ) - 1}]: ' ) ) a__: int = input('Encryption/Decryption [e/d]: ' ) if mode....
217
1
'''simple docstring''' import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPModel, CL...
660
'''simple docstring''' def lowerCamelCase_ ( __UpperCamelCase : int , __UpperCamelCase : int ) -> int: """simple docstring""" while second != 0: _A = first & second first ^= second _A = c << 1 ...
292
0
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np __A : Dict = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 __A : Tuple = typing.Union[np.floataa, int, float] # noqa: UP007 def lowerCamelC...
714
import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime as ort __A : ...
450
0
"""simple docstring""" def __snake_case ( _lowercase ): """simple docstring""" UpperCamelCase = int(_lowercase ) if n_element < 1: UpperCamelCase = ValueError('''a should be a positive number''' ) raise my_error UpperCamelC...
34
import numpy # List of input, output pairs snake_case__ : Optional[Any] = ( ((5, 2, 3), 1_5), ((6, 5, 9), 2_5), ((1_1, 1_2, 1_3), 4_1), ((1, 1, 1), 8), ((1_1, 1_2, 1_3), 4_1), ) snake_case__ : str = (((5_1_5, 2_2, 1_3), 5_5_5), ((6_1, 3_5, 4_9),...
392
0
import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_params import UNCONDITIONA...
707
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple import torch from torch import nn from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel from transformers.utils import ModelOutput @dataclass class snake_case ( __lowercase ):...
628
0
'''simple docstring''' import cva import numpy as np class _A : def __init__( self : Any , __magic_name__ : float , __magic_name__ : int ) -> Optional[int]: """simple docstring""" if k in (0.04, 0.06): __snake_c...
26
import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaImgaImgPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_ima...
217
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowercase_ = {"""configuration_plbart""": ["""PLBART_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PLBartConfig"""...
717
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class _snake_case ( lowercase__): def A__ ( self : Optional[Any], __lowercase : str ): with open(__lowercase, encoding="utf-8" ) as ...
37
0
def __UpperCAmelCase ( a_): return str(a_) == str(a_)[::-1] def __UpperCAmelCase ( a_): return int(a_) + int(str(a_)[::-1]) def __UpperCAmelCase ( a_ = 1_00_00): snake_case_ = [] for num in range(1 , a_): snake_case_ ...
198
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class UpperCamelCase_ : '''simple docstring''' lowerCAmelCase = None lowerCAmelCase = False lowerCAmelCase = False lowerCAmelCase = F...
198
1
"""simple docstring""" import inspect import unittest from typing import List import numpy as np from transformers import EfficientFormerConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_availa...
616
"""simple docstring""" def A ( snake_case__ ): '''simple docstring''' if not nums: # Makes sure that the list is not empty raise ValueError("""List is empty""" ) SCREAMING_SNAKE_CASE__ = sum(snake_case__ ) / len(snake_case__ ) # Calculat...
616
1
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 import ...
64
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface...
64
1
import doctest from collections import deque import numpy as np class lowercase__ : def __init__( self : Any ): '''simple docstring''' SCREAMING_SNAKE_CASE : Optional[int] = [2, 1, 2, -1] SCREA...
34
# 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 a...
34
1
import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from transformers.utils import lo...
576
import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common...
576
1
'''simple docstring''' def UpperCAmelCase_ (__a : Optional[Any] , __a : Dict , __a : Any ): """simple docstring""" def count_of_possible_combinations(__a : Optional[Any] ) -> int: if target < 0: return 0 if target == 0: ret...
711
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase = logging.get_logger(__name__) __lowerCAmelCase = { """microsoft/unispeech-sat-base-100h-libri-ft""": ( """https://huggi...
319
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : Dict = logging.get_logger(__name__) __lowerCamelCase : str = { '''RWKV/rwkv-4-169m-pile''': '''https://huggingface.co/RWKV/rwkv-...
653
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : List[Any] = logging.get_logger(__name__) __lowerCamelCase : Dict = { '''weiweishi/roc-bert-base-zh''': '''https://huggingface.co...
653
1
"""simple docstring""" import torch from diffusers import CMStochasticIterativeScheduler from .test_schedulers import SchedulerCommonTest class __lowerCAmelCase ( UpperCamelCase_): '''simple docstring''' __magic_name__ : Union[str, Any] = (CMStochasticIterativeSchedule...
712
"""simple docstring""" 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, prepare_image_inputs if is_torch_avail...
595
0
'''simple docstring''' def lowercase (_A = 1_0_0_0 ): """simple docstring""" _lowerCAmelCase : List[str] = 2**power _lowerCAmelCase : List[Any] = str(__snake_case ) _lowerCAmelCas...
444
'''simple docstring''' 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 ( ...
274
0
"""simple docstring""" import logging import os from dataclasses import dataclass, field from typing import Dict, Optional import datasets import numpy as np import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, EvalPrediction, HfArgumentParser, ...
702
"""simple docstring""" import argparse import torch from transformers import ( UniSpeechSatConfig, UniSpeechSatForAudioFrameClassification, UniSpeechSatForSequenceClassification, UniSpeechSatForXVector, WavaVecaFeatureExtractor, logging, ) logging.set_verbosity_info() __SCREAMING_SNAK...
477
0
from ...configuration_utils import PretrainedConfig from ...utils import logging a =logging.get_logger(__name__) a ={ # See all MEGATRON_BERT models at https://huggingface.co/models?filter=bert } class A_ ( SCREAMING_SNAKE_CASE ): _UpperCAmelCase :...
652
import math def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ ) -> list: __lowerCamelCase : Union[str, Any] = [True] * n __lowerCamelCase : List[Any] = False __lowerCamelCase : int = False __lowerCamelCase : An...
652
1
"""simple docstring""" import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def lowercase (_lowerCAmelCase ): return x + 2 class lowerCAmelCase_ ( unittest.TestCase ): '''simple docstri...
719
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) SCREAMING_SNAKE_CASE_ = { '''configuration_mega''': ['''MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MegaConfig''', '''MegaOnnxConfig''']...
573
0
from math import factorial, radians def lowercase_ ( __snake_case : float , __snake_case : int = 18 , __snake_case : int = 10 ) -> float: '''simple docstring''' snake_case__ :Optional[int] = angle_in_degrees - ((a...
241
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class _snake_case ( _A ): @require_torch def lowerCAmelCase_ ( self ) -> Tupl...
241
1
'''simple docstring''' import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class snake_case__ ( unittest.TestCase): def A ( self : Dict ) -> Any: debug_launcher(test_scri...
216
'''simple docstring''' def __UpperCAmelCase ( A : int ) -> str: UpperCAmelCase_ : Dict = int(A ) if decimal in (0, 1): # Exit cases for the recursion return str(A ) UpperCAmelCase_ , UpperCAmelCase_ : Any = divmod(A , 2 ...
216
1
import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class ...
61
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 __lowerCamelCase ( __a :int ) ...
176
0
import argparse import re import numpy as np import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SamConfig, SamImageProcessor, SamModel, SamProcessor, SamVisionConfig, ) __magic_name__ = { '''iou_prediction_he...
530
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_pegasus import PegasusTokenizer else: __magic_name__ ...
530
1
'''simple docstring''' import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_dev...
28
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 ort ...
593
0
import argparse import gc import json import os 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 Accel...
115
# 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 import deprecate dep...
115
1
'''simple docstring''' import json import os import shutil import tempfile import unittest from transformers import BatchEncoding, CanineTokenizer from transformers.testing_utils import require_tokenizers, require_torch from transformers.tokenization_utils import AddedToken from transformers.utils ...
435
'''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 TokenizerTe...
435
1
"""simple docstring""" import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # -...
719
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformer...
348
0
from __future__ import annotations def UpperCamelCase_ ( __a ) -> bool: a__ : str = str(__a ) return n == n[::-1] def UpperCamelCase_ ( __a = 1_000_000 ) -> str: a__ : Any = 0 for i in range(1 , __a ): if is_palindrome(...
37
class A__ : """simple docstring""" def __init__( self : List[Any] , lowerCamelCase__ : str , lowerCamelCase__ : Union[str, Any] , lowerCamelCase__ : List[str] ): a__ : str = name a__ : Optional[int] = value a__ : Dict = we...
37
1
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 Acce...
702
from __future__ import annotations __magic_name__ : str = [] def lowercase__ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase) -> bool: """simple docstring""" for i in range(len(_UpperCamelCase)): if board[row]...
410
0
SCREAMING_SNAKE_CASE = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' SCREAMING_SNAKE_CA...
99
from collections.abc import Callable def a (lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): __a = a __a = b if function(lowerCAmelCase__ ) == 0: # one of the a or b is a root for the function return a elif function(lowerCAmelCase__ ) == 0: ...
99
1
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def UpperCamelCase__ ( a_): def wrapper(*a_ , **a_): snake_case_ = timeit.default_timer() snake_case_ ...
708
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_SEQUENCE_CLASSIFICA...
607
0
"""simple docstring""" import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) A : Any = l...
516
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def UpperCamelCase ( snake_case__ : int ) -> Dict: UpperCamelCase ...
40
0
'''simple docstring''' import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class __A ( unittest.TestCase ): """simple docstring""" def snake_case_( self )-> List[An...
710
'''simple docstring''' import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor _lowerCAmelCase = logging.get_logger(__name__) class __A ( a ): """simple docstring""" def __init__( self ...
318
0
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is...
144
import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, ...
144
1
"""simple docstring""" from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder UpperCamelCase = datasets.utils.logging.get_logger(__name__) class lowercase_ (folder_based_builder.FolderBasedBu...
612
"""simple docstring""" import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def lowerCAmelCase ( UpperCamelCase_: Dict ) -> Any: '''simple docstring''' _a = os.path.jo...
612
1
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from .....
53
from __future__ import annotations def a_ ( lowerCAmelCase_ : list[float] ): if len(lowerCAmelCase_ ) < 2: raise ValueError('Monogons and Digons are not polygons in the Euclidean space' ) if any(i <= 0 for i in nums ): raise ValueError('All values must be g...
53
1
from abc import ABC, abstractmethod from argparse import ArgumentParser class __magic_name__ (snake_case_ ): '''simple docstring''' @staticmethod @abstractmethod def SCREAMING_SNAKE_CASE__ ( _a:ArgumentParser ): raise NotImplementedError() ...
208
from __future__ import annotations from collections.abc import Sequence from typing import Literal def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase ) -> str | Literal[False]: snake_case__ = list(__lowerCAmelCase ) snake_case__ ...
208
1
"""simple docstring""" def UpperCamelCase ( _lowerCAmelCase : int, _lowerCAmelCase : int ) -> int: _UpperCAmelCase : Optional[int] = 1 # To kept the Calculated Value # Since C(n, k) = C(n, n-k) if k > (n - k): _UpperCAmelCase : Lis...
238
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ : Union[str, Any] = { '''configuration_mobilenet_v2''': [ '''MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP''', ''...
594
0
import os import string import sys _lowerCamelCase : Optional[int] = 1 << 8 _lowerCamelCase : Union[str, Any] = { 'tab': ord('\t'), 'newline': ord('\r'), 'esc': 27, 'up': 65 + ARROW_KEY_FLAG, 'down': 66 + ARROW_KEY_FLAG, 'right': 67 + ARR...
721
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCamelCase : Optional[Any] = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_M...
361
0
"""simple docstring""" # 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 e...
610
"""simple docstring""" 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 Token...
610
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ :Optional[Any] = logging.get_logger(__name__) UpperCAmelCase__ :List[str] = { """microsoft/biogpt""": """https://huggingface.co/microsoft/biogpt/resolve...
483
'''simple docstring''' import math def __lowercase () -> None: """simple docstring""" __lowerCamelCase : Optional[int] = input("""Enter message: """ ) __lowerCamelCase : Optional[Any] = int(input(f"Enter key [2-{len(_lowercase ) - 1}]: ...
483
1
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline _SCREAMING_SNAKE_CASE = argparse.ArgumentParser('''Stable Diffusion script with intel optimization''', add_he...
502
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import ( enable_full_determinism, ...
252
0
'''simple docstring''' from __future__ import annotations from typing import Generic, TypeVar A__ : Dict =TypeVar('T') class __A ( Generic[T] ): def __init__( self : Any , lowerCamelCase : T ): """simple docstring""" __A : List[str] = data _...
718
'''simple docstring''' A__ : int =8.3_1_4_4_6_2 # Unit - J mol-1 K-1 def A_ ( __SCREAMING_SNAKE_CASE : float , __SCREAMING_SNAKE_CASE : float , __SCREAMING_SNAKE_CASE : float ) -> float: """simple docstring""" if moles < 0 ...
499
0