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
import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py lowerCAmelCase = '''src/...
295
import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import TaTokenizer else: lowerCA...
295
1
"""simple docstring""" from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from ac...
368
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin UpperCAmelCase: Opt...
336
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase = logging.get_logger(__name__) lowerCAmelCase = { """vinvino02/glpn-kitti""": """https://huggingface.co/vinvino02/glpn-kitti/resolve/main/config.json""", ...
126
"""simple docstring""" from math import ceil from typing import List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import BatchFeature, SequenceFeatureExtractor from ...utils import TensorType, loggi...
126
1
"""simple docstring""" from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class lowerCamelCase : '''simple docstring''' SCREAMING_SNAKE_CASE = 42 # [batch_size x 3] SCREAMING_SNAKE_CASE = 42 # [batch_size x 3] S...
166
"""simple docstring""" import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from t...
166
1
"""simple docstring""" import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class lowerCamelCase__ : a__ : str = None def lowerCamelCase_ ( self ): """simple docstring""" ...
148
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install...
148
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase = logging.get_logger(__name__) __lowerCamelCase = { """MIT/ast-finetuned-audioset-10-10-0.4593""": ( """https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/resolve/main/confi...
352
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def UpperCamelCase ( __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int , __lowerCamelCase : int , __lowerCa...
10
0
class a : def __init__( self :Optional[Any] ,__lowercase :int ): snake_case__ : Optional[int] = size snake_case__ : str = [0] * size snake_case__ : List[Any] = [0] * size @staticmethod def __lowerCamelCase (...
230
import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from utils_ner im...
230
1
"""simple docstring""" import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common i...
181
"""simple docstring""" import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def _lowerCAmelCas...
181
1
from __future__ import annotations import string from itertools import cycle, product from pathlib import Path A : str = ( string.ascii_letters + string.digits + string.punctuation + string.whitespace ) A : list[int] = [ord(letter) for letter in string.ascii_lowercase] A ...
184
import inspect import unittest from transformers import ViTHybridConfig from transformers.testing_utils import require_accelerate, require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import Config...
336
0
'''simple docstring''' import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def a_ ( __snake_case : Union[str, An...
359
'''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_MAPP...
6
0
'''simple docstring''' from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time lowerCamelCase = Lock() def _A ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ,...
166
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _A ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase ): ...
166
1
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Effici...
359
import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( "The `inpainting.py` script is outdated. Please use directly `from diffusers import" " StableDiffusionInpaintPipeline` instead." )
84
0
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class A__ ( unittest.TestCase ): ...
162
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( UniSpeechConfig, UniSpeechForCTC, UniSpeechForPreTraining, WavaVecaFeatureExtractor, WavaVecaPhonemeCTCTokenizer, WavaVecaProcessor, logging, ) logging.s...
10
0
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LDMTextToImagePipeline, UNetaDConditionModel from diffusers.utils.testing_utils import...
350
'''simple docstring''' from dataclasses import dataclass, field from typing import Optional @dataclass class __lowerCamelCase : """simple docstring""" a = field( default="codeparrot/codeparrot" , metadata={"help": "Model name or path of model to be trained."} ) a ...
227
0
'''simple docstring''' import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict UpperCamelCase__ = namedtuple( '''_Te...
181
'''simple docstring''' def a__ ( lowerCAmelCase__ ) -> int: UpperCAmelCase__ : Tuple = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def a__ ( lowerCAmelCase__ = 1_00 ) -> int: Up...
181
1
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_gr...
365
"""simple docstring""" from unittest import TestCase from datasets import Dataset from minhash_deduplication import deduplicate_dataset, make_duplicate_clusters def _A ( ) -> Dict: '''simple docstring''' __lowercase = { "repo_name": ["test_repo1", "test_repo2", "test_...
144
0
"""simple docstring""" from __future__ import annotations from math import ceil, floor, sqrt def a_ ( lowerCamelCase = 2_0_0_0_0_0_0 ): UpperCAmelCase__ = [0] UpperCAmelCase__ = 42 for idx in range(1 , ceil(sqrt(target * 2 ) * 1.1 ...
98
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def __lowerCAmelCase ( a__ , a__ , a__ ) -> tuple[int | None, int | None, float]: if not arr: return None, None, 0 if l...
6
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPipe...
116
import os import re import sys import traceback import warnings from pathlib import Path from typing import Dict, Optional, Union from uuid import uuida from huggingface_hub import HfFolder, ModelCard, ModelCardData, hf_hub_download, whoami from huggingface_hub.file_download import REGEX_COMMIT_HAS...
116
1
import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase): SCREAMING_SNAKE_CASE = multiprocessing.Mana...
137
"""simple docstring""" def _snake_case ( lowercase__ : list[int] ) -> list[list[int]]: '''simple docstring''' lowerCAmelCase_ :Optional[Any] = [] if len(lowercase__ ) == 1: return [nums.copy()] for _ in range(len(lowercase__ ) ): ...
84
0
a : Dict = { '''A''': '''.-''', '''B''': '''-...''', '''C''': '''-.-.''', '''D''': '''-..''', '''E''': '''.''', '''F''': '''..-.''', '''G''': '''--.''', '''H''': '''....''', '''I''': '''..''', '''J''': '''.---''', '''K''': '''-.-''', '''L''': '''.-..''', '''M''': '''--''', '''N''': '''-.''', ...
355
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a : List[Any] = { """configuration_m2m_100""": ["""M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP""", """M2M100Config""", """M2M100On...
338
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import Autoencod...
173
# DISCLAIMER: This code is strongly influenced by https://github.com/pesser/pytorch_diffusion # and https://github.com/hojonathanho/diffusion import math from dataclasses import dataclass from typing import List, Optional, Tuple, Union import numpy as np import torch from diffusers.configuration_utils import Conf...
227
0
"""simple docstring""" import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import A...
369
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : Union[str, Any] = logging.get_logger(__name__) __A : Union[str, Any] = { 'facebook/s2t-wav2vec2-large-en-de': ( 'https://huggingface.co/facebook/s2t-wav2vec2-large-en-de...
57
0
"""simple docstring""" import contextlib import importlib import io import unittest import transformers # Try to import everything from transformers to ensure every object can be loaded. from transformers import * # noqa F406 from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, re...
150
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) A__ : Tuple = {'configuration_reformer': ['REFORMER_PRETRAINED_CONFIG_...
144
0
'''simple docstring''' import re import string import numpy as np import datasets SCREAMING_SNAKE_CASE__ = '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n' SCREAMING_SNA...
183
'''simple docstring''' from PIL import Image def lowercase__ ( __UpperCamelCase , __UpperCamelCase )-> Image: def brightness(__UpperCamelCase ) -> float: return 128 + level + (c - 128) if not -255.0 <= level <= 255.0: raise ...
183
1
# 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 appli...
116
def __UpperCamelCase ( _lowerCAmelCase = 100_0000 ) -> int: """simple docstring""" A : str = limit + 1 A : Tuple = [0] * limit for first_term in range(1 , _lowerCAmelCase ): for n in range(_lowerCAmelCase , _lowerCAmelCa...
116
1
"""simple docstring""" from collections import namedtuple import requests from lxml import html # type: ignore SCREAMING_SNAKE_CASE__:Dict = namedtuple("""covid_data""", """cases deaths recovered""") def _lowerCamelCase( a = "https://www.worldometers.info/coronavirus/" ): __a = ...
268
"""simple docstring""" from ...processing_utils import ProcessorMixin class snake_case__ ( snake_case_ ): _snake_case : List[str] = """WhisperFeatureExtractor""" _snake_case : Any = """WhisperTokenizer""" def __init__( self , lowerCamelCase , lowerC...
268
1
import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _SCREAMING_SNAKE_CASE ( unittest.TestCase ): ...
19
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class lowercase_ ( UpperCamelCase_ ): """simple docstring""" UpperCAmelCase_ : str = (DDPMScheduler,) def SCREAMING_SNAKE_CASE_ ( self , **__SCREA...
338
0
from __future__ import annotations from typing import Any class UpperCamelCase_ ( _lowerCamelCase ): pass class UpperCamelCase_ : def __init__( self , lowerCAmelCase_ ) -> None: _snake_case = data _snake_case ...
295
import warnings from ...utils import logging from .image_processing_flava import FlavaImageProcessor UpperCAmelCase_ = logging.get_logger(__name__) class UpperCamelCase_ ( _lowerCamelCase ): def __init__( self , *lowerCAmelCase_ , **lowerCAmelCase_ ) ->...
295
1
import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusion...
39
"""simple docstring""" import numpy # List of input, output pairs A : Any = ( ((5, 2, 3), 1_5), ((6, 5, 9), 2_5), ((1_1, 1_2, 1_3), 4_1), ((1, 1, 1), 8), ((1_1, 1_2, 1_3), 4_1), ) A : str = (((5_1_5, 2_2, 1_3), 5_5_5), ((6_1, 3_5, 4_9), 1_5_0)) A : Union[str, ...
57
0
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 .tokenization_albert import Albe...
50
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 TFModelTes...
50
1
"""simple docstring""" 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 fro...
183
"""simple docstring""" import string def lowerCamelCase__ ( _lowerCamelCase : str ) -> None: for key in range(len(string.ascii_uppercase ) ): lowerCamelCase_ = '' for symbol in message: if symbol in string.ascii_upp...
183
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase: Tuple = logging.get_logger(__name__) lowerCAmelCase: Tuple = { 'facebook/s2t-wav2vec2-large-en-de': ( 'https://huggingface.co/facebook/s2t-wav2vec2-large...
96
'''simple docstring''' from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax imp...
96
1
'''simple docstring''' import os import unittest from huggingface_hub.utils import are_progress_bars_disabled import transformers.models.bart.tokenization_bart from transformers import logging from transformers.testing_utils import CaptureLogger, mockenv, mockenv_context from transformers.utils.log...
3
'''simple docstring''' # 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 # # ...
267
0
"""simple docstring""" from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def a__ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ = 10**-10 ): UpperCAmelCase_ = ...
241
"""simple docstring""" from maths.prime_check import is_prime def a__ ( lowerCAmelCase__ ): if not isinstance(lowerCAmelCase__ , lowerCAmelCase__ ): UpperCAmelCase_ = f"""Input value of [number={number}] must be an integer""" ...
241
1
import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask from ...test_pi...
295
from __future__ import annotations def _lowerCamelCase( lowercase__ , lowercase__ ) -> bool: '''simple docstring''' __lowercase= get_failure_array(lowercase__ ) # 2) Step through text searching for pattern __lowercase, __lowercase= 0, 0 # index into text, pattern wh...
295
1
"""simple docstring""" import sys def a__ ( lowerCAmelCase ) -> Optional[int]: UpperCAmelCase__ : Dict = len(lowerCAmelCase ) UpperCAmelCase__ : Optional[int] = [[0 for x in range(lowerCAmelCase )] for x in range(lowerCAmelCase )] UpperCAmelCase__ : int...
368
"""simple docstring""" def a__ ( lowerCAmelCase ) -> bool: if not isinstance(lowerCAmelCase , lowerCAmelCase ): UpperCAmelCase__ : Tuple = F"""Input value of [number={number}] must be an integer""" raise TypeError(lowerCAmelCase ) if number < 0: ...
166
0
import argparse import shutil import time from json import JSONDecodeError from logging import getLogger from pathlib import Path from typing import Dict, List import torch from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from utils impo...
50
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_comm...
50
1
"""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, normalize, rescale, resize, to_channel_dimension_format from ...image...
366
"""simple docstring""" import re def UpperCamelCase_ ( lowerCAmelCase__ : str ) -> bool: """simple docstring""" lowerCAmelCase_ : str = re.compile( R'^(?:0|94|\+94|0{2}94)' R'7(0|1|2|4|5|6|7|8)' R'(-| |)' R'\d{7}$' ) ...
289
0
"""simple docstring""" import string import numpy def _snake_case ( lowercase__ , lowercase__ ): return b if a == 0 else greatest_common_divisor(b % a , lowercase__ ) class lowerCAmelCase__ : '''simple docstring''' ...
96
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = {"""ctrl""": """https://huggingface.co/ctrl/resolve/main/config.json"""} class lower...
96
1
"""simple docstring""" import logging import os import threading import time try: import warnings except ImportError: a : Any = None try: import msvcrt except ImportError: a : Any = None try: import fcntl except ImportError: ...
79
"""simple docstring""" from __future__ import annotations def _SCREAMING_SNAKE_CASE ( _lowercase : list[list[int]] ) ->int: '''simple docstring''' for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessi...
79
1
"""simple docstring""" import copy import os from typing import TYPE_CHECKING, List, Union if TYPE_CHECKING: pass from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { """kakaobrain/align-base"...
241
"""simple docstring""" # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
241
1
import re def SCREAMING_SNAKE_CASE__ ( snake_case_ ) -> str: """simple docstring""" if len(re.findall('''[ATCG]''', snake_case_ ) ) != len(snake_case_ ): raise ValueError('''Invalid Strand''' ) return dna.translate(dna.maketrans('''AT...
330
from __future__ import annotations import os from collections.abc import Mapping UpperCamelCase__ : Any = tuple[int, int] class lowerCamelCase_ : def __init__( self : Optional[Any] ,__lowerCamelCase : set[int] ,__lowerCamelCase ...
330
1
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class __snake_case ( lowerCamelCase_ , lowerCamelCase_ ): @register_to_config def __init__( self : List[Any] , *, _l...
219
'''simple docstring''' import os import unittest from transformers import MobileBertTokenizer, MobileBertTokenizerFast from transformers.models.bert.tokenization_bert import ( VOCAB_FILES_NAMES, BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from tran...
166
0
"""simple docstring""" import argparse import math import os import torch from neural_compressor.utils.pytorch import load from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, StableDiffusionPipeline, UNetaDConditionModel def UpperCAmelCase ( ): ...
367
"""simple docstring""" 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() ...
205
0
import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test_configuration_...
322
"""simple docstring""" 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() d...
289
0
import json import os import unittest from transformers import BatchEncoding, LEDTokenizer, LEDTokenizerFast from transformers.models.led.tokenization_led import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_propert...
354
from __future__ import annotations import unittest from transformers import EsmConfig, 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_tens...
125
0
'''simple docstring''' def __lowercase ( __lowercase ) -> int: '''simple docstring''' if not grid or not grid[0]: raise TypeError("The grid does not contain the appropriate information" ) for cell_n in range(1 , len(grid[0] ) ...
79
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor ...
79
1
'''simple docstring''' def __lowerCamelCase ( A__ = 10 , A__ = 1_000 , A__ = True ) -> int: """simple docstring""" assert ( isinstance(__snake_case , __snake_case ) and isinstance(__snake_case , __snake_case ) an...
364
'''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_accelera...
249
0
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = {"""vocab_file""": """vocab.json""", """me...
330
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_tensor, random_attention_mask if is_torch...
330
1
import torch from diffusers import StableDiffusionPipeline SCREAMING_SNAKE_CASE : Dict = "path-to-your-trained-model" SCREAMING_SNAKE_CASE : Tuple = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("cuda") SCREAMING_SNAKE_CASE : Union[str, Any] = ...
84
import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if import IFWatermarker from diffusers.utils.test...
84
1
'''simple docstring''' from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class snake_case__ ( UpperCamelCase)...
304
import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_xl.tokenization_transfo_xl import...
205
0
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, XLMRobertaTokenizer from diffusers import AltDiffusionPipeline, AutoencoderKL, DDIMScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipelines.alt_diffusion.modeli...
57
"""simple docstring""" # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for test...
57
1
'''simple docstring''' import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.t...
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available snake_case_ : Union[str, Any] = { "configuration_mask2former": [ "MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "M...
125
0
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :int ) -> Dict: if p < 2: raise ValueError("""p should not be less than 2!""" ) elif p == 2: return True __lowerCAmelCase : List[Any] = 4 __lowerCAmelCase : str = (1 << p) - 1 for _ in range(p - 2 ): _...
356
from __future__ import annotations def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :list[list[int]] ) -> bool: __lowerCAmelCase : Tuple = len(SCREAMING_SNAKE_CASE ) # We need to create solution object to save path. __lowerCAmelCase : str = [[0 for _ in ra...
232
0
def A_ ( _lowerCAmelCase = 50 ) -> int: UpperCamelCase : List[Any] = [[0] * 3 for _ in range(length + 1 )] for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): different_co...
52
"""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, ) a_ = { 'con...
249
0
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def A ( a_ = 3 ) -> qiskit.result.counts.Counts: if isinstance(a_ ,a_ ): raise TypeError('number of qubits must be a...
365
from math import pow, sqrt def A ( *a_ ) -> bool: __UpperCamelCase : Union[str, Any] =len(a_ ) > 0 and all(value > 0.0 for value in values ) return result def A ( a_ ,a_ ) -> float | ValueError: return ( ...
245
0
"""simple docstring""" import tempfile import numpy as np import torch from transformers import AutoTokenizer, TaEncoderModel from diffusers import DDPMScheduler, UNetaDConditionModel from diffusers.models.attention_processor import AttnAddedKVProcessor from diffusers.pipelines.deepfloyd_if imp...
84
"""simple docstring""" def _snake_case ( lowercase__ : int = 1_0 ) -> str: '''simple docstring''' if not isinstance(lowercase__ , lowercase__ ) or n < 0: raise ValueError("""Invalid input""" ) lowerCAmelCase_ :List[str] = 1_0**n ...
84
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowerCAmelCase : Optional[Any] = { '''configuration_canine''': ['''CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''CanineConfig'''], '''tokenization_can...
70
from math import pi, sqrt def __snake_case ( _lowerCAmelCase : float ) -> float: if num <= 0: raise ValueError("math domain error" ) if num > 1_71.5: raise OverflowError("math range error" ) elif num - int(_lowerCAmelCase ) not in (0, 0.5): raise NotImplementedError("num...
70
1
"""simple docstring""" import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime as ...
57
"""simple docstring""" import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from...
57
1
import string def lowerCAmelCase_ ( UpperCamelCase_ ) -> None: for key in range(len(string.ascii_uppercase ) ): UpperCamelCase_ = "" for symbol in message: if symbol in string.ascii_uppercase: ...
328
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { 'alibaba-damo/mgp-str-base': 'https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json', } class _UpperCamelCase ( lo...
328
1
def a__ ( A_ = 10**9 ): '''simple docstring''' __magic_name__ = 1 __magic_name__ = 2 __magic_name__ = 0 __magic_name__ = 0 __magic_name__ = 0 while perimeter <= max_perimeter: perimeter...
88
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.hug...
232
0
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class UpperCAmelCase ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' snake_case_ = "EncodecFeatureExtractor" snake_case_ = ("T5Tokenizer", "T...
124
import copy import re class UpperCAmelCase : '''simple docstring''' snake_case_ = "hp" snake_case_ = {} snake_case_ = None @classmethod def UpperCamelCase_ ( cls : Dict ,A : Dict ,A : Any ): __A = prefix __A ...
124
1
'''simple docstring''' import math import tensorflow as tf from packaging import version def __snake_case ( UpperCAmelCase_ : Optional[Any] ): lowerCamelCase_ = tf.convert_to_tensor(_A ) lowerCamelCase_ = 0.5 * (1.0 + tf.math.erf(x / tf.cast(tf.sqrt(2.0 ) ...
55
from typing import List, Union import numpy as np from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if ...
245
0
from .constants import ( MODEL_NAME, OPTIMIZER_NAME, RNG_STATE_NAME, SAFE_WEIGHTS_INDEX_NAME, SAFE_WEIGHTS_NAME, SCALER_NAME, SCHEDULER_NAME, TORCH_LAUNCH_PARAMS, WEIGHTS_INDEX_NAME, WEIGHTS_NAME, ) from .dataclasses import ( BnbQuantizationConfig, ComputeEnvironment...
102
import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def _a ( SCREAMING_SNAKE_CASE_ : Any ): # encoder.embeddings are double copied in o...
102
1
'''simple docstring''' import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xope...
70
'''simple docstring''' # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CL...
70
1
"""simple docstring""" from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is...
355
"""simple docstring""" import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme impor...
132
0
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 Image from ..image_utils import l...
328
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_common import ModelTesterMixin, ids_tensor, r...
328
1
from decimal import Decimal, getcontext from math import ceil, factorial def __a ( lowerCAmelCase_ : int ) -> str: '''simple docstring''' if not isinstance(lowerCAmelCase_ ,lowerCAmelCase_ ): raise TypeError("""Undefined for non-integers""" ) ...
277
import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state import GradientState, Par...
277
1
from collections import namedtuple lowerCamelCase : Dict = namedtuple('from_to', 'from_ to') lowerCamelCase : Optional[Any] = { 'cubicmeter': from_to(1, 1), 'litre': from_to(0.001, 1_0_0_0), 'kilolitre': from_to(1, 1), 'gallon': from_to(0.0_0454, 264.17...
124
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup lowerCamelCase : Any = [ 'kernels/rwkv/wkv_cuda.cu', 'kernels/rwkv/wkv_op.cpp', 'kernels/deformable_detr/ms_deform_attn.h', 'kernels/deformable_detr/cuda/ms_deform_im2col_c...
124
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) snake_case__ : List[str] = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCod...
358
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer snake_case__ : str = logging.get_logger...
314
0
"""simple docstring""" import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class _UpperCAmelCase ( __snake_case ): '''simple docstring''' lowerCamelCase__ =(PNDMScheduler,) lowerCamelCase__ =(('num_inference_steps', 50...
102
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils...
102
1
"""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 UpperCAmelCase_ = False class lowerCAm...
354
"""simple docstring""" UpperCAmelCase_ : Optional[int] = 8.3_1_4_4_5_9_8 def _A (__a , __a ) -> float: """simple docstring""" if temperature < 0: raise Exception('''Temperature cannot be less than 0 K''' ) if molar_mass <= 0: ...
318
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE__ = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDepe...
46
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_availa...
132
0
import qiskit def _lowercase ( UpperCamelCase_ , UpperCamelCase_ ) -> qiskit.result.counts.Counts: '''simple docstring''' SCREAMING_SNAKE_CASE__ = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q register SCREAMI...
362
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor __snake_case = logging.get_logger(__name__) class lowercase__ ( _UpperCAmelCase ): def __init__( self : Dict , *UpperCAmelCase_ : int , ...
169
0
import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extraction_common import SequenceFeat...
277
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): import torch ...
277
1
from __future__ import annotations from typing import TypedDict class A ( _UpperCAmelCase ): """simple docstring""" lowerCamelCase = 42 lowerCamelCase = 42 def _snake_case( SCREAMING_SNAKE_CASE__ : str ...
282
from __future__ import annotations from scipy.special import comb # type: ignore class A : """simple docstring""" def __init__( self : Any,lowercase_ : list[tuple[float, float]] )-> Optional[int]: '''simple docstring''' ...
282
1
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0...
220
from functools import reduce _SCREAMING_SNAKE_CASE : Any = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' ...
314
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Tuple = logging.get_logger(__name__) _lowerCamelCase : Tuple = { '''google/pix2struct-textcaps-base''': ( '''h...
366
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class lowercase ( a ): lowercase__ : Dict ...
206
0
from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge lowerCamelCase = [ '''Prosecutor: "No videos were used in the crash investigation" German papers say they saw a cell phone video of the'''...
188
'''simple docstring''' import numpy as np def lowercase_ ( _lowercase ) -> np.ndarray: '''simple docstring''' return 1 / (1 + np.exp(-vector )) def lowercase_ ( _lowercase ) -> np.ndarray: '''simple docstring''' return vector * sigmoid(_lowercase ) if __nam...
318
0
"""simple docstring""" from collections import namedtuple __UpperCamelCase : Optional[int] = namedtuple('''from_to''', '''from_ to''') __UpperCamelCase : List[Any] = { '''cubicmeter''': from_to(1, 1), '''litre''': from_to(0.0_0_1, 1_0_0_0), '''kilolitre''': from_to(1, ...
74
"""simple docstring""" from __future__ import annotations __UpperCamelCase : Any = 1.6021e-19 # units = C def __SCREAMING_SNAKE_CASE ( A_ , A_ , A_ , ): if (conductivity, electron_conc, mobility).count(0 ) != 1: raise ValueError('''You cannot supply more or...
74
1
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...
30
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def lowerCAmelCase ( ): """simple docstring""" UpperCAmelCase__ = [randint(-1000 , 1000 ) for i in range(10 )] UpperCAmelCase__ ...
169
0
def snake_case_ (__A : str ) -> bool: if not all(x.isalpha() for x in string ): raise ValueError("""String must only contain alphabetic characters.""" ) __lowerCAmelCase : Tuple = sorted(string.lower() ) return len(__A ) == len(set(__A...
139
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=a_ ) class SCREAMING_SNAKE_CASE ( a_ ): """simple docstring""" lowerCamelCase : s...
139
1
import unittest import numpy as np from transformers import DistilBertConfig, 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 tra...
282
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSpec from ...tokenization_u...
282
1
from dataclasses import dataclass from typing import Optional import torch from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .modeling_utils import ModelMixin @dataclass class _UpperCAmel...
207
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_ : Dict[str, torch.Tensor] ): __lowerCAmelCase = [] __lowerCAmelCase = [] __lowerCAm...
207
1
import unittest import numpy as np def a( A : Optional[int] , A : Optional[Any] , A : List[str] , A : str = None , ) -> Tuple: """simple docstring""" a = np.shape(lowerCamelCase__ ) a = np.shap...
227
'''simple docstring''' # 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 #...
206
0
'''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 ( TFBaseModelOutputWithNoAtten...
43
'''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 __a = logging.getLogger(__name__) class UpperCAmelCase_ ( _a ): """simple docstring""...
43
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase = { '''configuration_swinv2''': ['''SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Swinv2Config'''], } try: if not is_torch_available(): rais...
74
"""simple docstring""" # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union _lowercase = re.compile(r'''^(?P<major>\d+)''' r'''\.(?P<minor>\d+)''' r'''\.(?P<patch>\d+)$''') @total_ordering @datac...
74
1
"""simple docstring""" import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput _UpperCamelCase : Any = 'scheduler_config.json' ...
186
"""simple docstring""" import os import unittest from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer from transformers.testing_utils import get_tests_dir from ...test_tokenization_common import TokenizerTesterMixin _UpperCamelCase : int = get_test...
186
1
'''simple docstring''' from __future__ import annotations import matplotlib.pyplot as plt # type: ignore import numpy # initial triangle of Koch snowflake A_ = numpy.array([0, 0]) A_ = numpy.array([0.5, 0.866_0254]) A_ = numpy.array([1, 0]) A_ = [VECTOR_1, ...
139
'''simple docstring''' import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers...
139
1
import unittest from knapsack import greedy_knapsack as kp class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): def a (self : Tuple ): """simple docstring""" __snake_case = [10, 20, 30, 40, 50, 60] __snake_case ...
238
from __future__ import annotations snake_case_ = 'Muhammad Umer Farooq' snake_case_ = 'MIT' snake_case_ = '1.0.0' snake_case_ = 'Muhammad Umer Farooq' snake_case_ = 'contact@muhammadumerfarooq.me' snake_case_ = ...
238
1
import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTokenizer, HfArgumentPars...
207
from .configuration_bert_masked import MaskedBertConfig from .modeling_bert_masked import ( MaskedBertForMultipleChoice, MaskedBertForQuestionAnswering, MaskedBertForSequenceClassification, MaskedBertForTokenClassification, MaskedBertModel, ) from .modules import *
207
1
'''simple docstring''' from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class _lowerCamelCase : '''simple docstring''' A_ : List[s...
275
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowerCAmelCase :str = { '''configuration_vision_encoder_decoder''': ['''VisionEncoderDecoder...
275
1
def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): raise ValueError('''multiplicative_persistence() only accepts integral values''' ) if num < 0: raise ValueError('''multiplicative_persistence() do...
43
import math import qiskit def lowerCamelCase ( SCREAMING_SNAKE_CASE = 1 , SCREAMING_SNAKE_CASE = 1 , SCREAMING_SNAKE_CASE = 1 ): '''simple docstring''' if ( isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ) or isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CAS...
43
1
import logging import os from .state import PartialState class SCREAMING_SNAKE_CASE__ ( logging.LoggerAdapter ): """simple docstring""" @staticmethod def __lowerCamelCase ( __UpperCamelCase ) -> int: '''simple docstring''' __UpperCa...
171
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 .tokenization_rembert import...
171
1
from __future__ import annotations import math from collections.abc import Callable def lowerCamelCase_ ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase = 100 , ) -> float: """simple docstring""" snake_case_ : Any = x_start ...
279
'''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_full_determinism() class ...
185
0
def lowerCamelCase_ ( lowerCamelCase__ ): lowerCamelCase_ , lowerCamelCase_ = [], [] while len(lowerCamelCase__ ) > 1: lowerCamelCase_ , lowerCamelCase_ = min(lowerCamelCase__ ), max(lowerCamelCase__ ) start.append(lowerCamelCase__ ) ...
47
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) __A ={ '''configuration_trocr''': ['''TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TrOCRConfig'''], '''processing_t...
47
1
"""simple docstring""" from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText if is_...
238
"""simple docstring""" from functools import lru_cache def snake_case__ ( __lowerCamelCase : int ): """simple docstring""" lowerCamelCase__ : Optional[Any] =2 lowerCamelCase__ : Optional[int] =set() while i * i <= n: if n % i: i += 1 else: ...
238
1
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProcessing ...
370
def UpperCamelCase ( _A : int , _A : int )-> int: """simple docstring""" return int((input_a, input_a).count(0 ) == 0 ) def UpperCamelCase ( )-> None: """simple docstring""" assert and_gate(0 , 0 ) ...
198
0
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 DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logg...
275
import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizerBase def _lowercas...
275
1
import argparse import re from typing import Dict import torch from datasets import Audio, Dataset, load_dataset, load_metric from transformers import AutoFeatureExtractor, pipeline def UpperCamelCase ( _A, _A ): """simple docstring""" __magic_name__ : List[Any]...
138
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onn...
138
1