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
"""simple docstring""" import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsA...
633
"""simple docstring""" import unittest from transformers import DonutProcessor a : Optional[int] = '''naver-clova-ix/donut-base''' class __UpperCamelCase ( unittest.TestCase ): def __a ( self ) -> Dict: a : O...
633
1
'''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 ...
79
'''simple docstring''' from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accele...
79
1
from __future__ import annotations from random import random class _lowerCAmelCase : def __init__( self : int , __snake_case : int | None = None ): lowerCamelCase :Dict = value lowerCamelCase :Any = random() lowerCame...
166
import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): im...
166
1
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCamelCase__ ( lowerCamelCase__ , unittest.TestCase): ...
90
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel_di...
90
1
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table import ar...
85
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ) def a_ ( ) -> Dict: ...
246
0
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import ( BaseOutput, OptionalDependencyNotAvailable, is_flax_available, is_k_diffusion_available, is_k_diffusion_version, is_onnx_available, is_torc...
711
from string import ascii_lowercase, ascii_uppercase def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ) -> str: if not sentence: return "" SCREAMING_SNAKE_CASE_ : int = dict(zip(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) ) return lower_to_upper.get(sentence[0]...
311
0
from functools import reduce lowerCamelCase_ : Dict = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" """668...
548
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class _UpperCamelCase ( unittest.TestCase , _A ): '''simple docstring''' def lowerCAmelCase__ ( self : Tuple ): UpperCamelCase_: List[Any] = ...
548
1
import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def snake_case__ ( __lowercase , __lowercase , __lowercase , __lo...
182
import argparse import io import requests import torch from omegaconf import OmegaConf from diffusers import AutoencoderKL from diffusers.pipelines.stable_diffusion.convert_from_ckpt import ( assign_to_checkpoint, conv_attn_to_linear, create_vae_diffusers_config, renew_vae_attention_paths, ren...
182
1
'''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/LICENS...
94
"""simple docstring""" from __future__ import annotations lowerCamelCase_ = 8.9_88e9 # units = N * m^s * C^-2 def __lowerCamelCase ( a_ : float , a_ : float , a_ : float , a_ : float ) -> dict[str, float]: __SCREAMING_SNAKE_CASE ...
498
0
from __future__ import annotations import unittest from transformers import MobileBertConfig, is_tf_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelT...
589
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __lowerCAmelCase = {"""configuration_yolos""": ["""YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP""", """YolosConfig""", """YolosOnnxConfig"""]} try: if not is_vision_available(...
589
1
"""simple docstring""" import unittest from transformers import MraConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tenso...
65
from __future__ import annotations import numpy as np def A__ ( _a : np.ndarray ): '''simple docstring''' snake_case__ , snake_case__ : str =np.shape(_a ) if rows != columns: snake_case__ : Any =( """'table' has to be of ...
385
0
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf...
691
'''simple docstring''' import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unorde...
691
1
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 as ...
190
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a__: List[Any] = { 'configuration_x_clip': [ 'XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XCLIPConfig', 'XCLIPTextConfig', 'XCLIPVis...
190
1
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, ControlNetModel, DDIMScheduler, StableDiffusionControlNetImgaImgPip...
703
'''simple docstring''' 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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers im...
432
0
"""simple docstring""" import unittest from transformers import SqueezeBertConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_com...
281
"""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 ImageProcessingSav...
281
1
def UpperCAmelCase ( A__ ) -> int: if not isinstance(A__ , A__ ): raise ValueError("""Input must be an integer""" ) if input_num <= 0: raise ValueError("""Input must be positive""" ) return sum( divisor for divisor in range(1 , input_num // 2 + 1 )...
711
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging UpperCAmelCase_ = logging.get_logger(__name__) def UpperCAmelCase ( A__ , A__ ...
519
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor lowerCAmelCase_ : List[Any] = logging.get_logger(__name__) class lowerCamelCase_ ( __lowerCamelCase ): ...
527
'''simple docstring''' import argparse import datetime import json import time import warnings from logging import getLogger from pathlib import Path from typing import Dict, List import torch from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils import calculate_bleu, c...
399
0
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowerCamelCase_ : Dict = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARC...
718
from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowerCAmelCase( __lowerCamelCase ): # A local function to see if a dot lands in the circle. def is_in_circle(__lowerCamelCase , __lowerCamelCase ) -> bool: ...
246
0
'''simple docstring''' from __future__ import annotations A__ : Any =list[tuple[int, int]] A__ : Dict =[ [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...
207
'''simple docstring''' from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar snake_case_ : Optional[Any] = TypeVar('KEY') snake_case_ : Dict = TypeVar('VAL') @dataclass(frozen=lowercase , slots=lowerca...
195
0
import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrogram_diffusion import Sp...
704
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def __SCREAMING_SNAK...
688
0
"""simple docstring""" from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse("""3.8"""): import importlib_metadata else: import importlib.metadata as importlib_metadata ...
543
"""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_util...
543
1
'''simple docstring''' import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy ...
331
'''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 transfor...
331
1
'''simple docstring''' def lowerCAmelCase ( UpperCamelCase__ : list[int] , UpperCamelCase__ : list[int] ): """simple docstring""" __UpperCAmelCase = len(UpperCamelCase__ ) print('''The following activities are selected:''' ) # The first act...
262
"""simple docstring""" from __future__ import annotations import os from collections.abc import Mapping a : Optional[Any] = tuple[int, int] class lowercase: def __init__( self , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> None: ...
273
0
'''simple docstring''' from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasu...
714
'''simple docstring''' A_ = {"a": ["c", "b"], "b": ["d", "e"], "c": [], "d": [], "e": []} A_ = ["a", "b", "c", "d", "e"] def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ) -> List[str]: lowerCamelCase_ = start # add current to vi...
384
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_...
65
"""simple docstring""" from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchF...
65
1
from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCAmelCase_ = logging.get_logger(__name__) # TODO: upload to AWS UpperCAmelCase_ = { "yjernite/retribert-base-uncased": ( "https://huggingface.co/yjernite/retribert-base-uncased/resolve...
702
'''simple docstring''' from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse("3.8"): import importlib_metadata else: import importlib.metadata as importlib_...
490
0
def lowerCamelCase_ ( UpperCamelCase__ : int = 3, UpperCamelCase__ : int = 7, UpperCamelCase__ : int = 100_0000 ): '''simple docstring''' UpperCamelCase__ = 0 UpperCamelCase__ = 1 for current_denominator ...
240
import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils import r...
240
1
from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration __UpperCamelCase : str = HfArgumentParser(InitializationArguments) __UpperCamelCase : Dict = parser.parse_a...
106
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[int] = logging.get_logger(__name__) __UpperCamelCase : Optional[int] = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base...
106
1
import heapq as hq import math from collections.abc import Iterator class _a : """simple docstring""" def __init__( self , _UpperCAmelCase ) -> Optional[Any]: UpperCamelCase_ = str(id_ ) UpperCamelCase_ = None UpperCa...
23
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers i...
646
0
import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion import Stab...
288
import numpy as np from cva import destroyAllWindows, imread, imshow, waitKey class lowerCAmelCase_ : def __init__( self : Union[str, Any] , SCREAMING_SNAKE_CASE_ : Optional[Any] , SCREAMING_SNAKE_CASE_ : int , SCREAMING_SNAKE_CASE_ : int ): ...
288
1
import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device _lowercase = False class _UpperCAmelCase ( unittest.TestCase ): pass @sl...
632
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase = logging.get_logger(__name__) class _UpperCAmelCase ( A__ ): UpperCamelCase__ = '''timm_backbone''' def __init__( self , a__=None , a__=3 , a__=True , ...
632
1
'''simple docstring''' from collections.abc import Iterable from typing import Generic, TypeVar lowerCAmelCase : Optional[Any] = TypeVar("""_T""") class _UpperCamelCase ( Generic[_T]): '''simple docstring''' def __init__( self , a_ = None ) -> ...
712
'''simple docstring''' import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import classes f...
425
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_dimension_format, ) ...
479
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKING...
479
1
'''simple docstring''' from random import randint from tempfile import TemporaryFile import numpy as np def _snake_case ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : Optional[int] , _SCREAMING_SNAKE_CASE : Dict ) -> Union[str, Any]: ...
344
'''simple docstring''' import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...gen...
344
1
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_gpta import GPTaTokenizer if TYPE_CHECK...
297
from itertools import count def UpperCamelCase__ ( _A: int = 50 ): '''simple docstring''' __lowerCamelCase = [1] * min_block_length for n in count(_A ): fill_count_functions.append(1 ) for block_length in range(_A , ...
479
0
"""simple docstring""" from __future__ import annotations import math class _UpperCAmelCase : def __init__( self : Dict , A : int ) -> None: lowercase_ : Optional[int] = size # approximate the overall si...
718
"""simple docstring""" import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset fro...
141
0
import re def __a ( lowerCAmelCase_ : str ) -> bool: '''simple docstring''' UpperCAmelCase_= re.compile(r"""^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$""" ) if match := re.search(__lowercase ,__lowercase ): return match.string == phone r...
593
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch if is_tf_available(): ...
670
0
'''simple docstring''' import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
490
'''simple docstring''' def SCREAMING_SNAKE_CASE ( a_ : int ): __a = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def SCREAMING_SNAKE_CASE ( a_ : int = 100 ): __a = 1 __a = 2 for i ...
490
1
import math import tensorflow as tf from packaging import version def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> Dict: """simple docstring""" a = tf.convert_to_tensor(lowerCamelCase__ ) a = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 )...
387
import random from typing import Any def __lowerCamelCase ( lowerCamelCase__ : list ): '''simple docstring''' for _ in range(len(lowerCamelCase__ ) ): lowerCamelCase = random.randint(0 , len(lowerCamelCase__ ) - 1 ) lowerCamelCa...
457
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__: Tuple = logging.get_logger(__name__) UpperCamelCase__: Optional[int] = { "asapp/sew-d-tiny-100...
528
'''simple docstring''' import contextlib import os import sqlitea import pytest from datasets import Dataset, Features, Value from datasets.io.sql import SqlDatasetReader, SqlDatasetWriter from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases, require_sq...
528
1
'''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, PreTrainedTokenizer from ...utils import logging lowerCAmelCase_ : Dict = logging.get_logger(__nam...
692
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase = logging.get_logger(__name__) __UpperCamelCase = { 'microsoft/trocr-base-handwritten': ( 'https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json' ), ...
551
0
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Any class SCREAMING_SNAKE_CASE__ : def __init__( self , A_ )-> str: '''simple docstring''' UpperCamelCase ...
432
'''simple docstring''' import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, ...
432
1
'''simple docstring''' from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class a__( lowerCAmelCase__ ): '''simpl...
370
'''simple docstring''' def snake_case__ ( _A: int ) -> list[int]: '''simple docstring''' if length <= 0 or not isinstance(_A , _A ): raise ValueError("""Length must be a positive integer.""" ) return [n * (2 * n - 1) for n in range(_A )] if __name__ == "__m...
370
1
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ...
709
from collections import defaultdict class a_ : def __init__( self :Tuple , _lowercase :List[str] , _lowercase :List[Any]) -> List[Any]: UpperCAmelCase_ = total # total no of tasks (N) # DP table will have a dimension of (2^M)*N ...
561
0
from collections import deque class _lowerCAmelCase : def __init__( self : Optional[Any] , __snake_case : str , __snake_case : int , __snake_case : int ): lowerCamelCase :Optional[int] = process_name # process name ...
166
# Copyright 2022 The HuggingFace Team and The OpenBMB 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 # #...
166
1
from __future__ import annotations def __lowerCAmelCase ( __snake_case , __snake_case , __snake_case ): if days_between_payments <= 0: raise ValueError("days_between_payments must be > 0" ) if daily_interest_rate < 0: raise ValueError("daily_...
721
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Any = logging.get_logger(__name__) lowerCamelCase : Dict = { '''microsoft/markuplm-base''': '''https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json''', '''mi...
290
0
import subprocess import sys from transformers import BertConfig, BertModel, BertTokenizer, pipeline from transformers.testing_utils import TestCasePlus, require_torch class snake_case__ ( __snake_case ): '''simple docstring''' @require_torch ...
121
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : str = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', ...
121
1
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) A_ ...
708
'''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 A_ = logging.get_logger(__name__) A_ = OrderedDict(...
123
0
import argparse from transformers import ( TapasConfig, TapasForMaskedLM, TapasForQuestionAnswering, TapasForSequenceClassification, TapasModel, TapasTokenizer, load_tf_weights_in_tapas, ) from transformers.utils import logging logging.set_verbosity_info() def a__ ...
529
from collections import OrderedDict from ...utils import logging from .auto_factory import _BaseAutoModelClass, _LazyAutoMapping, auto_class_update from .configuration_auto import CONFIG_MAPPING_NAMES __A : int = logging.get_logger(__name__) __A : List[str] = OrderedDict( ...
16
0
import math def _snake_case ( __snake_case ) -> bool: '''simple docstring''' UpperCAmelCase_ : Optional[int] = math.loga(math.sqrt(4 * positive_integer + 1 ) / 2 + 1 / 2 ) return exponent == int(__snake_case ) def _snake_case (...
455
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_commo...
455
1
import numpy as np _A = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""", """z"""], ] ...
258
import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from transformer...
258
1
'''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 MaskGenerationPipeline from ...
124
'''simple docstring''' from tempfile import TemporaryDirectory from unittest import TestCase from unittest.mock import MagicMock, patch from transformers import AutoModel, TFAutoModel from transformers.onnx import FeaturesManager from transformers.testing_utils import SMALL_MODEL_IDENTIFIER, require_tf, requi...
124
1
'''simple docstring''' import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": A : int = pd.read_csv("""sample_data.csv""", header...
349
'''simple docstring''' from __future__ import annotations import unittest from transformers import AutoTokenizer, MBartConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_config...
349
1
import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets lowercase = '''\ @inproceedings{popovic-2015-chrf, title = "chr{F}: character n-gram {F}-score for automatic {MT} evaluation", author = "Popovi{\'c}, Maja", booktitle = "Proceedings of the Te...
103
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_...
103
1
'''simple docstring''' from __future__ import annotations from math import pi, sqrt def __a(SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float ): '''simple docstring''' if inductance <= 0: raise ValueError("Inductance cannot be 0 or negative" ...
18
import math def __lowerCAmelCase ( _UpperCamelCase : int ) -> list[int]: '''simple docstring''' SCREAMING_SNAKE_CASE = [] SCREAMING_SNAKE_CASE = 2 SCREAMING_SNAKE_CASE = int(math.sqrt(_UpperCamelCase ) ) # Size of every segment SCREAMING_SNA...
439
0
"""simple docstring""" import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_comm...
717
"""simple docstring""" def a_ ( _lowerCAmelCase : str ): '''simple docstring''' lowercase__ : Any = [0] * len(_lowerCAmelCase ) for i in range(1 , len(_lowerCAmelCase ) ): # use last results for better performance - dynamic progra...
645
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 impo...
3
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer _A = {"""vocab_file""": """vocab.txt""", """tokenizer_file""": """tokenizer.json"""}...
258
0
"""simple docstring""" import string def lowerCAmelCase ( __UpperCamelCase ): '''simple docstring''' for key in range(len(string.ascii_uppercase ) ): UpperCAmelCase__ : List[str] = """""" for symbol in message: if symbol in string.ascii_uppercase: UpperC...
709
"""simple docstring""" from typing import List import jiwer import jiwer.transforms as tr from packaging import version import datasets from datasets.config import PY_VERSION if PY_VERSION < version.parse('3.8'): import importlib_metadata else: import importlib.metadata as impo...
194
0
'''simple docstring''' def A__ ( __lowerCAmelCase : int , __lowerCAmelCase : int , __lowerCAmelCase : int ): lowerCamelCase__ = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return tot...
50
import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image from ...image_u...
587
0
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase : Optional[Any] = logging.get_logger(__name__) lowercase : str ...
584
from ...utils import is_note_seq_available, is_transformers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...ut...
584
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE = { """abeja/gpt-neox-japanese-2.7b""": """https://huggingface.co/abeja/gpt-neox-japanese-2.7b/res...
163
"""simple docstring""" import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) class __magic_name__ ( lowercase__ ): def __init__( self : str , *snake_case_ : ...
163
1
'''simple docstring''' import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append(".") def lowerCAmelCase( a__ : Dict ): '''simple docstring''' ...
706
'''simple docstring''' 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 lowerCAmelCase_ = False try: ...
426
0
'''simple docstring''' import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm im...
22
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class a ( __lowercase ): def __init__( self , _lowerCAmelCase , _lowerCAmelCase = None , _lowerCAmelCase = None...
202
0
import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_mo...
719
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging a__ = logging.get_logger(__name__) def _UpperCAmelCase ( a : Union[tf.Tensor, np.ndarray] ): if isinstance(a , np.ndarray ): return list(tensor.shape ) ...
99
0
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class lowerCAmelCase ( __a , ...
149
import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[Any] = logging.get_logger(__name__) lowerCamelCase : Tuple = { '''kakaobrain...
149
1
import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_co...
717
import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBertForMaskedLM, Dist...
571
0
'''simple docstring''' import inspect import unittest from math import floor from transformers import CvtConfig from transformers.file_utils import cached_property, is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...
251
'''simple docstring''' def __lowerCAmelCase ( a_ = 1 , a_ = 1000 ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE : Tuple = 1 SCREAMING_SNAKE_CASE : Optional[int] = 0 for div...
251
1
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, Conditiona...
154
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tok...
154
1
'''simple docstring''' from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCAmelCase_ : int = logging.get_logger(__name__) UpperCAmelCase_ : Optional[Any] = { '''google/umt5...
24
'''simple docstring''' def _UpperCamelCase (_lowerCamelCase : int )-> int: '''simple docstring''' __snake_case = abs(_lowerCamelCase ) __snake_case = 0 while n > 0: res += n % 10 n //= 10 return res def ...
24
1
'''simple docstring''' import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class __magic_name__ ( nn.Module ): UpperCamelCase__ = 42 UpperCamelCase__ = 42 UpperC...
145
'''simple docstring''' from __future__ import annotations import unittest from transformers import LEDConfig, 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 from ...t...
145
1
from ..utils import DummyObject, requires_backends class lowerCamelCase__ ( metaclass=A__ ): __lowerCamelCase = ["""note_seq"""] def __init__( self : Optional[Any] , *__a : Tuple , **__a : Union[str, Any] ): ...
306
def __lowerCAmelCase ( _UpperCamelCase , _UpperCamelCase ) -> int: '''simple docstring''' return int((input_a, input_a).count(1 ) != 0 ) def __lowerCAmelCase ( ) -> None: '''simple docstring''' assert or_gate(0 ...
306
1
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig 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_...
719
'''simple docstring''' from __future__ import annotations def __magic_name__( lowerCamelCase, lowerCamelCase): __lowerCAmelCase = sorted(numsa + numsa) __lowerCAmelCase , __lowerCAmelCase = divmod(len(lowerCamelCase), 2) if mod...
474
0
"""simple docstring""" from collections import deque from .hash_table import HashTable class A__ ( __lowercase): """simple docstring""" def __init__( self: Optional[int] , *__a: Union[str, Any] , **__a: Dict )-> List[Any]: super().__init__(*__a ,...
222
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def snake_case ( ) -> Generator[int, None, None]: lowerCamelCase : dict[int, int] = {} lowerCamelCase : str = 2 while True: lowerCamelCase ...
222
1
'''simple docstring''' from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class ...
700
import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def snake_case ( UpperCAmelCase : List[Any] ): if "model" in orig_key: A = orig_key.replace('model.', '' ) if "norm1" in orig_key: A = orig_key.replace('norm1'...
110
0
from __future__ import annotations from functools import lru_cache from math import ceil lowerCamelCase__ : int = 1_0_0 lowerCamelCase__ : Optional[Any] = set(range(3, NUM_PRIMES, 2)) primes.add(2) lowerCamelCase__ : int for prime in range(3, ceil(NUM_PRIMES**0.5), 2): ...
12
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 as jnp from flax.jax_...
239
0
import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_...
709
import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient lowercase : Union[str, Any] = WebClient(token=os.environ["CI_SLACK_BOT_TOKEN"]) def snake_cas...
423
0
"""simple docstring""" from __future__ import annotations def __a ( A , A ) -> tuple[int, int]: '''simple docstring''' if b == 0: return (1, 0) ((A__) , (A__)) = extended_euclid(A , a % b ) A__ = a // b return (y, x - k *...
337
"""simple docstring""" import os import pytest from attr import dataclass __UpperCAmelCase ="""us-east-1""" # defaults region @dataclass class lowerCAmelCase__ : lowercase__ : str lowercase__ : List[Any] = """arn:aws:iam::558105141721:role/sagemaker_execution_role""" lower...
337
1
'''simple docstring''' import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING fr...
609
'''simple docstring''' import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_a...
609
1
from ... import PretrainedConfig __A = { "sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json", } class _A ( UpperCamelCase ): """simple docstring""" lowerCamelCase : Dict = NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP lowerCamelCa...
68
from __future__ import annotations def lowercase__ ( A_: list[list[int]] ) -> int: """simple docstring""" for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in rang...
68
1
def _a ( lowerCamelCase__ = 1_00_00_00 ) -> int: lowerCamelCase_ : Tuple = 1 lowerCamelCase_ : List[Any] = 1 lowerCamelCase_ : Optional[int] = {1: 1} for inputa in range(2 , lowerCamelCase__ ): lowerCamelCase_ ...
144
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_LM_MAPPING, AutoConfig, AutoModelForMaskedL...
144
1
from __future__ import annotations def __lowerCAmelCase ( _UpperCamelCase , _UpperCamelCase = None ) -> list[list[str]]: '''simple docstring''' lowerCamelCase__: int = word_bank or [] # create a table lowerCamelCase__: int ...
306
import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requi...
306
1
"""simple docstring""" from __future__ import annotations def UpperCamelCase_ ( lowerCAmelCase__ : list[int] ) -> int: """simple docstring""" lowerCAmelCase_ : List[Any] = len(lowerCAmelCase__ ) // 2 # choose the middle 3 elemen...
317
"""simple docstring""" 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_fu...
317
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) snake_case : Optional[int] = {'''configuration_encoder_decoder''': ['''EncoderDecoderConfig''']} try:...
566
'''simple docstring''' import re from flax.core.frozen_dict import freeze from flax.traverse_util import flatten_dict, unflatten_dict from jax.experimental import PartitionSpec as P # Sentinels UpperCamelCase_ : Optional[int] = object() # For specifying empty leaf dict `{}` UpperCamelCase_ ...
185
0
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class a__ : lowerCamelCase__: Optional[int] = None lowerCamelCase__: List[Any] = False lowerCamelCase__: int = ...
700
from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration_utils import FrozenDict f...
478
0
'''simple docstring''' import operator as op def a_ ( lowerCamelCase : Dict ): lowerCAmelCase = [] lowerCAmelCase = lambda lowerCamelCase , lowerCamelCase : int(x / y ) # noqa: E731 integer division operation lowerCAmelCase = ...
133
"""simple docstring""" import unittest from transformers import GPTSwaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin a = get_tests_dir('fixtures/test_sentencepiece_with_bytef...
169
0
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, ConditionalDetrForSegmentation, ...
700
# 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 requ...
423
0
def __snake_case ( _UpperCamelCase ) -> int: _a = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def __snake_case ( _UpperCamelCase = 1_00 ) -> int: _a = 1 _a = 2 for i in range(2 , max_n + 1 ): _a = pre_...
487
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, Effi...
487
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers import AutoTokenizer,...
330
'''simple docstring''' def UpperCamelCase_ ( snake_case_ : int = 10_00 ) -> int: '''simple docstring''' __lowerCAmelCase = -1 __lowerCAmelCase = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c ...
330
1
"""simple docstring""" import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _UpperCAmelCase (...
373
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = { '''asapp/sew-d-tiny-100k''': '''https://huggingface.c...
373
1
def __A ( _lowercase ): '''simple docstring''' if length <= 0 or not isinstance(a_ , a_ ): raise ValueError('''Length must be a positive integer.''' ) return [n * (2 * n - 1) for n in range(a_ )] if __name__ == "__main__": print(hexagonal_numbers(length=5...
712
def __A ( _lowercase = 1_00_00_00 ): '''simple docstring''' _A = 1 _A = 1 _A = {1: 1} for inputa in range(2 , _lowercase ): _A = 0 _A = inputa while True: if number in counters: ...
62
0
import os from collections.abc import Iterator def __UpperCAmelCase ( UpperCAmelCase = "." )-> int: """simple docstring""" for dir_path, dir_names, filenames in os.walk(UpperCAmelCase ): lowercase = [d for d in dir_names if d !...
604
'''simple docstring''' import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast _SCREAMING_SNAKE_CASE : Optional[Any] = datasets.utils.logging.get_logger(__name...
400
0
'''simple docstring''' import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torc...
717
def A__( __lowerCAmelCase ): assert column_title.isupper() _snake_case : List[Any] = 0 _snake_case : List[str] = len(__lowerCAmelCase ) - 1 _snake_case : Dict = 0 while index >= 0: _snake_case : List[str] = (ord(column_ti...
652
0
"""simple docstring""" import logging import os from typing import List, Tuple import numpy as np import psutil import torch import torch.distributed as dist from transformers import RagRetriever _lowerCAmelCase = logging.getLogger(__name__) class SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CAS...
180
"""simple docstring""" 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_...
180
1
"""simple docstring""" import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobe...
215
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs i...
215
1
"""simple docstring""" from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ......
82
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device lowerCamelCase = False class lowercase_...
82
1
'''simple docstring''' from string import ascii_uppercase lowerCamelCase__ = {char: i for i, char in enumerate(ascii_uppercase)} lowerCamelCase__ = dict(enumerate(ascii_uppercase)) def _SCREAMING_SNAKE_CASE( snake_case_ : str , snake_case_ :...
411
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow ...
411
1
import os import posixpath import uuid from dataclasses import dataclass from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple, Union import numpy as np import pyarrow as pa import datasets from datasets.arrow_writer import ArrowWriter, ParquetWriter from datasets.config import MAX_SHARD_SIZE...
583
from PIL import Image def lowerCamelCase_ ( UpperCAmelCase_ : Image , UpperCAmelCase_ : int ): lowercase : str = (2_59 * (level + 2_55)) / (2_55 * (2_59 - level)) def contrast(UpperCAmelCase_ : int ) -> int: retur...
583
1
'''simple docstring''' import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) SCREAMING_SNAKE_CASE_ = pytest.mark.integration @pytest.mark.parametrize...
716
import fire from utils import calculate_rouge, save_json def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: int , lowerCAmelCase: Tuple , lowerCAmelCase: Any=None , **lowerCAmelCase: Any ) -> Dict: _UpperCAmelCase : Optional[Any] = [x.strip() for x in open(low...
467
0
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
19
'''simple docstring''' from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _A ( _lowerCAmelCase = "isbn/0140328726" ): """simple docstring""" __lowercase =olid.strip().strip('/' ) # Remove leading/trail...
474
0
from math import sqrt def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase :List[Any] = 0 for i in range(1 , int(sqrt(UpperCamelCase__ ) + 1 ) ): if n % i == 0 and i != sqrt(UpperCamelCase__ ): total += i + n ...
703
import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class lowerCamelCase_ ( UpperCAmelCase_ ): '''simple docstring''' a__ : Union[str, ...
452
0