code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_ : Un...
335
"""simple docstring""" import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets SCREAMING_SNAKE_CASE_ : Dict = '\\n@inproceedings{popovic-2015-chrf,\n title = "chr{F}: character n-gram {F}-score for automatic {MT} evaluation",\n author =...
335
1
from unittest import TestCase from datasets import Sequence, Value from datasets.arrow_dataset import Dataset class lowerCAmelCase__( __SCREAMING_SNAKE_CASE ): '''simple docstring''' def UpperCamelCase_ ( self ) -> int: return [ ...
364
from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("socket.socket" ) @patch("builtins.open" ) def lowerCamelCase__ (__lowerCamelCase, __lowerCamelCase ): # ===== initialization ===== _SCREAMING_SNAKE_CASE : List[Any] = Mock(...
325
0
"""simple docstring""" import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available, i...
44
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 __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): _Uppe...
142
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _snake_case = { 'configuration_mega': ['MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MegaConfig', 'MegaOnnxConfig'], } try: if not is_torch_ava...
357
'''simple docstring''' import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.data i...
199
0
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils ...
46
import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaaPriorPipeline, PriorTransformer,...
101
0
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_avail...
232
from __future__ import annotations import inspect import unittest from math import floor import numpy as np from transformers import CvtConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...te...
232
1
import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallback, TrainingArguments,...
281
import math def lowerCAmelCase_ ( _snake_case : float , _snake_case : float ) -> float: '''simple docstring''' return math.pow(_snake_case , 2 ) - a def lowerCAmelCase_ ( _snake_case : float ) -> float: '''simple docstri...
281
1
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_available()...
359
from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before tokeni...
252
0
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> str: if "cls_token" in name: lowerCamelCase__ : List[str] = nam...
50
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger SCREAMING_SNAKE_CASE__ = get_logger(__name__) class A__ ( enum.Enum ): lowerCAmelCase__ : Dict = "all_checks" lowerCAmelCase__ : ...
325
0
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__: int ): '''simple docstring''' UpperCAmelCase = test_file.split(os.path.s...
359
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __magic_name__ = {} try: if not is_sentencepiece_available(): raise Optio...
152
0
from datetime import datetime import requests def _lowercase ( UpperCamelCase_ ) -> Any: '''simple docstring''' SCREAMING_SNAKE_CASE__ = 'https://downloadgram.net/wp-json/wppress/video-downloader/video?url=' SCREAMING_SNAKE_CASE__ = requests.get(base_...
176
from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor,...
199
0
def lowerCamelCase_ ( _lowerCamelCase ): lowerCamelCase__ : Any = [1] lowerCamelCase__ : List[str] = 0, 0, 0 lowerCamelCase__ : Optional[Any] = ugly_nums[ia] * 2 lowerCamelCase__ : Any = ugly_nums[ia] * 3 lowe...
363
"""simple docstring""" from __future__ import annotations import queue class a_ : '''simple docstring''' def __init__(self, lowerCamelCase_ ): '''simple docstring''' lowerCamelCase__ : Union[str, Any] = data lowerCamelCase__ : ...
316
0
import argparse import os from pathlib import Path import fairseq import torch from packaging import version from torch import nn from transformers import ( BartConfig, BartForConditionalGeneration, BartForSequenceClassification, BartModel, BartTokenizer, ) from transformers.util...
232
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 BeitConfig, BeitForImageClassification, BeitForMaskedImageModeling, BeitImageProcessor from transformers.image_utils import PILImageR...
232
1
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline __UpperCAmelCase = logging.get_logger(__name__) # pylint: disable=invalid-name class SCREAMING_SNAKE_CASE ( a_...
139
__UpperCAmelCase = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ __UpperCAmelCase = [{""...
139
1
'''simple docstring''' import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modelin...
47
import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.stable_diffusion_safe ...
252
0
import heapq def lowercase__ ( __snake_case : dict ): '''simple docstring''' UpperCAmelCase_ : list[list] = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue wil...
145
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 __UpperCAmelCase = logging.get_logger(__name__) ...
145
1
"""simple docstring""" import numpy as np from scipy.spatial.distance import cdist from sklearn.metrics import fa_score import datasets _a = '\\n @inproceedings{kakwani2020indicnlpsuite,\n title={{IndicNLPSuite: Monolingual Corpora, Evaluation Benchmarks and Pre-trained Multilingual Languag...
61
'''simple docstring''' from __future__ import annotations def _a( UpperCamelCase__ : list[int] ): '''simple docstring''' if not nums: return 0 SCREAMING_SNAKE_CASE__ : Dict =nums[0] SCREAMING_SNAKE_CAS...
152
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = { 'configuration_blip': [ 'BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BlipConfig', ...
28
from math import factorial, pi def __UpperCamelCase ( lowercase__ : float , lowercase__ : int = 30 ) -> float: '''simple docstring''' if not isinstance(lowercase__ , (int, float) ): raise ValueError("""maclaurin_sin() requires either an int or...
28
1
"""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 import...
136
"""simple docstring""" import logging from dataclasses import dataclass, field from pathlib import Path from typing import Optional, Union from .generation.configuration_utils import GenerationConfig from .training_args import TrainingArguments from .utils import add_start_docstrings UpperCamelCase : str = lo...
316
0
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import tor...
227
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) A : str = { '''configuration_blip''': [ '''BLIP_PRETRAINED_CONFIG_ARCHIVE...
227
1
'''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_...
139
'''simple docstring''' def A_ ( snake_case = 100 ): SCREAMING_SNAKE_CASE:Optional[Any] = set() SCREAMING_SNAKE_CASE:int = 0 SCREAMING_SNAKE_CASE:Optional[Any] = n + 1 # maximum limit for a in range(2 , snake_case ): for b in ra...
139
1
import unittest import numpy as np from transformers import RoFormerConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp from transf...
63
from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelerate.test_utils import Regress...
63
1
'''simple docstring''' # flake8: noqa # Lint as: python3 __a = [ 'VerificationMode', 'Version', 'disable_progress_bar', 'enable_progress_bar', 'is_progress_bar_enabled', 'experimental', ] from .info_utils import VerificationMode from .logging import disable_progress_bar, enab...
145
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from ...
145
1
'''simple docstring''' from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER, SMALL_M...
16
'''simple docstring''' from __future__ import annotations from typing import Any class _A : def __init__( self , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase = 0 ) -> None: '''simple docstring''' __UpperCAmelCase , __UpperCAmelC...
16
1
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute...
28
'''simple docstring''' import os from itertools import chain from random import randrange, shuffle import pytest from .sola import PokerHand _lowerCamelCase : Optional[int] = ( "4S 3H 2C 7S 5H", "9D 8H 2C 6S 7H", "2D 6D 9D TH 7D", "TC 8C 2S JH 6C", "JH 8S TH ...
28
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { '''google/vivit-b-16x2-kinetics400''': ( '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json''' ...
370
"""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 transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import...
296
0
from __future__ import annotations _lowercase: Tuple = list[list[int]] # assigning initial values to the grid _lowercase: Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8, 6, 3, 0, 0, 5]...
227
import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTest...
227
1
'''simple docstring''' from collections.abc import Callable def lowerCamelCase (_SCREAMING_SNAKE_CASE : Callable[[float], float] , _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : float ): __a : float = a __a : float ...
359
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowercase : Tuple = { 'configuration_distilbert': [ '...
294
0
'''simple docstring''' import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase_ : int = logging.get_logger(__name__) lowerCAmelCase_ : str = ...
63
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def _lowerCamel...
63
1
"""simple docstring""" import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils...
366
"""simple docstring""" from __future__ import annotations from collections.abc import MutableSequence class UpperCamelCase_ : def __init__( self : Optional[int] , lowerCAmelCase_ : int , lowerCAmelCase_ : MutableSequence[float] ) -> None: if len(low...
253
0
"""simple docstring""" from __future__ import annotations import copy import tempfile import unittest from transformers import CONFIG_MAPPING, AutoConfig, BertConfig, GPTaConfig, TaConfig, TapasConfig, is_tf_available from transformers.testing_utils import ( DUMMY_UNKNOWN_IDENTIFIER...
16
"""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 __UpperCAmelCase ( __lower...
16
1
from __future__ import annotations import math from collections.abc import Callable def _UpperCAmelCase (UpperCamelCase_ : Callable[[int | float], int | float] , UpperCamelCase_ : int | float , UpperCamelCase_ : int | float , UpperCamelCase_ : int = 100 , ): '''simple docstr...
353
def _UpperCAmelCase (UpperCamelCase_ : str , UpperCamelCase_ : str ): '''simple docstring''' _lowerCAmelCase : str = len(UpperCamelCase_ ) + 1 _lowerCAmelCase : List[Any] = len(UpperCamelCase_ ) + 1 # dp is a 2d matrix where dp[i][j] denotes w...
159
0
'''simple docstring''' import bza import gzip import lzma import os import shutil import struct import tarfile import warnings import zipfile from abc import ABC, abstractmethod from pathlib import Path from typing import Dict, List, Optional, Type, Union from .. import config from .filelock import FileLock f...
35
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) def __lowercase ( _SCREAMING_SNAKE_CASE=None , ...
296
0
"""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/l...
302
"""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...
302
1
from typing import Any def A__ ( SCREAMING_SNAKE_CASE__) -> Dict: if not input_list: return [] __snake_case: Optional[Any] = [input_list.count(UpperCamelCase__) for value in input_list] __snake_case: Dict = max(UpperCamelCase__) # Gets the maximum count i...
111
"""simple docstring""" import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap im...
294
0
import os import numpy import onnx def __lowerCamelCase (UpperCAmelCase__ : Any , UpperCAmelCase__ : Optional[Any] ): SCREAMING_SNAKE_CASE = a.name SCREAMING_SNAKE_CASE = b.name SCREAMING_SNAKE_CASE = "" ...
357
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging ...
206
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
10
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase : List[str] = logging.get_logger(__name__) class _A ( __magic_name__ , __magic_nam...
253
0
'''simple docstring''' 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...
352
'''simple docstring''' from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DD...
275
0
def _a ( a :int , a :int ) -> int: return int((input_a, input_a).count(0 ) != 0 ) def _a ( ) -> None: assert nand_gate(0 , 0 ) == 1 assert nand_gate(0 , 1 ) == 1 assert nand_gate(1 , 0 ) == 1 assert nand_gate(1 , 1 ) == 0...
0
import os def _lowerCAmelCase ( )->Union[str, Any]: '''simple docstring''' snake_case_ = os.path.dirname(os.path.realpath(lowerCAmelCase_ ) ) snake_case_ = os.path.join(lowerCAmelCase_ , "triangle.txt" ) with open(lowerCAmelCas...
159
0
from __future__ import annotations class lowerCamelCase_ : """simple docstring""" def __init__( self : List[str] ,__lowerCamelCase : int ): '''simple docstring''' a = data a...
358
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : Optional[int] = logging.get_logger(__name__) UpperCamelCase__ : Dict = { """facebook/vit-mae-base""": """https://huggingface.co/facebook/vit-mae-base/resolve/main/config.js...
330
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = {} class SCREAMING_SNAKE_CASE ( lowerCamelCase__ ): __lowerCamelCase : Union[str, Any] ='llama' __lowerCamelCase ...
302
import string import numpy def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ): """simple docstring""" return b if a == 0 else greatest_common_divisor(b % a , _SCREAMING_SNAKE_CASE ) class SCREAMING_SNAKE_CASE : __lowerCame...
302
1
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoModelForQuestionAnswering...
363
'''simple docstring''' import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import TokenizerTes...
287
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case : Any = logging.get_logger(__name__) _snake_case : int = { '''transfo-xl-wt103''': '''https://huggingface.co/transfo-xl-wt103/resolve/main/config.json''', } class a (__UpperCAmelCase ...
123
'''simple docstring''' from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline lowerCamelCase :Union[str, Any] ...
206
0
import random from typing import Any def __lowerCAmelCase ( __SCREAMING_SNAKE_CASE : list ): '''simple docstring''' for _ in range(len(__SCREAMING_SNAKE_CASE ) ): __snake_case : List[Any] = random.randint(0 , len(__SCREAMING_SNAKE_CASE ) - 1 ) ...
355
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase_ = {"configuration_yolos": ["YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP", "YolosConfig", "YolosOnnxConfig"]} try: if not is_vision_available(): raise...
20
0
"""simple docstring""" import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase ...
256
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def _lowercase ( lowercase__ ): __lowerCAmelCase : str = [] __lowerCAmelCase : List[Any] = [] __lowe...
275
0
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { 'Intel/dpt-large': 'https://huggingface.co/Intel/dpt...
322
'''simple docstring''' from typing import Optional, Tuple, Union import tensorflow as tf from ...activations_tf import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward from ...modeling_tf_outputs import ( TFBaseModelOutputWi...
322
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) __SCREAMING_SNAKE_CASE :str = { '''configuration_roformer''...
22
import argparse import os from pathlib import Path from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import PegasusConfig, PegasusForConditionalGeneration, PegasusTokenizer from transformers.models.pegasus.configuration_pegasus import DEFAULTS, task_specific_para...
330
0
"""simple docstring""" def _a ( _snake_case = 50 ): """simple docstring""" UpperCAmelCase = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for...
234
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _UpperCamelCase = {"""configuration_glpn""": ["""GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GLPNConfig"""]} try: if not is_visio...
234
1
"""simple docstring""" import numpy as np from transformers import Pipeline def snake_case_ ( A_ : List[str] ): '''simple docstring''' _lowerCamelCase : Any = np.max(A_, axis=-1, keepdims=A_ ) _lowerCamelCase : List[str...
72
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
287
0
'''simple docstring''' import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipeli...
355
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : Tuple = {"configuration_vit_msn": ["VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMSNConfig"]} try: if not is_torch_avai...
264
0
'''simple docstring''' import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def lowercase__ ( *__lowercase : List[str] , __lowercase : Union[str, Any] = None , __lowercase : Any=True , __lowercase : str=2 ) -> ...
53
def _snake_case( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ) -> List[str]: if index == r: for j in range(SCREAMING_SNAKE_CASE__ ): prin...
20
0
import copy import os from collections import OrderedDict from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union if TYPE_CHECKING: from ...processing_utils import ProcessorMixin from ...utils import TensorType from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConf...
305
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
305
1
import cva import numpy as np class A_ : def __init__( self : List[str] , UpperCAmelCase : float , UpperCAmelCase : int ) -> Optional[Any]: if k in (0.04, 0.06): __lowerCAmelCase: Optional[Any] = k __lowerCAmelCase: L...
322
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class A_ ( snake_case__ ): _lowercase : ...
322
1
def snake_case_ ( snake_case ) -> Dict: lowercase__: str = [] lowercase__: str = [] lowercase__: List[str] = { '^': 3, '*': 2, '/': 2, '%': 2, '+': 1, ...
358
from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configur...
288
0
'''simple docstring''' from __future__ import annotations def __lowerCAmelCase (__lowerCAmelCase ): _UpperCAmelCase : int = [True] * limit _UpperCAmelCase : List[str] = False _UpperCAmelCase : Dict = False _UpperCAmelC...
234
'''simple docstring''' import json import logging import os import sys from pathlib import Path import finetune_rag from transformers.file_utils import is_apex_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, require_ray, require_torch_...
234
1
"""simple docstring""" import collections import json import os import re from typing import TYPE_CHECKING, List, Optional, Tuple import numpy as np from ...tokenization_utils_fast import PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import C...
359
"""simple docstring""" def lowercase ( a__ : Tuple , a__ : str ) -> Tuple: return (pointa[0] - pointa[0]) ** 2 + (pointa[1] - pointa[1]) ** 2 def lowercase ( a__ : Optional[int] , a__ : List[str]=0 ) -> Optional[Any]: return ...
54
0
"""simple docstring""" import sys def a__ ( SCREAMING_SNAKE_CASE : Optional[Any] ): '''simple docstring''' lowerCAmelCase : Union[str, Any] = len(SCREAMING_SNAKE_CASE ) lowerCAmelCase : Any = [[0 for x in range(SCREAMING_SNAKE_CASE...
108
"""simple docstring""" import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_pro...
264
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE ( metaclass=lowerCAmelCase ): '''simple docstring''' UpperCamelCase_ : Optional[int] = ['''torch'''] def __init__( self : Tuple , *UpperCAmelCase_ ...
352
def lowerCamelCase__ ( lowercase ): """simple docstring""" SCREAMING_SNAKE_CASE : Dict = n ** (1 / 3) return (val * val * val) == n if __name__ == "__main__": print(perfect_cube(27)) print(perfect_cube(4))
319
0
def UpperCamelCase ( ) -> Optional[int]: """simple docstring""" for n in range(1 , 100_0000 ): yield n * (n + 1) // 2 def UpperCamelCase ( __magic_name__ : List[str] ) -> Optional[Any]: """simple docstring""" lowercase__ ...
305
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGeneratio...
305
1
'''simple docstring''' def SCREAMING_SNAKE_CASE__( _UpperCamelCase : float , _UpperCamelCase : float ) -> float: '''simple docstring''' if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: rais...
31
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE__( _UpperCamelCase : Dict , _UpperCamelCase : str , _UpperCamelCase : Optional[int] , _UpperCamelCase : str ) -> Dict: # noqa: E741 '''simple docstri...
31
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A : Union[str, Any] = logging.get_logger(__name__) A : Optional[int] = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json", ...
57
"""simple docstring""" # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # ...
288
0
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency snake_case_ = { '''E''': 12.70, '''T''': 9.06, '''A''': 8.17, '''O''': 7.51, '''I''': 6.97, '''N''': 6.75, '''S''': 6.33, '''H''': 6.09, '''R''': 5.99, '''D''': 4.25, '''L''': 4.03...
360
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case_ = logging.get_logger(__name__) snake_case_ = { '''vocab_file''': '''vocab.json''', '''tokenizer_config_file''': '''tokenize...
216
0
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar snake_case_ : Union[str, Any] = TypeVar("T") class __snake_case ( Generic[T] ): UpperCAmelCase__ : deque[T] # Cache store of keys UpperCAmelCase__...
51
"""simple docstring""" import math import random def UpperCAmelCase__ (lowerCAmelCase_ , lowerCAmelCase_ = False ): '''simple docstring''' if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value a__ : Tuple =...
54
0
def A_ ( _lowerCAmelCase ) -> float: return 10 - x * x def A_ ( _lowerCAmelCase , _lowerCAmelCase ) -> float: # Bolzano theory in order to find if there is a root between a and b if equation(_lowerCAmelCase ) * equation(_lowerCAmelCase ) >= 0: ra...
140
from scipy.stats import spearmanr import datasets __lowerCamelCase : List[str] = """ The Spearman rank-order correlation coefficient is a measure of the relationship between two datasets. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Positive...
140
1
'''simple docstring''' import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput from...
104
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin ...
319
0
from __future__ import annotations from collections.abc import Callable from typing import Any, Generic, TypeVar lowercase__ = TypeVar("""T""") class __lowerCamelCase ( Generic[T] ): '''simple docstring''' def __init__( self : Any , a_ : ...
350
"""simple docstring""" import qiskit def __lowerCamelCase ( __UpperCamelCase , __UpperCamelCase ) -> qiskit.result.counts.Counts: """simple docstring""" lowerCAmelCase_ : int = qiskit.Aer.get_backend("aer_simulator" ) lowerCAmelCase_ : List[Any] ...
161
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase_ (metaclass=snake_case__ ): '''simple docstring''' __UpperCamelCase: int = ["speech"] def __init__( self : str , *A : Any , **A : Any ...
31
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable __SCREAMING_SNAKE_CASE : Optional[int] = {"""configuration_gpt_neox""": ["""GPT_NEOX_PRETRAINED_CONFIG_ARCH...
31
1
from dataclasses import dataclass from typing import Dict, Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, apply_forward_hook from .attention_processor import AttentionProcessor, AttnProce...
26
from math import ceil, sqrt def _a ( a :int = 1_000_000 ) -> int: a = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: a = max(ceil(sqrt(outer_width**2 - limit ) ) , 1 ) else: a = 1 ...
26
1
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> Optional[Any]: def merge(__UpperCAmelCase , __UpperCAmelCase ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0] else right).pop(0 ) yield from left ...
177
import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def __UpperCamelCase ( lowerCAmelCase__ : Any ): # vision encoder if "img_encoder.pos_embed" in name: __a : Any = name.replace('''img_encoder.pos...
216
0
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() a_ = logging.get_logger(__name__) ...
50
import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class _lowercase ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self : List[str] ) -> Optional[Any]: """simple docstring"...
50
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase = { """configuration_deberta""": ["""DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DebertaConfi...
140
from queue import PriorityQueue from typing import Any import numpy as np def UpperCamelCase ( __lowercase : dict ,__lowercase : str ,__lowercase : set ,__lowercase : set ,__lowercase : dict ,__lowercase : dict ,__lowercase : P...
140
1
import mpmath # for roots of unity import numpy as np class _UpperCAmelCase : """simple docstring""" def __init__( self : List[Any] , lowerCAmelCase_ : Dict=None , lowerCAmelCase_ : str=None ) -> List[Any]: # Input as list __lowerCAmelCase = ...
356
import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class _UpperCAmelCase ( unittest.TestCase ): """simple docstring""" def lowercase ( self : Any ) -> Optional[int]: ...
207
0
def lowerCamelCase_ ( lowerCamelCase__ ): if divisor % 5 == 0 or divisor % 2 == 0: return 0 lowerCamelCase_ = 1 lowerCamelCase_ = 1 while repunit: lowerCamelCase_ = (1_0 * repunit + 1) % divisor repunit_index += 1 return repunit_index def ...
19
'''simple docstring''' from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent a__ : Optional[Any] = {"UserAgent": UserAgent().random} def snake_case ( UpperCAmelCase )-> dict:...
161
0
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def _SCREAMING_SNAKE_CASE () -> Generator[int, None, None]: '''simple docstring''' lowercase_ = {} lowercase_ = 2 while True: lowercase_ = facto...
369
"""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 ...
313
0
def lowerCAmelCase_ ( snake_case_,snake_case_ ): if discount_rate < 0: raise ValueError("""Discount rate cannot be negative""" ) if not cash_flows: raise ValueError("""Cash flows list cannot be empty""" ) _A : Tuple = sum( cas...
26
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 if is_torch_available(): i...
26
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE_ : Optional[Any] = { 'configuration_squeezebert': [ 'SQUEEZEBERT_PRETRAINED_CONFIG_AR...
69
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE_ : Tuple = { 'configuration_nllb_moe': [ 'NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'NllbMoeConfig', ...
69
1
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_property ...
50
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenizerFast, XLMRo...
50
1
import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging _UpperCAmelCase = logging.get_logger(__...
192
import darl # noqa import gym import tqdm from diffusers.experimental import ValueGuidedRLPipeline _UpperCAmelCase = { """n_samples""": 64, """horizon""": 32, """num_inference_steps""": 20, """n_guide_steps""": 2, # can set to 0 for faster sampling, does not use value network ...
192
1
import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers import ( AutoConfig, A...
227
from typing import Dict import numpy as np import torch from . import residue_constants as rc from .tensor_utils import tensor_tree_map, tree_map def a ( lowerCamelCase_ ): '''simple docstring''' lowercase__ = [] lowercase__ = [] lowercase__ = [] for ...
207
0
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_availab...
369
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS...
117
0
'''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 import ANY...
198
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a__ : Tuple = {'''configuration_wavlm''': ['''WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''WavLMConfig''']} try: if not is_torch_available(): raise OptionalDependency...
313
0
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import...
354
import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params import ( TEXT_G...
94
0
"""simple docstring""" from __future__ import annotations import math def UpperCAmelCase ( UpperCAmelCase ) -> list[int]: if num <= 0: snake_case_ = f'{num}: Invalid input, please enter a positive integer.' raise ValueError(UpperCAmelCase ) ...
69
"""simple docstring""" from __future__ import annotations def UpperCAmelCase ( UpperCAmelCase ) -> None: create_state_space_tree(UpperCAmelCase , [] , 0 , [0 for i in range(len(UpperCAmelCase ) )] ) def UpperCAmelCase ( UpperCAmel...
69
1
'''simple docstring''' from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffu...
356
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _UpperCAmelCase ): if not nums: raise ValueError("List is empty" ) return sum(_UpperCAmelCase ) / len(_UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.testmod()
37
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { """vinvino02/glpn-kitti""": """https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json""", # See all GLPN model...
309
"""simple docstring""" def __lowerCamelCase ( a_ : int , a_ : str ) -> Optional[int]: __SCREAMING_SNAKE_CASE :Optional[int] = [1] for i in range(2 , a_ ): factorials.append(factorials[-1] * i ) assert 0 <= k < fac...
191
0
from math import loga def snake_case_(_UpperCamelCase ) -> int: """simple docstring""" if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(_UpperCamelCase , _UpperCamelCase ): raise TypeError('''Input value must be a \'int\' t...
278
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def snake_case_(_UpperCamelCase , _UpperCamelCase , _UpperCamelCase = 1 / sqrt(2 ) ) -> IIRFilter: """simple docstring""" _snake_case = tau * frequency / samplerate _snake_case ...
278
1
from ....utils import logging lowercase : Any = logging.get_logger(__name__) class A__ ( _lowerCamelCase ): """simple docstring""" def __init__( self , lowercase , lowercase=None , lowercase=2048) -> Optional[int]: '''sim...
99
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 snake_case__ : ...
117
0
import os import pytest from transformers.dynamic_module_utils import get_imports a_ : Optional[Any] = '\nimport os\n' a_ : List[str] = '\ndef foo():\n import os\n return False\n' a_ : Optional[int] = '\ndef foo():\n def bar():\n if True:\n ...
327
import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import six # noqa: F401 # Here to have a ...
327
1
"""simple docstring""" def UpperCAmelCase__ ( SCREAMING_SNAKE_CASE : str , SCREAMING_SNAKE_CASE : str = " " ): '''simple docstring''' lowerCAmelCase = [] lowerCAmelCase = 0 for index, char in enumerate(SCRE...
46
from __future__ import annotations import collections import pprint from pathlib import Path def __lowerCamelCase ( UpperCAmelCase_ : str ): """simple docstring""" return "".join(sorted(UpperCAmelCase_ ) ) def __lowerCamelCase ( UpperCAmelCase_ : str...
94
0
"""simple docstring""" from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, D...
354
"""simple docstring""" from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline lowercase_ ...
11
0
"""simple docstring""" import fire from utils import calculate_rouge, save_json def lowerCamelCase_ (UpperCamelCase__ : Any , UpperCamelCase__ : Optional[int] , UpperCamelCase__ : Optional[Any]=None , **UpperCamelCase__ : Optional[Any] ): _UpperCAmelCase ...
263
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowerCAmelCase = logging.get_logger(__name__) _lowerCAmelCase = { '''facebook/xlm-...
37
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available snake_case = {"""configuration_speech_encoder_decoder""": ["""SpeechEncoderDecoderConfig"""]} try: if not is_torch_available(): raise OptionalDependen...
356
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case = {"""configuration_focalnet""": ["""FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """FocalNetConfig"""]} try: if not is_torch_av...
319
0
from .imports import is_rich_available if is_rich_available(): from rich.traceback import install install(show_locals=False) else: raise ModuleNotFoundError('''To use the rich extension, install rich with `pip install rich`''')
278
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): raise OptionalDependencyNotAva...
278
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase : str = { """facebook/s2t-wav2vec2-large-en-de""": ( """https://huggingface.co/facebook/s2t-wav2vec2-...
359
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase : Optional[int] = { """configuration_nllb_moe""": [ """NLLB_MOE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NllbMoeConfig""", ] } try: ...
127
0
def SCREAMING_SNAKE_CASE__ ( __a , __a , __a ): snake_case_ : List[Any] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series return total def SCREAMING_SNAKE_CASE__ ( ): print(sum_of_seri...
327
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, normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAGENET_STAN...
327
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 __snake_case : List[Any] = logging.get_logger(__name__) __snak...
361
'''simple docstring''' from __future__ import annotations from math import pi from typing import Protocol import matplotlib.pyplot as plt import numpy as np class lowerCamelCase ( lowercase_ ): '''simple docstring''' def lowercase__ ( self : Any , lowerCAmelCase_ : ...
136
0
"""simple docstring""" from math import factorial def _lowerCamelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ): '''simple docstring''' if successes > trials: raise ValueError("successes must be lower or equal to trials" ) if trials < 0 or successes < 0: r...
57
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments @require_torch clas...
11
0
def lowerCAmelCase( SCREAMING_SNAKE_CASE_ )-> list: """simple docstring""" if len(SCREAMING_SNAKE_CASE_ ) <= 1: return lst UpperCamelCase_ = 1 while i < len(SCREAMING_SNAKE_CASE_ ): if lst[i - 1] <= lst[i]: i += 1 ...
370
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp ...
60
0
def _A ( _lowercase ) -> int: """simple docstring""" if not isinstance(__lowercase , __lowercase ): raise TypeError('only integers accepted as input' ) else: __UpperCamelCase = str(abs(__lowercase ) ) ...
310
'''simple docstring''' import os import pytest from transformers.dynamic_module_utils import get_imports UpperCamelCase = ''' import os ''' UpperCamelCase = ''' def foo(): import os return False ''' UpperCamelCase = ''' def foo(): def bar(): ...
319
0
"""simple docstring""" import argparse import hashlib # hashlib is only used inside the Test class import struct class UpperCamelCase__ : """simple docstring""" def __init__( self : Dict , SCREAMING_SNAKE_CASE_ : Tupl...
289
"""simple docstring""" import unittest from transformers import AlbertConfig, is_torch_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_mod...
289
1