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 Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( Chann...
276
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTP...
249
0
"""simple docstring""" import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class _UpperCAmelCase( unittest.TestCase ): ...
358
"""simple docstring""" 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.""...
100
0
def lowerCAmelCase__ ( _SCREAMING_SNAKE_CASE : Any ): """simple docstring""" __a = [] __a = [] __a = { """^""": 3, """*""": 2, """/""": 2, """%""": 2, """+""": 1, """-""": 1, } # Priority...
302
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import torch from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available @dataclass class SCREAMING_SNAKE_CASE ( lowerCamelCase__ ): __lowerC...
302
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCamelCase = { '''configuration_data2vec_audio''': ['''DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Data2VecAudioCo...
363
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbed...
334
0
'''simple docstring''' import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration _lowerCAmelCase = 50_0000 _lowerCAmelCase , _lowerCAmelCase = os.path.split(__file__) _lowerCAmelCase = os.path....
37
# 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 req...
187
0
"""simple docstring""" import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_g...
362
"""simple docstring""" from collections import defaultdict from math import gcd def _a ( _SCREAMING_SNAKE_CASE = 1_500_000 ) -> int: snake_case_ = defaultdict(_SCREAMING_SNAKE_CASE ) snake_case_ = 2 while 2 * euclid_m * (euclid_m + 1) <= limit: ...
233
0
'''simple docstring''' import os import tempfile import unittest import numpy as np from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax, slow if is_flax_available(): import jax import jax.numpy as jnp from flax.jax_...
23
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __lowerCamelCase ( A__ ): '''simple docstring''' a_ : str = ["""image_processor""", """tokenizer"""] a_ : List[str] ...
241
0
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
329
from __future__ import annotations import os import tempfile import unittest from transformers import ConvBertConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ...
329
1
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import WAV_2_VEC_2_PRETRAINED_MODEL_ARCHIVE_LIST, WavaVecaConfig, WavaVecaFeatureExtractor from transformers.testing_utils import require_torch, slow from ...test_sequence_feature_extracti...
28
"""simple docstring""" from collections import defaultdict def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = first_str.lower().strip() __SCREAMING_SNAKE_CASE = second_str.lower().strip() # Remove whitespace __SCREAMING_SNAKE_CA...
100
0
'''simple docstring''' import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging snake_case__ = logging.get_logger(__name__) class UpperCamelCase_ : """simple docstr...
369
'''simple docstring''' def snake_case__ ( lowerCamelCase__ : list ) -> list: if len(lowerCamelCase__ ) <= 1: return [tuple(lowerCamelCase__ )] A_ : List[str] = [] def generate(lowerCamelCase__ : int , lowerCame...
4
0
'''simple docstring''' import warnings from ..trainer import Trainer from ..utils import logging __a: List[Any] = logging.get_logger(__name__) class UpperCAmelCase ( lowerCamelCase_ ): '''simple docstring''' def __init__( self , __lowerCAmelCase=None , **__l...
198
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _lowerCamelCase =logging.get_logger(__name__) _lowerCamelCase ...
334
0
'''simple docstring''' def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> Dict: if not isinstance(UpperCamelCase , UpperCamelCase ): lowerCamelCase__ : List[str] = f'''Input value of [number={number}] must be an integer''' raise ...
370
'''simple docstring''' import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main impo...
129
0
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassific...
64
from itertools import permutations def snake_case_ ( lowerCAmelCase_ : tuple ): if num[3] % 2 != 0: return False if (num[2] + num[3] + num[4]) % 3 != 0: return False if num[5] % 5 != 0: return False __lowercase : ...
233
0
'''simple docstring''' import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class a ( _lowerCamelCase ): snake_case_ = (DDPMParallelScheduler,) def A_ ( self : List[Any] , **lowercase_ : str ): snak...
370
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a : Optional[int] = logging.get_logger(__name__) a : Optional[Any] ...
72
0
def lowerCAmelCase__ ( a__: list ) -> bool: '''simple docstring''' if not isinstance(a__ , a__ ): raise ValueError('Input series is not valid, valid series - [2, 4, 6]' ) if len(a__ ) == 0: raise ValueError('Input list mus...
329
import argparse from tax import checkpoints from transformers import AutoConfig, FlaxAutoModelForSeqaSeqLM def lowerCAmelCase__ ( a__: Tuple , a__: Optional[Any] , a__: Any ) -> List[Any]: '''simple docstring''' _UpperCAmelCase = AutoConfig.from_pretrained(a__ ...
329
1
"""simple docstring""" import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class __lowe...
366
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_...
161
0
"""simple docstring""" def UpperCAmelCase__ (snake_case__ : list ): """simple docstring""" def merge(snake_case__ : list , snake_case__ : list ) -> list: def _merge(): while left and right: yield (left if left[0] <= right[0]...
64
'''simple docstring''' import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/f...
4
0
'''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_effec...
366
'''simple docstring''' import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProc...
299
0
import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docst...
39
from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeling_utils import PreT...
129
0
'''simple docstring''' from typing import Any, Callable, Dict, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, LMSDiscreteScheduler, PNDM...
183
'''simple docstring''' import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging SCREAMING_SNAKE_CASE__ = ...
183
1
from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def UpperCamelCase__( UpperCamelCase__ : str , UpperCamelCase__ : float | Decimal , UpperCamelCase__ : float = 10**-10 )->Optional[Any]: ...
193
"""simple docstring""" import math def snake_case_ ( A_ : int ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, ...
72
0
from __future__ import annotations import unittest import numpy as np from transformers import LayoutLMConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, rando...
185
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ :List[str] = { '''configuration_x_clip''': [ '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XCLIPConfig''', '''XCLIPTextConfig''', ...
185
1
import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator, Dist...
270
'''simple docstring''' import math import unittest def snake_case ( UpperCAmelCase )-> bool: """simple docstring""" assert isinstance(UpperCAmelCase , UpperCAmelCase ) and ( number >= 0 ), "'number' must been an int and posi...
161
0
"""simple docstring""" from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def __A ( a_ :str) -> None: __a : Union[str, Any] = analyze_text(a_) __a : List[str] = list('...
360
"""simple docstring""" def __A ( a_ :int = 1_00_00_00) -> int: __a : Tuple = [i - 1 for i in range(limit + 1)] for i in range(2 , limit + 1): if phi[i] == i - 1: for j in range(2 * i , limit + 1 , a_): ...
188
0
'''simple docstring''' import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class lowercase ( unittest.TestCase ): """simple docstring""" def lowerCAmelCase__ ( self ): '''simple ...
97
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) __UpperCAmelCase = { "configuration_layoutlmv2": ["LAYOUTLMV2_PRETRAINED_CONFIG_ARCHIVE_MAP", "LayoutLMv2Config"], ...
299
0
"""simple docstring""" from ....utils import logging __snake_case : Optional[Any] = logging.get_logger(__name__) class A__ ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' def __init__( self: str , _SCREAMING_SNAKE_CA...
58
"""simple docstring""" import random import unittest import numpy as np import transformers from transformers import is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax if is_flax_available(): import os import jax.nump...
58
1
"""simple docstring""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import datasets import evaluate import numpy as np from datasets import load_dataset import transformers from transformers import ( A...
183
"""simple docstring""" import json import os from collections import Counter import torch import torchvision import torchvision.transforms as transforms from PIL import Image from torch import nn from torch.utils.data import Dataset _SCREAMING_SNAKE_CASE : List[Any] ...
183
1
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Union[str, Any] ) -> Any: # vision encoder if "img_encoder.pos_embed" in...
362
"""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_model...
126
0
'''simple docstring''' from bisect import bisect from itertools import accumulate def UpperCAmelCase__ ( UpperCAmelCase_ : Any , UpperCAmelCase_ : Any , UpperCAmelCase_ : List[str] , UpperCAmelCase_ : str ) -> int: __lowerCamelCase : Dict...
185
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase_ : List[Any] ) -> str: __lowerCamelCase : Tuple = 0 __lowerCamelCase : Optional[int] = len(UpperCAmelCase_ ) for i in range(n - 1 ): for j in range(i + 1 , UpperCA...
185
1
"""simple docstring""" from __future__ import annotations from collections.abc import Generator def a__ ( ) -> Generator[int, None, None]: UpperCAmelCase__ : dict[int, int] = {} UpperCAmelCase__ : Tuple = 2 while True: UpperCAmelCase__ : str ...
166
"""simple docstring""" import random import unittest from torch.utils.data import BatchSampler, DataLoader, IterableDataset from accelerate import Accelerator from accelerate.data_loader import ( BatchSamplerShard, DataLoaderDispatcher, DataLoaderShard, IterableDatasetShard, SkipBatchSampler, ...
166
1
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _lowerCAmelCase ( lowerCamelCase__ ): __UpperCAmelCase : List[Any] = ['image_processor', 'tokenizer'] __UpperCAmelCase : Dict ...
203
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 = logging.get_logger(__name__) ...
188
0
"""simple docstring""" import math import random from typing import Any from .hill_climbing import SearchProblem def _snake_case ( _snake_case : List[Any] , _snake_case : List[Any] = True , _snake_case : int = math.inf , _snake_case : Tuple = -math.inf , _snake_...
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''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2...
58
'''simple docstring''' from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerat...
58
1
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase ( a_ ): """simple docstring""" A : Optional[int] = ['image_processor', 'tokenizer'] A : Opt...
360
'''simple docstring''' import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common impo...
345
0
def __SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE : int = 100 ) -> int: __lowercase = n * (n + 1) * (2 * n + 1) / 6 __lowercase = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F'''{solutio...
325
"""simple docstring""" import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import...
126
0
'''simple docstring''' import warnings 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 ...
369
'''simple docstring''' from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from...
251
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device lowerCamelCase = False class _UpperCamelCase ( unittest.Test...
166
'''simple docstring''' from scipy.stats import spearmanr import datasets lowerCamelCase = """ 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....
166
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, ) if is_sentencepiece_av...
354
"""simple docstring""" _lowerCAmelCase : dict[tuple[int, int, int], int] = {} def lowerCamelCase_( _lowerCamelCase , _lowerCamelCase , _lowerCamelCase ) -> int: '''simple docstring''' if late == 3 or absent == 2: return 0 # if we have no days lef...
340
0
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from ...
66
from functools import reduce _SCREAMING_SNAKE_CASE : Any = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' ...
314
0
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class UpperCamelCase_ ( _lowerCamelCase ): lowerCA...
295
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging UpperCAmelCase_ = logging.get_lo...
295
1
from collections import defaultdict def SCREAMING_SNAKE_CASE_ ( __A : int ) -> int: """simple docstring""" a_ : str = 1 a_ : Optional[Any] = True for v in tree[start]: if v not in visited: ...
32
from ..utils import DummyObject, requires_backends class _snake_case ( metaclass=__snake_case ): '''simple docstring''' A__ : Tuple = ["flax"] def __init__( self: str ,*lowerCamelCase_: int ,**lowerCamelCase_: List[str] ) -> str: requires...
345
0
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_c...
355
"""simple docstring""" import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device _lowercase : Tuple = False class __SCREAMING_SNAKE_CASE ...
272
0
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def a__ ( A_ = True, *A_, **A_ ): '''simple docstring''' if not is_tqdm_available(): raise ImportError("""Accelerate...
88
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCamelCase_ = {"configuration_speech_encoder_decoder": ["SpeechEncoderDecoderConfig"]} try: if not is_torch_a...
251
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @requ...
365
import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() A_ : str = [ 'word_embeddings_la...
292
0
"""simple docstring""" 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():...
173
import collections import importlib.util import os import re from pathlib import Path a_ = '''src/transformers''' # Matches is_xxx_available() a_ = re.compile(r'''is\_([a-z_]*)_available()''') # Catches a one-line _import_struct = {xxx} a_ = re.compile(r'''^_import_structure\s+=\s+\{(...
340
0
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def A_ ( snake_case_ : int ): '''simple docstring''' UpperCamelCase : int = int(number**0.5 ) return number == sq * sq def ...
27
"""simple docstring""" 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 A_ ( snake_case_ : Dataset ,snake_case_ : Dict[str, str] ): ...
27
1
from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass lowerCAmelCase = (3, 9, -1_1, 0, 7, 5, 1, -1) lowerCAmelCase = (4, 6, 2, 0, 8, 1_0, 3, -2) @dataclass class A : UpperCamelCase_ : int UpperCa...
295
import argparse import importlib from pathlib import Path # Test all the extensions added in the setup lowerCAmelCase = [ '''kernels/rwkv/wkv_cuda.cu''', '''kernels/rwkv/wkv_op.cpp''', '''kernels/deformable_detr/ms_deform_attn.h''', '''kernels/deformable_detr/cuda/ms_deform_im2col_cuda.c...
295
1
'''simple docstring''' import builtins import sys from ...utils.imports import _is_package_available from . import cursor, input from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor from .keymap import KEYMAP UpperCAmelCase_ : Dict = False try: ...
364
'''simple docstring''' import os def _UpperCamelCase ( SCREAMING_SNAKE_CASE__ : Any ): '''simple docstring''' UpperCAmelCase__ = len(grid[0] ) UpperCAmelCase__ = len(SCREAMING_SNAKE_CASE__ ) UpperCAmelCase__ = 0 UpperCAmelCase__ ...
61
0
'''simple docstring''' def _lowerCamelCase ( lowercase : int , lowercase : int ) -> int: while a != 0: _a , _a = b % a, a return b def _lowerCamelCase ( lowercase : int , lowercase : int ) -> int:...
63
'''simple docstring''' from string import ascii_lowercase, ascii_uppercase def snake_case__ ( _A: str ) -> str: '''simple docstring''' if not sentence: return "" lowerCAmelCase = dict(zip(_A , _A ) ) return lower_to_upper.get(sentence[0] , sentence[0] ) ...
272
0
"""simple docstring""" from math import pow, sqrt def __UpperCAmelCase ( *lowercase ): """simple docstring""" _UpperCAmelCase = len(lowercase ) > 0 and all(value > 0.0 for value in values ) return result def __UpperCAmelCase ( lowercase ,lowercase ...
30
"""simple docstring""" 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...
30
1
import unittest from transformers import MPNetConfig, 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, ids_tensor, random_attention_mask from ...test_pipeline_m...
207
"""simple docstring""" import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler...
292
0
from string import ascii_uppercase a_ = {char: i for i, char in enumerate(ascii_uppercase)} a_ = dict(enumerate(ascii_uppercase)) def __lowercase ( lowerCamelCase : str , lowerCamelCase : str ): UpperCamelCase_ : Tuple = len(lowerCamelCase ) UpperCamelCase_ : ...
50
from __future__ import annotations import numpy as np def __lowercase ( lowerCamelCase : list[float] ): return np.maximum(0 , lowerCamelCase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
50
1
'''simple docstring''' import gc import unittest from transformers import CTRLConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling...
27
'''simple docstring''' import importlib import os import sys # This is required to make the module import works (when the python process is running from the root of the repo) sys.path.append('.') def lowerCamelCase (_SCREAMING_SNAKE_CASE : List[Any] ): __a : Any = te...
27
1
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 import cached_property from ...te...
362
def lowercase( UpperCamelCase_ ) -> Tuple: '''simple docstring''' UpperCamelCase = 0 UpperCamelCase = len(UpperCamelCase_ ) for i in range(n - 1 ): for j in range(i + 1 , UpperCamelCase_ ): if arr[i] > arr[j]: num_inversions += 1 return num_inversi...
165
0
import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home snake_case_ = HUGGINGFACE_HUB_CACHE snake_case_ = 'config.json' snake_case_ = 'diffusion_pytorch_model.bin' snake_case_ = 'diffusion_flax_model.msgpack' snake_case_ = 'model.onnx' s...
24
"""simple docstring""" from collections import namedtuple _a = namedtuple('from_to', 'from_ to') _a = { 'cubicmeter': from_to(1, 1), 'litre': from_to(0.001, 1_000), 'kilolitre': from_to(1, 1), 'gallon': from_to(0.0_0454, 264.172), 'cubicyard': from_to(0.7_6455, 1....
61
0
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def SCREAMING_SNAKE_CASE ( __UpperCamelCase : Dict , __UpperCamelCase : Optional[int]=False ) -> Any: UpperCAmelCase_ = Omeg...
177
import baseaa def SCREAMING_SNAKE_CASE ( __UpperCamelCase : str ) -> bytes: return baseaa.baaencode(string.encode('''utf-8''' ) ) def SCREAMING_SNAKE_CASE ( __UpperCamelCase : bytes ) -> str: return baseaa.baadecode(__UpperCam...
177
1
import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch import t...
30
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING __a = logging.get_logger(__name__) class lowercase__( UpperCAmelCase ): """simple docstring""" a :Union[str, Any] =...
30
1
from ...configuration_utils import PretrainedConfig from ...utils import logging A : str = logging.get_logger(__name__) A : Union[str, Any] = { "MIT/ast-finetuned-audioset-10-10-0.4593": ( "https://huggingface.co/MIT/ast-finetuned-audioset-10-10-0.4593/res...
353
import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils i...
305
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase : Union[str, Any] = logging.get_logger(__name__) _UpperCAmelCase : str = { """google/pix2struct-textcaps-base""": ( """https...
50
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, re...
50
1
def snake_case__ ( SCREAMING_SNAKE_CASE_ : str , SCREAMING_SNAKE_CASE_ : str ): '''simple docstring''' lowercase__ : Optional[Any] = len(SCREAMING_SNAKE_CASE_ ) lowercase__ : List[str] = [] for i in range(len(SCREAMING_SNAKE_CASE_ ...
365
import math import sys def snake_case__ ( SCREAMING_SNAKE_CASE_ : int ): '''simple docstring''' if number != int(SCREAMING_SNAKE_CASE_ ): raise ValueError('the value of input must be a natural number' ) if number < 0: raise ValueError('the valu...
216
0
"""simple docstring""" def lowercase ( __snake_case : Optional[Any] , __snake_case : Tuple ): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''' ) lowercase_ : str = str(bin(snake_case__ ) )[2:] # remove the le...
33
"""simple docstring""" from ....configuration_utils import PretrainedConfig from ....utils import logging A_ : str = logging.get_logger(__name__) # TODO: upload to AWS A_ : Optional[int] = { "yjernite/retribert-base-uncased": ( "https://huggingface....
165
0
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as s...
294
'''simple docstring''' import os def lowerCamelCase (): with open(os.path.dirname(_SCREAMING_SNAKE_CASE ) + '/p022_names.txt' ) as file: __a : List[Any] = str(file.readlines()[0] ) __a : str = names.replace('"' , '' ).split('...
294
1
"""simple docstring""" from functools import lru_cache @lru_cache def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase ) -> int: if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__ == "__main__": import do...
177
"""simple docstring""" from __future__ import annotations from fractions import Fraction def SCREAMING_SNAKE_CASE__ ( __UpperCAmelCase , __UpperCAmelCase ) -> bool: return ( num != den and num % 1_0 == den // 1_0 and (num // 1_0) / (den % 1_0) == num / den ) def SCREAMING_SNAKE_...
177
1
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data impo...
214
'''simple docstring''' import math 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 @dataclass # Co...
214
1
"""simple docstring""" def lowercase ( A_ )-> int: '''simple docstring''' if not isinstance(A_ , A_ ): raise ValueError("Input must be an integer" ) if input_num <= 0: raise ValueError("Input must be positive" ) return su...
40
from __future__ import annotations def UpperCamelCase ( __magic_name__ : list[float] , __magic_name__ : list[float] ) -> float: """simple docstring""" lowercase__ = sorted(numsa + numsa ) lowercase__ , lowercase__ = divmod(l...
305
0
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 PreTrainedTokenizer from ...utils import logging a__ = logging.get_logger(__name__) a__ = '''▁''' ...
367
import argparse import os import torch from transformers.utils import WEIGHTS_NAME a__ = ['''small''', '''medium''', '''large'''] a__ = '''lm_head.decoder.weight''' a__ = '''lm_head.weight''' def __UpperCAmelCase ( __a : str ,__a : str ) -> ...
15
0
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def lowerCamelCase__ ( __snake_case ) -> Optional[int]: """simple docstring""" if "img_enc...
194
import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency lowercase__ ={ '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, 'C': 2.78, 'U': 2.76, 'M': 2.41, ...
216
0
import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPipeline, ...
351
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable lowercase__ :Union[str, Any] = {"configuration_dpt": ["DPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DPTConfig"]} try: if...
97
0
"""simple docstring""" import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowerCAmelCase__ ( UpperCamelCase__ ): '''simple docstring''' _a : List[Any] = FileLock(str(tmpdir / """foo.lock""" ) )...
294
"""simple docstring""" def lowerCAmelCase__ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , ): '''simple docstring''' _a : Optional[Any] = [redshift, radiation_density, matter_...
294
1
"""simple docstring""" from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging a_ = logging.get_logger(__name__) def __lowercase ( sna...
291
"""simple docstring""" import string # frequency taken from https://en.wikipedia.org/wiki/Letter_frequency a_ = { """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...
291
1
import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor snake_case_ = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ (__snake_case ): def __init__( self , *a , **a): warnings.warn( 'The class D...
214
import unittest from transformers import DonutProcessor snake_case_ = '''naver-clova-ix/donut-base''' class SCREAMING_SNAKE_CASE__ (unittest.TestCase ): def snake_case_ ( self): lowercase__ : Dict = DonutProcessor.from_pretrained(a) def ...
214
1
import string from math import logaa def lowerCamelCase_ ( UpperCamelCase__ : str, UpperCamelCase__ : str ): '''simple docstring''' UpperCamelCase__ = document.translate( str.maketrans('''''', '''''', string.punctuat...
370
from __future__ import annotations class __lowercase : '''simple docstring''' def __init__( self : List[Any] , _a : int ): UpperCamelCase__ = data UpperCamelCase__ = None UpperCamelCase__ = ...
35
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __lowercase = {'configuration_swin': ['SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SwinConfig', 'SwinOnnxConfig']} try: if not is_torch_available(): raise Optional...
43
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel SCREAMING_SNAKE_CASE :Union[str, Any] = False SCREAMING_SNAKE_CASE :Any = True SCREAMING_SNAKE_CASE :Tuple = False ...
15
0
from datetime import datetime import requests def A__ ( lowerCamelCase ) -> bytes: UpperCamelCase_: Any = """https://downloadgram.net/wp-json/wppress/video-downloader/video?url=""" UpperCamelCase_: int = requests.get(base_url + url ).json()[0]["""urls"""][0]["""src"""] ...
223
import json import multiprocessing import os import re from collections import defaultdict import torch from accelerate import Accelerator from accelerate.utils import set_seed from arguments import HumanEvalArguments from datasets import load_dataset, load_metric from torch.utils.data import IterableDataset from tor...
223
1
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDepe...
139
'''simple docstring''' import csv import tweepy # Twitter API credentials __snake_case = '''''' __snake_case = '''''' __snake_case = '''''' __snake_case = '''''' def a ( __a ) -> None: '''simple docstring''' UpperCame...
97
0
'''simple docstring''' from __future__ import annotations def UpperCamelCase__ ( lowerCAmelCase ): """simple docstring""" _lowerCAmelCase = str(lowerCAmelCase ) return n == n[::-1] def UpperCamelCase__ ( lowerCAmelCas...
220
'''simple docstring''' # Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def UpperCamelCase__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase ): """simple docstring""" _lowerCAmelCase = ...
220
1
"""simple docstring""" import numpy as np def a__ ( snake_case__ ) -> np.ndarray: return 1 / (1 + np.exp(-vector )) def a__ ( snake_case__ ) -> np.ndarray: return vector * sigmoid(snake_case__ ) if __name__ == "__main__": import doctest docte...
291
"""simple docstring""" import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import...
291
1
from collections.abc import Iterable from typing import Generic, TypeVar snake_case = TypeVar("""_T""") class SCREAMING_SNAKE_CASE ( Generic[_T] ): '''simple docstring''' def __init__( self : Tuple , UpperCAmelCase_ : Iterable[_T] | None = None ): SCREAMI...
353
import argparse from collections import OrderedDict from pathlib import Path import torch from transformers import ( VisualBertConfig, VisualBertForMultipleChoice, VisualBertForPreTraining, VisualBertForQuestionAnswering, VisualBertForVisualReasoning, ) from transformers.utils import loggin...
319
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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( BitConfi...
184
'''simple docstring''' import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaVecaConfig, WavaV...
35
0
"""simple docstring""" import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): __lowerCAmelCase : List[Any] =yaml.safe_load( """\ name: \"\" allow_empty: false allow...
32
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def UpperCAmelCase__ ( lowerCAmelCase__ :Union[str, Any] ) -> Dict: '''simple docstring''' if "img...
32
1
'''simple docstring''' import json import os import tempfile import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_...
223
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import to...
223
1
import collections import os import re from pathlib import Path __lowercase = "src/transformers" # Matches is_xxx_available() __lowercase = re.compile(r'''is\_([a-z_]*)_available()''') # Catches a one-line _import_struct = {xxx} __lowercase = re.compile(r'''^_import_structure\s+=\s...
360
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging __lowercase = logging....
105
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase : Dict = { 'configuration_roberta': ['ROBERTA_PR...
220
"""simple docstring""" def _SCREAMING_SNAKE_CASE ( __snake_case : int = 4_00_00_00 ): '''simple docstring''' lowercase = [] lowercase , lowercase = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__snake_case ) lowerca...
220
1
from argparse import ArgumentParser from accelerate.commands.config import get_config_parser from accelerate.commands.env import env_command_parser from accelerate.commands.launch import launch_command_parser from accelerate.commands.test import test_command_parser from accelerate.commands.tpu import tpu_command...
350
import requests from bsa import BeautifulSoup def snake_case ( snake_case__ :str = "AAPL") -> str: _A = F'''https://in.finance.yahoo.com/quote/{symbol}?s={symbol}''' _A = BeautifulSoup(requests.get(snake_case__).text , """html.parser"""...
81
0
"""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/lic...
105
'''simple docstring''' import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPP...
319
0
"""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...
298
"""simple docstring""" import inspect import unittest from datasets import load_dataset from packaging import version from transformers import BeitConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch...
298
1
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_...
32
import math import flax.linen as nn import jax.numpy as jnp def SCREAMING_SNAKE_CASE_ ( __A : jnp.ndarray , __A : int , __A : float = 1 , __A : float = 1 , __A : float = 1.0e4 , __A : bool = False , __A : float = 1.0 , ) -> jnp.ndarray: ...
32
1
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, smartaa_timest...
282
import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMi...
282
1
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> int: while b: __lowerCamelCase , __lowerCamelCase : Any = b, a % b return a def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> int: return a if b ==...
73
"""simple docstring""" from decimal import Decimal, getcontext from math import ceil, factorial def _SCREAMING_SNAKE_CASE ( _lowercase : int ) ->str: '''simple docstring''' if not isinstance(_lowercase , _lowercase ): rais...
105
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __A : Any = { '''configuration_bloom''': ['''BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BloomConfig''', '''BloomOnnxConfig'''], } try: if not is_to...
323
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL from ...utils import BaseOutput, OptionalDependencyNotAvailable, is_torch_available, is_transformers_available from .timesteps import ( fastaa_timesteps, smartaa_timesteps, smartaa_timesteps, sma...
323
1
import random from typing import Any def lowercase_ ( _lowerCamelCase : list): for _ in range(len(_lowerCamelCase)): lowercase__ : Dict = random.randint(0 , len(_lowerCamelCase) - 1) lowercase__ : Union[str, Any] = random.randint(0 , len(_lowerC...
87
"""simple docstring""" from math import factorial def _A ( lowercase = 1_00 ): """simple docstring""" return sum(int(lowercase ) for x in str(factorial(lowercase ) ) ) if __name__ == "__main__": print(solution(int(input("""Enter the Number: """)....
81
0
'''simple docstring''' from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def __A ( ): _UpperCAmelCase : List[Any] = [randint(-1000 , 1000 ) for i in range(10 )] _UpperCAmelCase : Dict =...
353
'''simple docstring''' from __future__ import annotations def __A ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , ): if (stress, tangential_force, area).count(0 ) != 1: raise ValueError("""You cannot supply more or less than 2 values""" ) elif stress < 0: ...
170
0
'''simple docstring''' import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_inpu...
298
'''simple docstring''' def __lowerCAmelCase ( snake_case__ ): return [ txt[:a] + txt[a].upper() + txt[a + 1 :] for a in range(len(snake_case__ ) ) if txt[a].isalpha() ] if __name__ == "__main__": __import__('''doctest''').testmod(...
298
1
'''simple docstring''' from __future__ import annotations from decimal import Decimal from numpy import array def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase =Decimal # Check if the provided matrix has 2 rows and 2 columns # since this impl...
353
'''simple docstring''' from math import factorial def _A ( _lowerCAmelCase = 20 ): """simple docstring""" __lowercase =2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... __lowercase =n // 2 return int(facto...
48
0
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): '''simple docstring''' def A ( self : Tuple ): '''simple docstring''' _snake_case ...
282
import os from typing import Any, Callable, Dict, List, Optional, Tuple, Union import torch from torch import nn from ...models.controlnet import ControlNetModel, ControlNetOutput from ...models.modeling_utils import ModelMixin from ...utils import logging _lowerCamelCase : List[str] = logging.get...
282
1
def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :Optional[int] , SCREAMING_SNAKE_CASE :Tuple ) -> int: print("""\nThe shortest path matrix using Floyd Warshall algorithm\n""" ) for i in range(SCREAMING_SNAKE_CASE ): for j in range(SCREAMING_SNAKE_CASE ): if dist[i][j] != float(...
232
from datetime import datetime import requests def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE :str ) -> bytes: __lowerCAmelCase : List[Any] = """https://downloadgram.net/wp-json/wppress/video-downloader/video?url=""" __lowerCAmelCase : Dict = requests.get(b...
232
1
'''simple docstring''' def __A ( lowerCamelCase_ , lowerCamelCase_ ): """simple docstring""" return number | (1 << position) def __A ( lowerCamelCase_ , lowerCamelCase_ ): """simple docstring""" return number & ~(1 << position) ...
323
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase = { """microsoft/git-base""": """https://huggingface.co/microsoft/gi...
323
1
"""simple docstring""" from __future__ import annotations _A = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , ) ...
212
"""simple docstring""" import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def lowercase_ ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ) -> List[Any]: ...
212
1
def __UpperCamelCase ( _lowerCAmelCase ) -> bool: """simple docstring""" return credit_card_number.startswith(("""34""", """35""", """37""", """4""", """5""", """6""") ) def __UpperCamelCase ( _lowerCAmelCase ) -> bool: """simple docstring""" A : str ...
116
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Optional[int] =logging.get_logger(__name__) _lowercase : Tuple ={ "microsoft/swinv2-tiny-patch4-window8-256": ( "https://huggingface.co/microsoft/swinv2-tiny-patch4-window8-25...
170
0
"""simple docstring""" def __snake_case ( SCREAMING_SNAKE_CASE__ : str ) -> list[int]: '''simple docstring''' _UpperCAmelCase : Optional[int] = [0 for i in range(len(SCREAMING_SNAKE_CASE__ ) )] # initialize interval's left pointer an...
202
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _lowerCAmelCase : Union[str, Any] = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDepend...
202
1