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
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def __UpperCamelCase ( A , A , A ): # Initialise PyTorch model ...
415
import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_available, is_vision...
415
1
'''simple docstring''' import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common impo...
718
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available __lowercase : List[Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDepende...
357
0
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py lowerCamelCase_ = '''src/transformers''' # This is to make sure the transfor...
513
from __future__ import annotations import time import numpy as np lowerCamelCase_ = [8, 5, 9, 7] lowerCamelCase_ = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] lowerCamelCase_ = [ [3, 2, 1, 4], [0, 2, 5, 2], [5, 1, 0, 5], [1, 5, 3...
513
1
"""simple docstring""" def A_ ( __lowercase ): return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
709
"""simple docstring""" import requests from bsa import BeautifulSoup def A_ ( __lowercase = "https://www.worldometers.info/coronavirus" ): UpperCamelCase_ : Dict =BeautifulSoup(requests.get(__lowercase ).text , 'html.parser' ) UpperCamelCase_ : List[Any] =soup.fin...
395
0
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dim...
190
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _low...
369
0
'''simple docstring''' import argparse import fairseq import torch from torch import nn from transformers import ( MBartaaTokenizer, MBartConfig, MBartForCausalLM, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaMode...
644
'''simple docstring''' def lowerCamelCase_ ( SCREAMING_SNAKE_CASE__ : list[int] ) -> list[list[int]]: UpperCAmelCase_ : int = [] if len(SCREAMING_SNAKE_CASE__ ) == 1: return [nums.copy()] for _ in range(len(SCREAMING_SNAKE_CASE__ ) ...
644
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase = { """configuration_bloom""": ["""BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BloomConfig""", """BloomOnnxConf...
525
"""simple docstring""" from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": lowerCAmelCase__ = input('Enter image url: ').strip() print(F'Downloading image from {url} ...') lowerCAmelCase__ = BeautifulSoup(requests.get(url).conten...
621
0
import unittest import numpy as np def _a ( lowercase__ : np.ndarray , lowercase__ : np.ndarray , lowercase__ : np.ndarray , lowercase__ : np.ndarray | None = None , ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Any = np.shape(__snake_...
713
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, ViltForMaskedLM, ViltForQu...
636
0
'''simple docstring''' import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermark...
578
'''simple docstring''' import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def lowerCAmelCase_ ( _lowerCamelCase: Optional[int] , _lowerCamelCase: str , _lowerCamelCase: str , _lowerCamel...
578
1
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 __Uppe...
703
import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class lowercase__ ( __SCREAMING_SNAKE_CASE ): def __init__( self : Dict , _lowercase : int , ...
277
0
import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger SCREAMING_SNAKE_CASE__ = '''<<<<<<< This should probably be modified because it mentions: ''' SCREAMING_SNAKE_CASE__ = ...
9
"""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_CACHE, WEIGHTS_NAME...
83
0
from __future__ import annotations from typing import Any def _lowerCAmelCase ( __lowerCAmelCase ) -> None: """simple docstring""" create_state_space_tree(__lowerCAmelCase , [] , 0 ) def _lowerCAmelCase ( __lowerCAmelCase ,...
714
from ...configuration_utils import PretrainedConfig from ...utils import logging A__ = logging.get_logger(__name__) A__ = { '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json''', '''microsoft/markuplm-large''': '''https://huggingfac...
219
0
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): im...
64
'''simple docstring''' import random def _UpperCAmelCase ( _lowerCamelCase : Optional[Any] , _lowerCamelCase : Optional[Any] , _lowerCamelCase : List[str] ) -> Optional[Any]: _lowerCAmelCase : Tuple = a[left_index] _lowerCAmelCase : Optiona...
384
0
import logging from transformers import PretrainedConfig A_ : Tuple = logging.getLogger(__name__) A_ : Dict = { '''bertabs-finetuned-cnndm''': '''https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json''', }...
712
import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision, slow, tor...
32
0
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel __a : str = HfApi() __a : Dict = {} # fmt: off __a : List[str] = torch.tensor([ -0.7515, -1.6883, 0.2420, 0.0300, 0.6347, 1.3433, -1.1743, -3.7467, 1.2342, -2.2485, 0.463...
534
import math import sys def lowerCAmelCase( __lowerCamelCase ): if number != int(__lowerCamelCase ): raise ValueError('the value of input must be a natural number' ) if number < 0: raise ValueError('the value of input must not be a negative number' ) if number == 0:...
559
0
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration UpperCAmelCase__ = 50_0000 UpperCAmelCase__ , UpperCAmelCase__ = os.path.split(__file__) UpperCAmelCase__ = os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILE...
721
def A ( _UpperCAmelCase : list ) -> list: '''simple docstring''' if len(_UpperCAmelCase ) <= 1: return lst _UpperCAmelCase = 1 while i < len(_UpperCAmelCase ): if lst[i - 1] <= lst[i]: i += 1 else: _UpperCAmelCase...
639
0
import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizerBase def lowercase( U...
537
def lowercase( UpperCamelCase_ , UpperCamelCase_ ) -> List[str]: '''simple docstring''' _enforce_args(UpperCamelCase_ , UpperCamelCase_ ) if n == 0: return 0 UpperCamelCase = float("""-inf""" ) for i in range(1 , n + 1 ): UpperCamelCase ...
537
1
'''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...
710
'''simple docstring''' from __future__ import annotations from typing import Any def a__ ( _SCREAMING_SNAKE_CASE : list ) -> int: """simple docstring""" if not postfix_notation: return 0 UpperCAmelCase_ : Tuple = {"+", "-", "*", "/"} ...
323
0
import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor lowerCAmelCase_ = logging.get_logger(__name__) class _A ( _lowerCamelCase ): def __init__( self : List[Any] , *_A : List[Any...
217
def UpperCamelCase_( _A :Union[str, Any] )-> List[str]: UpperCamelCase__ = [0] * len(_A ) UpperCamelCase__ = [] UpperCamelCase__ = [] UpperCamelCase__ = 0 for values in graph.values(): for i in values: indegree[i] += 1 for...
551
0
import logging from transformers import PretrainedConfig _lowercase = logging.getLogger(__name__) _lowercase = { """bertabs-finetuned-cnndm""": """https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/config.json""", } class lo...
431
import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP _lowercase = False try: _lowercase = _is_packag...
431
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available UpperCAmelCase__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: U...
351
"""simple docstring""" from typing import Any def __lowerCamelCase ( __UpperCamelCase ) -> list[Any]: """simple docstring""" if not input_list: return [] lowerCAmelCase_ : Any = [input_list.count(__UpperCamelCase ) for value in input_list] lowerCAme...
610
0
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, ToTensor from accelerate import Acce...
710
import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_utils import...
453
0
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, tor...
24
from __future__ import annotations def SCREAMING_SNAKE_CASE ( UpperCAmelCase__ ): """simple docstring""" _SCREAMING_SNAKE_CASE = 2 _SCREAMING_SNAKE_CASE = [] while i * i <= n: if n % i: i += 1 else: n //= i ...
605
0
"""simple docstring""" from __future__ import annotations import typing from collections import Counter def A( snake_case_ ): """simple docstring""" lowercase__: typing.Counter[int] = Counter() for base in range(1 , max_perimeter + 1 ): ...
704
"""simple docstring""" class _a : '''simple docstring''' def __init__( self) -> Union[str, Any]: '''simple docstring''' lowercase__: Union[str, Any] = 0 lowercase__: Optional[Any] = 0 lowercase...
120
0
'''simple docstring''' import gc import inspect import unittest import torch from parameterized import parameterized from diffusers import PriorTransformer from diffusers.utils import floats_tensor, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_m...
460
'''simple docstring''' def _SCREAMING_SNAKE_CASE (A ) -> bool: """simple docstring""" if not isinstance(A , A ): raise ValueError('''Input series is not valid, valid series - [2, 4, 6]''' ) if len(A ) == 0: raise ValueError('''Input li...
460
1
'''simple docstring''' import os import re import shutil from argparse import ArgumentParser, Namespace from datasets.commands import BaseDatasetsCLICommand from datasets.utils.logging import get_logger a_ = "<<<<<<< This should probably be modified because it mentions: " a_ = "======...
711
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UN...
92
0
import argparse UpperCAmelCase : Any = "docs/source/_static/js/custom.js" def __lowerCamelCase ( lowerCamelCase__ : List[Any] ): '''simple docstring''' with open(__lowerCamelCase , encoding="""utf-8""" , newline="""\n""" ) as f: lowerCa...
457
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, T...
446
0
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging __SCREAMING_SNAKE_CASE :Optional[int] = l...
712
'''simple docstring''' import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common i...
119
0
"""simple docstring""" import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPi...
567
"""simple docstring""" def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' UpperCAmelCase = [0] * len(lowerCAmelCase ) UpperCAmelCase = [] UpperCAmelCase = [1] * len(lowerCAmelCase ) for values...
673
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 ...
160
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available _lowerCAmelCase = {'''tokenization_herbert''': ['''HerbertTokenizer''']} try: if not is_tokenizers_available(): raise OptionalDependencyNotAvailable() e...
160
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_speech_available, is_torch_available A_ : Union[str, Any] = { "configuration_audio_spectrogram_transformer": [ "AUDIO_SPECTROGRAM_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "AS...
456
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
430
0
import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils import is_torch_available ...
719
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE : Dict = { '''configuration_longformer''': [ '''LONGFORMER_PRETRAINED_CONFIG_AR...
472
0
'''simple docstring''' from __future__ import annotations A_ : Tuple = { "A": ["B", "C", "E"], "B": ["A", "D", "E"], "C": ["A", "F", "G"], "D": ["B"], "E": ["A", "B", "D"], "F": ["C"], "G": ["C"], } class __snake_case : '''simple docstring''' def ...
38
'''simple docstring''' 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_token...
320
0
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_g...
709
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class __UpperCAmelCase ( _lowerCamelCase ): @staticmethod @abstractmethod def lowerCamelCase ( lowerCAmelCase_ ): """simple docstring""" rai...
542
0
"""simple docstring""" from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps...
289
"""simple docstring""" 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 __snake_case ( SCREAMING_SNAKE_CASE__ : int ) -> int: ...
289
1
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : int , lowerCAmelCase__ : int ) -> str: """simple docstring""" if a < 0 or b < 0: raise ValueError('the value of both inputs must be positive' ) lowerCAmelCase_ ...
711
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : Optional[int] , lowerCAmelCase__ : Any ) -> int: """simple docstring""" lowerCAmelCase_ : Tuple = 0 while b > 0: if b & 1: res += a a +...
317
0
def lowerCamelCase_ ( UpperCamelCase__ : str ) -> Optional[int]: """simple docstring""" __lowerCamelCase = 0 # if input_string is "aba" than new_input_string become "a|b|a" __lowerCamelCase = '' __lowerCamelCase =...
469
"""simple docstring""" from __future__ import annotations from statistics import mean def _UpperCAmelCase ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ): """simple docstring""" lowerCAmelCase__ = [0] * no_of_processes lowerCAmelCase__ = [0] * no_of_proces...
644
0
import os import re import shutil import sys import tempfile import unittest import black __magic_name__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402 # This ...
391
import argparse import torch from transformers import LxmertConfig, LxmertForPreTraining, load_tf_weights_in_lxmert from transformers.utils import logging logging.set_verbosity_info() def _lowerCAmelCase ( A__: Optional[int] , A__: List[Any] , A__: str ): '''simp...
391
1
"""simple docstring""" def a_ ( lowercase__ :Any, lowercase__ :Optional[Any] ): __lowerCamelCase = int(lowercase_ ) # Initialize Result __lowerCamelCase = [] # Traverse through all denomination for denomination in reversed(lowercase_ ...
281
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_available(): ...
12
0
import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf,...
709
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a_ : Union[str, Any] = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise OptionalDependen...
148
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_...
395
def lowerCamelCase__ ( a : list , a : list , a : int , a : int , a : int ) -> int: """simple docstring""" if index == number_of_items: return 0 a__ :str = 0 a__ :Union[str, Any] = 0 a__ :Optional[int...
395
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 im...
717
import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_available, ) from . ...
83
0
from random import randint, random def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE = False , SCREAMING_SNAKE_CASE = False , SCREAMING_SNAKE_CASE = 5 , ): """simple docstring""" lowercase__ =...
43
from typing import Dict, List, Optional, Union import numpy as np from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy snake_case__ = logging.get_logger(__name__) class lower...
395
0
'''simple docstring''' lowercase__ = "0.18.2" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version,...
707
'''simple docstring''' import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor lowercase__ = logging.get_logger(__name__) class A_ ( _snake_case ): '''simple docstring''' def __init__...
695
0
'''simple docstring''' import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import VideoMAEConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from t...
107
'''simple docstring''' from __future__ import annotations def _SCREAMING_SNAKE_CASE ( __snake_case : int | str ): _A = str(__snake_case ) return n == n[::-1] def _SCREAMING_SNAKE_CASE ( __snake_case : int = 1_0_0_0_0_0_0 ): _A = 0 f...
107
1
'''simple docstring''' import os import sys import unittest A__ : Tuple = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_dummies # noqa: E402 from check_dummies import create_dummy_files,...
124
'''simple docstring''' import argparse from collections import defaultdict import yaml A__ : List[str] = '''docs/source/en/_toctree.yml''' def a_ ( _UpperCAmelCase : List[Any] ) -> List[str]: __snake_case : str = defaultdict(_...
124
1
'''simple docstring''' import re import string from collections import Counter import sacrebleu import sacremoses from packaging import version import datasets SCREAMING_SNAKE_CASE__ = "\n@inproceedings{xu-etal-2016-optimizing,\n title = {Optimizing Statistical Machine Tra...
267
'''simple docstring''' from __future__ import annotations def lowerCamelCase ( _snake_case : int ,_snake_case : int ): '''simple docstring''' if b == 0: return (1, 0) ((lowercase__) , (lowercase__)) = extend...
267
1
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 TokenizerTesterMixin class lowercase ...
108
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING _UpperCAmelCase : Dict = logging.get_logger(__name__) class lowercase ( lowercase_ ): __SCREAMING_SNAKE_CASE : Any = '...
108
1
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def _UpperCAmelCase ( __lowerCamelCase : ndarray ) -> float: return np.dot(__lowerCamelCase , __lowerCamelCase ) class lowerCAmelCase__ :...
224
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import requ...
224
1
import qiskit def _UpperCAmelCase ( UpperCAmelCase : int , UpperCAmelCase : int ): """simple docstring""" __lowerCamelCase : Dict = qiskit.Aer.get_backend("""aer_simulator""" ) # Create a Quantum Circuit a...
703
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProce...
458
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase = { """configuration_mctct""": ["""MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MCTCTConfig"""], """feature_extraction_mctct""": ["""MC...
432
import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class UpperCamelCase_ ( unittest.TestCase ): '''simple docstring''' UpperCAmelCase__ = JukeboxTokenizer UpperCAmelCase__ = { '''artist''': '''Z...
87
0
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging _lowerCAmelCase : Dict = logging.get_logger(__name__) _lowerCAmelCase : Dict = { '''t5-small''': '''https://huggi...
712
"""simple docstring""" import math def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase ) -> float: '''simple docstring''' return math.pow(_lowerCamelCase , 2 ) - a def lowerCamelCase_( _lowerCamelCase ) -> float: '''simple docstring''' ...
386
0
'''simple docstring''' from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES UpperCamelCase_ : Any = logging.get_logger(__name__) UpperCamelCas...
185
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 : Any = False class lowercase ( ...
352
0
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils.import_...
710
import argparse import torch from transformers import ( SpeechTaConfig, SpeechTaFeatureExtractor, SpeechTaForSpeechToSpeech, SpeechTaForSpeechToText, SpeechTaForTextToSpeech, SpeechTaProcessor, SpeechTaTokenizer, logging, ) from transformers.tokenization_utils import AddedToken logg...
297
0
'''simple docstring''' from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor _lowercase ...
5
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCAmelCase__ ( metaclass=lowercase__ ): """simple docstring""" __UpperCAmelCase : List[str] = ['''keras_nlp'''] def __init__( self : Union[str, Any] ,*_a : List[An...
229
0
"""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_distilbert import DistilBertTokenizer _UpperCamelCase : Union[str, Any] = ...
715
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0...
645
0
'''simple docstring''' import math UpperCAmelCase_ : Optional[Any] = 1_0 UpperCAmelCase_ : Dict = 7 UpperCAmelCase_ : List[str] = BALLS_PER_COLOUR * NUM_COLOURS def _lowercase ( UpperCamelCase__ : int = 20 ): __A : Union[str, Any] = ...
365
'''simple docstring''' from math import factorial UpperCAmelCase_ : List[str] = {str(d): factorial(d) for d in range(1_0)} def _lowercase ( UpperCamelCase__ : int ): return sum(DIGIT_FACTORIAL[d] for d in str(UpperCamelCase__ ) ) def _lowercase ...
365
1
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : int = 1000 ) -> int: '''simple docstring''' _UpperCAmelCase = 2**power _UpperCAmelCase = str(__lowercase ) _UpperCAmelCase = list(__lowercase ) _UpperCAmelCase ...
716
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __SCREAMING_SNAKE_CASE :List[str] = { '''configuration_swiftformer''': [ '''SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
119
0
'''simple docstring''' def lowerCAmelCase_ ( __A : list ): '''simple docstring''' snake_case: str = len(__A ) for i in range(1 , __A ): snake_case: Union[str, Any] = collection[i] snake_case: Dict = ...
329
'''simple docstring''' import torch from torch import nn class SCREAMING_SNAKE_CASE ( nn.Module ): '''simple docstring''' def __init__( self , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCRE...
329
1
'''simple docstring''' def __lowerCamelCase ( A__ ) -> list: """simple docstring""" UpperCamelCase = int(A__ ) if n_element < 1: UpperCamelCase = ValueError('a should be a positive number' ) raise my_error ...
704
'''simple docstring''' import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on impor...
324
0
'''simple docstring''' import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( ...
3
"""simple docstring""" def snake_case ( _a: float , _a: float )-> float: '''simple docstring''' return price * (1 + tax_rate) if __name__ == "__main__": print(f"""{price_plus_tax(100, 0.25) = }""") print(f"""{price_plus_tax(1_25.50, 0.05) = }""")
510
0
"""simple docstring""" import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class _UpperCamelCase ( lowerCamelCase__ ): """simple docstring""" snake_case_ = (KDPMaDiscreteScheduler,) snake...
147
"""simple docstring""" from math import loga def UpperCamelCase_ ( lowerCamelCase : int ) -> int: """simple docstring""" if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(lowerCamelCase , lo...
147
1
"""simple docstring""" import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def __magic_name__ ( UpperCamelCase : List[str] ) -> Optional[Any]: a__ = FileLock(str(tmpdir / 'foo.lock' ) ) a__ = FileLock(str(tmpdir / 'foo.lock...
273
'''simple docstring''' from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tenso...
356
0
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 SequenceF...
607
from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor lowercase = transform...
607
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from...
436
def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> Tuple: '''simple docstring''' lowerCAmelCase : Any = [] lowerCAmelCase : Dict = [] lowerCAmelCase : int = { '^': 3, '*': 2, '/': 2, ...
343
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_owlvit import OwlViTImageProcessor __A : List[Any] = logging.get_logger(__name__) class lowerCAmelCase__ ( lowerCAmelCase_ ): """simple docstring""" def __init__( ...
715
"""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/LICE...
281
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunDiscreteScheduler from ......
290
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask from...
290
1
"""simple docstring""" def lowercase_ ( _UpperCAmelCase ): """simple docstring""" A_ : List[Any] = set() # edges = list of graph's edges A_ : Union[str, Any] = get_edges(_UpperCAmelCase ) # While there are still elements in edges list, take an arbitra...
361
"""simple docstring""" import argparse from argparse import Namespace import torch from torch import nn from transformers import XGLMConfig, XGLMForCausalLM def lowercase_ ( _UpperCAmelCase ): """simple docstring""" A_ : Optional[Any] = [ '''decoder....
361
1
"""simple docstring""" import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging UpperCamelCase = """\ """ UpperCamelCase = """ Perplexity (PPL...
104
'''simple docstring''' import numpy as np def A__ ( A_ ) -> np.array: return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
497
0
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def A__ ( __lowerCamelCase ): return (data["data"], data["target"]) de...
721
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_image, load_numpy, slow, to...
597
0
from ..utils import ( OptionalDependencyNotAvailable, is_flax_available, is_scipy_available, is_torch_available, is_torchsde_available, ) try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...
61
import warnings from typing import Dict, List, Optional, Tuple from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging snake_case_ = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ (__snake_case ): __lowerCamelCase : Optional[Any] = ["...
164
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ : List[Any] = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise Opt...
709
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__ : Any = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : str = { """huggingface/informer-tourism-monthly""": ( ...
629
0
"""simple docstring""" import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": _lowerCAmelCase :Dict = argparse.ArgumentParser() parser.add_argument( '--checkpoint_path', default=None, type=str, requir...
506
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class SCREAMING_SNAKE_CASE__ ( nn.Module ): def __init__( self : str , lowerCAmelCase : int = 16 ...
169
0
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel __a = False __a = True __a = False if __name__ == "__main__": __a = argparse.ArgumentParser() ...
708
def lowerCamelCase__ ( _lowercase = 1000 ): '''simple docstring''' return sum(2 * a * ((a - 1) // 2) for a in range(3 , n + 1 ) ) if __name__ == "__main__": print(solution())
300
0
from statistics import mean import numpy as np def _lowercase ( lowercase__ , lowercase__ , lowercase__ , lowercase__ ): __lowerCAmelCase : List[Any] = 0 # Number of processes finished __lowerCAmelCase : List[Any] = 0 # Displays the finished p...
492
# Copyright (c) 2021-, NVIDIA CORPORATION. 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 ap...
492
1
'''simple docstring''' import argparse import fairseq import torch from transformers import UniSpeechSatConfig, UniSpeechSatForCTC, UniSpeechSatForPreTraining, logging logging.set_verbosity_info() __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { 'post_extract_pr...
703
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('9.1.0'): __UpperCAmelCase = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilinear': PIL.Im...
220
0
'''simple docstring''' import argparse import os import torch from transformers.utils import WEIGHTS_NAME _A: Any = ['''small''', '''medium''', '''large'''] _A: Dict = '''lm_head.decoder.weight''' _A: Any = '''lm_head.weight''' def _lowerCAm...
126
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_availabl...
660
0
from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig 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...
582
# Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def _lowerCamelCase ( A_ : Any ) -> str: '''simple docstring''' return 1 / (1 + np.exp(-z )) def _lower...
582
1
'''simple docstring''' from math import isclose, sqrt def __A ( _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : float ): """simple docstring""" __SCREAMING_SNAKE_CASE : Any ...
211
import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import...
477
0
'''simple docstring''' from math import isqrt def __UpperCAmelCase ( UpperCamelCase__ :int ) -> list[int]: snake_case__ : Dict = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in r...
574
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example _lowercase : Union[str, Any] =[ [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,...
574
1
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging __snake_case = logging.get_logger(__name__) def _A ( SCREAMING_SNAKE_CASE__ : Tuple=None , SCREAMING_SNAKE_CASE__ ...
658
"""simple docstring""" from __future__ import annotations from math import pi, sqrt def a__ ( lowerCAmelCase__ , lowerCAmelCase__ ): if inductance <= 0: raise ValueError("Inductance cannot be 0 or negative" ) elif capacitance <= 0: raise...
82
0
'''simple docstring''' import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch ...
717
'''simple docstring''' import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
461
0
from __future__ import annotations from typing import Generic, TypeVar __a :Optional[Any] = TypeVar('T') class _a ( Generic[T] ): """simple docstring""" def __init__( self : Tuple , UpperCAmelCase : str ): A_ = d...
86
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 ...
64
0
'''simple docstring''' import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( HubertConfig, HubertForCTC, HubertModel, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, logging, ) logging.set...
717
'''simple docstring''' from itertools import permutations def _UpperCamelCase ( UpperCamelCase__ ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False UpperCAmelCase__...
113
0
"""simple docstring""" import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForCon...
34
import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTokenizer, A...
509
0
"""simple docstring""" 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 GPTaToken...
711
"""simple docstring""" from __future__ import annotations from decimal import Decimal from numpy import array def _snake_case ( UpperCamelCase : list[list[float]] ): UpperCAmelCase : str = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works...
359
0
import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_mod...
89
"""simple docstring""" import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def _SC...
567
0
from __future__ import annotations import math import random from typing import Any class UpperCAmelCase : def __init__( self ): _lowerCAmelCase = [] _lowerCAmelCase = 0 _lowerCAmelCase = 0 def __lowerCAmelCase ( self ): return ...
720
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_determi...
664
0
"""simple docstring""" import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common impo...
213
"""simple docstring""" import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class __A : def __init__( self , a__ , a__ , a__ ): if dst_width < 0 or dst_height < 0: raise ValueError("""Destination width/height should be > 0""" ) ...
213
1
# tests directory-specific settings - this file is run automatically # by pytest before any tests are run import doctest import sys import warnings from os.path import abspath, dirname, join import _pytest from transformers.testing_utils import HfDoctestModule, HfDocTestParser # allow having multiple repository c...
345
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def __lowercase( __snake_case : Tuple ) -> ...
345
1
"""simple docstring""" from __future__ import annotations A: Optional[int] = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def _snake_case ( UpperCamelCase : list[list[int]] , UpperCamelCase : list[int] , UpperCamelCase : ...
160
"""simple docstring""" def _snake_case ( UpperCamelCase : str , UpperCamelCase : int ): UpperCAmelCase : List[Any] = word.split() def justify(UpperCamelCase : list , UpperCamelCase : int , UpperCamelCase : int ) -> str: UpperCAmelCa...
160
1
"""simple docstring""" import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def lowerCamelCase_ ( UpperCAme...
702
"""simple docstring""" def lowerCamelCase_ ( UpperCAmelCase_ ) ->float: """simple docstring""" return 10 - x * x def lowerCamelCase_ ( UpperCAmelCase_ , UpperCAmelCase_ ) ->float: """simple docstring""" if equ...
374
0
'''simple docstring''' import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class __magic_name__ ( unittest.TestCase , lowerCAmelCase_ ): def _A( self ): lowercase =load_tool('''text-classification''' ) self.tool.se...
72
"""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...
575
0
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class lowerCamelCase ( unittest.TestCase ): '''simple docstring''' def UpperCAmelCase__ ( self : List[Any] ) -> Dict: ...
501
import sys import turtle def lowercase__ ( __A: tuple[float, float] ,__A: tuple[float, float] ): '''simple docstring''' return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def lowercase__ ( __A: tuple[float, float] ,__A: tuple[float, float] ,__A: tuple[...
501
1
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def UpperCamelCase__ ( lowercase__ : Dict , lowercase__ : Union[str, Any]=7 ): snake_case : Dict = None if token is no...
134
"""simple docstring""" def UpperCamelCase__ ( lowercase__ : str ): snake_case : str = [int(lowercase__ ) for i in ip_va_address.split("." ) if i.isdigit()] return len(lowercase__ ) == 4 and all(0 <= int(lowercase__ ) <= 254 for octet in octets ) if __name__ == "__main__":...
134
1
import os import re import shutil import sys import tempfile import unittest import black a__ : Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, '''utils''')) import check_copies # noqa: E402 # This is the ...
706
def UpperCAmelCase_( a__ ): """simple docstring""" return 10 - x * x def UpperCAmelCase_( a__ , a__ ): """simple docstring""" if equation(a__ ) * equation(a__ ) >= 0: raise ValueError('''Wrong space!''' ) SCREAMING_SNAKE...
333
0
'''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/lic...
368
'''simple docstring''' from __future__ import annotations a__ : Optional[int] = list[tuple[int, int]] a__ : List[Any] = [ [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], ...
368
1
'''simple docstring''' def lowerCamelCase__ ( __lowerCamelCase : List[str] ): '''simple docstring''' if num < 0: return False _UpperCAmelCase : Dict =num _UpperCAmelCase : int =0 while num > 0: _UpperCAmelCase : ...
714
'''simple docstring''' 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_mvp imp...
331
0
"""simple docstring""" import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class A_ ( unittest.TestCase ): def _lowercase ...
46
"""simple docstring""" from typing import List, Optional, Union import numpy as np import PIL import torch from PIL import Image from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import...
46
1
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_se...
710
import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preprocessing import ...
167
0