code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
from collections.abc import Callable import numpy as np def lowerCamelCase ( a_ , a_ , a_ , a_ , a_ ) -> np.array: lowerCAmelCase_ = int(np.ceil((x_end - xa) / step_size ) ) lowerCAmelCase_ = np.zeros((n + 1,) ) ...
318
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 d...
318
1
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDependencyNotA...
640
'''simple docstring''' import math from enum import Enum from typing import Optional, Union from torch.optim import Optimizer from torch.optim.lr_scheduler import LambdaLR from .utils import logging UpperCamelCase__ = logging.get_logger(__name__) class _UpperCAmelCase ( snake_case ): _...
640
1
import logging import os import sys from dataclasses import dataclass, field from typing import Optional from seqaseq_trainer import SeqaSeqTrainer from seqaseq_training_args import SeqaSeqTrainingArguments import transformers from transformers import ( AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer...
622
# 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...
622
1
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional import In...
188
import logging import os import sys from dataclasses import dataclass, field from typing import Optional import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor from torchvision.transforms.functional import In...
188
1
from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward ...
194
from statistics import mean import numpy as np def __a ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase ): a__ = 0 # Number of processes finished a__ = 0 # Displays the finished process. # If it is 0, the performance is...
194
1
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImagePr...
320
'''simple docstring''' 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 UpperCamelCase_ = loggin...
320
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_ = { 'configuration_blenderbot': [ 'BLENDERBOT_PRETRAINED_CONFI...
300
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowercase__ ( _UpperCAme...
472
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize,...
564
'''simple docstring''' def __A ( _SCREAMING_SNAKE_CASE : Optional[Any] , _SCREAMING_SNAKE_CASE : Optional[int] ): """simple docstring""" __SCREAMING_SNAKE_CASE : Optional[Any] = 0 __SCREAMING_SNAKE_CASE ...
564
1
class UpperCamelCase_ : '''simple docstring''' def __init__( self) -> None: UpperCamelCase__ : dict[str, TrieNode] = {} # Mapping from char to TrieNode UpperCamelCase__ : Any = False def lowerCAmelCase__ ( self , ...
410
# Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def _lowercase ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> int: UpperCamelCase__ : Dict = { 'en': 'Machine learning i...
410
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : List[str] =logging.get_logger(__name__) _lowercase : int ={ '''studio-ousia/luke-base''': '''https://huggingface.co/studio-ousia/luke-base/resolve/main/config.json''', '''studio-o...
704
import operator as op _lowercase : Optional[int] ="""scaler.pt""" _lowercase : List[Any] ="""pytorch_model""" _lowercase : Tuple ="""random_states""" _lowercase : Tuple ="""optimizer""" _lowercase : Dict ="""scheduler""" _lowercase ...
412
0
def SCREAMING_SNAKE_CASE_ ( UpperCAmelCase_ : int ) -> bool: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
443
from typing import Callable, Dict, Optional, Tuple import torch from torch import nn from torch.distributions import ( AffineTransform, Distribution, Independent, NegativeBinomial, Normal, StudentT, TransformedDistribution, ) class SCREAMING_SNAKE_CASE ( a_ ...
651
0
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class _snake_case ( ctypes.Structure ): """simple docstring""" a = [("size", ctypes.c_int), ("visible...
719
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel lowerCAmelCase_ = { '''text_branch''': '''text_model''', '''audio_branch''': '''audio_model.audio_encoder''', '''attn''': '''attention...
635
0
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, requir...
197
import argparse import json import os from pathlib import Path import requests import torch from transformers import JukeboxConfig, JukeboxModel from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) SCRE...
197
1
import math from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ = logging.get_logger(__name__) UpperCamelCase__ = { '''facebook/data2vec-base-960h''': '''https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main...
143
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class __lowercase : _lowerCAmelCase = None _lowerCAmelCase = False _lowerCAmelCase = False _lowerCAmelCase = False _...
143
1
def __magic_name__ ( __lowerCAmelCase : str , __lowerCAmelCase : list[str] ) -> str: __lowerCamelCase = '''''' for word_or_phrase in separated: if not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise Exception('''join() a...
298
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": SCREAMING_SNAKE_CASE__ : Dict = argparse.ArgumentParser() parser.add_argument("--dump_path", default=N...
298
1
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary # Register SEW's fairseq modules from sew_asapp import tasks # noqa: F401 from transformers import ( SEWConfig, SEWForCTC, SEWModel, WavaVecaCTCTokenizer, WavaVeca...
637
"""simple docstring""" from __future__ import annotations class snake_case_: def __init__( self : int , UpperCamelCase_ : str , UpperCamelCase_ : str ): lowerCAmelCase, lowerCAmelCase : List[str] = text, pattern lowerCAmelCas...
637
1
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = {name: getattr(transformers, name + """Fast""") for name in SLOW_T...
225
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase : List[str] = logging.get_logger(__name__) lowerCAmelCase : List[Any] = { 'facebook/convnextv2-tiny-1k-...
511
0
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator class A : '''simple docstring''' def __init__(self , _UpperCAmelCase ) -> None: __UpperCamelCase : List[Any] = value ...
399
'''simple docstring''' import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor _lowerCAmelCase = logging.get_logger(__name__) class A ( SCREAMING_SNAKE_CASE__ ): '''simple docstring''' ...
399
1
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration lowerCAmelCase_ = [ # tf -> hf ('''/''', '''.'''), ('''layer_''', '''layers.'''), ('''kernel''',...
60
"""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....
93
0
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_lxmert import LxmertTokenizer _SCREAMING_SNAKE_CASE = {'''vocab_file''': '''vocab.txt'''...
56
'''simple docstring''' import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient _SCREAMING_SNAKE_CASE = WebClient(token=os.environ['''CI_SLACK_BOT_TOKEN''']) ...
56
1
import math def A ( lowercase__ : Tuple , lowercase__ : Union[str, Any] ) -> Optional[Any]: if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(lowercase__ ) else: if x == 0: # 0 raised to any number is 0 return 0 elif y == 0:...
45
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { '''bigcode/gpt_bigcode-santacoder''': '''https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json''', } c...
7
0
'''simple docstring''' from typing import Tuple, Union from ...modeling_outputs import BackboneOutput from ...modeling_utils import PreTrainedModel from ...utils import is_timm_available, is_torch_available, requires_backends from ...utils.backbone_utils import BackboneMixin from .configuration_timm_b...
712
'''simple docstring''' import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinvaConfig, SwinvaForImageClassification def _snake_c...
344
0
from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_im...
311
from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax.numpy as jnp from jax import random from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .scheduling_utils_flax import FlaxSchedulerMixin @flax.struct.dataclas...
302
0
from __future__ import annotations from math import gcd def lowerCamelCase__ ( snake_case_ : Optional[Any] , snake_case_ : Any = 2 , snake_case_ : Optional[Any] = 1 , snake_case_ : str = 3 , ) -> int | None: if num < 2: ...
712
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case_ = { 'configuration_electra': ['ELECTRA_PRETRAINED_CONFIG_AR...
388
0
def a_ ( UpperCamelCase_ : str , UpperCamelCase_ : str ) -> list: """simple docstring""" lowerCamelCase = len(UpperCamelCase_ ) lowerCamelCase = [] for i in range(len(UpperCamelCase_ ) - pat_len + 1 ): lowerCamelCase = True for j in r...
246
from __future__ import annotations from typing import Any class lowerCAmelCase : '''simple docstring''' def __init__( self : str , __snake_case : int = 6 ) -> None: '''simple docstring''' lowerCamelCase ...
246
1
'''simple docstring''' def a_ ( lowerCamelCase : Tuple , lowerCamelCase : Tuple ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) lowerCAmelCase = (boundary[1] - boundary[0]) / steps lowerCAmelCase = boundary[0] lowerCAmelCase...
716
'''simple docstring''' def a_ ( lowerCamelCase : Tuple , lowerCamelCase : Tuple ): # "extended trapezoidal rule" # int(f) = dx/2 * (f1 + 2f2 + ... + fn) lowerCAmelCase = (boundary[1] - boundary[0]) / steps lowerCAmelCase = boundary[0] lowerCAmelCase...
513
0
"""simple docstring""" # coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
650
"""simple docstring""" # Copyright 2022 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 #...
650
1
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slow from...
721
import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : List[str] = logging.get_logger(__name__) _lowerCamelCase : List[str] = { '''facebook/encodec_24khz''': '''https://huggi...
516
0
"""simple docstring""" import os import tempfile import unittest from transformers import FlaubertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_co...
545
"""simple docstring""" import argparse import copy def A ( __snake_case: Union[str, Any] ) -> Tuple: """simple docstring""" __magic_name__ = {} with open(__snake_case ) as f: for line in f: i...
545
1
"""simple docstring""" import unittest from transformers import BigBirdTokenizer, BigBirdTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import ...
706
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ : Optional[int] = { """configuration_timesformer""": ["""TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Timesforme...
317
0
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_C...
574
"""simple docstring""" import argparse import collections import json import os import re import string import sys import numpy as np lowerCAmelCase_ = re.compile(R'''\b(a|an|the)\b''', re.UNICODE) lowerCAmelCase_ = None def lowerCamelCase_()-> List[str]: _SCREAMING_SNAK...
338
0
import argparse import torch from transformers import MobileBertConfig, MobileBertForPreTraining, load_tf_weights_in_mobilebert from transformers.utils import logging logging.set_verbosity_info() def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ , lowerCam...
337
import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, TableTransformerForObjectDete...
337
1
from PIL import Image def _a ( SCREAMING_SNAKE_CASE__ : Image , SCREAMING_SNAKE_CASE__ : int ) -> Image: '''simple docstring''' SCREAMING_SNAKE_CASE__ : List[str] = (2_59 * (level + 2_55)) / (2_55 * (2_59 - level)) ...
663
import torch from diffusers import DPMSolverSDEScheduler from diffusers.utils import torch_device from diffusers.utils.testing_utils import require_torchsde from .test_schedulers import SchedulerCommonTest @require_torchsde class lowerCamelCase (__lowerCamelCase ): ...
663
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available __A = { 'configuration_ernie': ['ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ErnieConfig', 'ErnieOnnxConfig'], } try: if not is_torch_available(): ...
708
import itertools import string from collections.abc import Generator, Iterable def __A ( _lowercase , _lowercase ): '''simple docstring''' _A = iter(_lowercase ) while True: _A = tuple(itertools.islice(_lowercase , _lowercase ) ) ...
62
0
'''simple docstring''' import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class _a (_lowerCamelCase): """simple docstring""" SCREAMING_SNAKE_CASE = (DDPMParallelScheduler,) def UpperCamelCase ( self ...
591
'''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(): from .to...
591
1
import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets __snake_case : Optional[Any] = datasets.logging.get_logger(__name__) __snake_case : Optional[Any] = """\ @inproceedings{bleurt, title={BLEURT: Learning Robust ...
365
import numpy as np from PIL import Image def _UpperCamelCase ( UpperCamelCase_ : np.ndarray , UpperCamelCase_ : int , UpperCamelCase_ : int ) -> np.ndarray: """simple docstring""" lowerCAmelCase__ = np.array(UpperCamel...
365
1
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _UpperCamelCase = logging.get_logger(__name__) _...
492
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 import FlaxTimestepEmbedding, Flax...
492
1
'''simple docstring''' import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transfo...
338
'''simple docstring''' import argparse import json 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...
338
1
import io import math from typing import Dict, Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import convert_to_rgb, normalize, to_channel_dimension_format, to_pil_image from ...image_...
600
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __UpperCAmelCase = {'configuration_encoder_decoder': ['EncoderDecoderConfig']} try: if not is_torch_available(): rais...
600
1
'''simple docstring''' def snake_case( __magic_name__ = 50 ) -> int: '''simple docstring''' lowercase : str = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ...
709
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common i...
596
0
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
157
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 ( ChannelDimension, ImageInput, PILImageResamp...
157
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __UpperCAmelCase ={ """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], """co...
261
"""simple docstring""" import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("""Googling.....""") __UpperCAmelCase ="""https://www.google.com/search?q=""" + """ """.join(sys.argv[1:]) __UpperCAmelCase ...
261
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase = {"""configuration_wavlm""": ["""WAVLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """WavLMConfig"""]} try: if not is_torch_available(): raise...
88
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_utils import replicate from flax.training.common_utils import shard ...
456
0
def lowerCAmelCase_ ( snake_case_ = 1,snake_case_ = 1000 ): _A : Optional[int] = 1 _A : List[Any] = 0 for divide_by_number in range(snake_case_,digit + 1 ): _A : list[int] = [] _A : Any = numerator for _ ...
54
def lowerCAmelCase_ ( snake_case_ = 1000000 ): _A : Any = limit + 1 _A : Tuple = [0] * limit for first_term in range(1,snake_case_ ): for n in range(snake_case_,snake_case_,snake_case_ ): _A : Optional[int] = first_term +...
54
1
import math import time from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met class lowerCamelCase_ ( lower...
147
from __future__ import annotations __lowerCAmelCase = [] def _lowercase ( a__ : list[list[int]] , a__ : int , a__ : int ) -> bool: """simple docstring""" for i in range(len(a__ ) ): if board[row][i] == 1: return False for i ...
147
1
'''simple docstring''' import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class UpperCAmelCase_ ( tf.keras.optimizers.schedu...
709
'''simple docstring''' from collections import defaultdict from math import ceil, sqrt def __snake_case ( lowercase : int = 1_000_000 , lowercase : int = 10 ): snake_case_ = defaultdict(lowercase ) for outer_width in range(3 , (t_limit // 4) + 2 ...
420
0
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class a__ ( unittest...
227
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def UpperCAmelCase ( snake_case : BertModel , snake_case : str , snake_case : str ): _lowerCAmelCa...
227
1
"""simple docstring""" import copy import random from transformers import CLIPTokenizer class __UpperCAmelCase ( _lowerCamelCase ): '''simple docstring''' def __init__( self , *_A , **_A ): '''simple docstring''' super().__init__(*_A , **_A ) _SCREAMING_SN...
721
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) UpperCAmelCase_ : int = { '''configuration_wav2vec2''': ['''WAV_2_VEC_2_PRETR...
165
0
import argparse import datetime def a (lowerCAmelCase__ ): __a = { """0""": """Sunday""", """1""": """Monday""", """2""": """Tuesday""", """3""": """Wednesday""", """4""": """Thursday""", """5""": """Friday""", """6""": """Saturday"""...
99
'''simple docstring''' import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from t...
109
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) a_ = { "configuration_swiftformer": [ "SWIFTFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "SwiftFormerConfig", "SwiftFormerOnnxCon...
708
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { "configuration_longformer": [ "LONGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "LongformerConfig"...
375
0
import json import os import shutil import tempfile from unittest import TestCase from transformers import BartTokenizer, BartTokenizerFast, DPRQuestionEncoderTokenizer, DPRQuestionEncoderTokenizerFast from transformers.models.bart.configuration_bart import BartConfig from transformers.models.bert.tokenization_...
654
import argparse import json import subprocess def lowerCAmelCase__ ( a__: List[str] , a__: Optional[int] ) -> Union[str, Any]: '''simple docstring''' _UpperCAmelCase = [] _UpperCAmelCase = ( F'''curl -H "Accept...
618
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_av...
131
import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def a__ ( snake_case , snake_case , snake_case , snake_case ): """sim...
131
1
import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_unordered, map_nested, tem...
36
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 s...
303
0
def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ ) -> float: _validate_point(lowerCamelCase__ ) _validate_point(lowerCamelCase__ ) if len(lowerCamelCase__ ) != len(lowerCamelCase__ ): raise ValueError('Both points must be in the same n-dimensional space' ...
337
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available a ={ """configuration_xlm""": ["""XLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMConfig""", """XLMOnnxConfig"""], """tokenization_xlm""": ["""XLMTokenizer"""], } ...
337
1
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_pa...
646
"""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...
646
1
class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : Optional[Any] , __A : int ): snake_case__ : List[str] = n snake_case__ : Optional[int] = [None] * self.n snake_case__ : int = ...
25
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if ...
25
1
"""simple docstring""" import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cast f...
91
"""simple docstring""" import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def _snake_case ( ): with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): with p...
91
1
"""simple docstring""" def lowercase__ ( snake_case_ :dict ): __UpperCAmelCase = set() # edges = list of graph's edges __UpperCAmelCase = get_edges(snake_case_ ) # While there are still elements in edges list, take an arbitrary edge # (from_node, to_node) and a...
397
"""simple docstring""" def lowercase__ ( snake_case_ :List[Any] , snake_case_ :str , snake_case_ :Tuple , snake_case_ :Any , snake_case_ :Union[str, Any] , snake_case_ :List[Any] ): if index == r: for j in range(snake_case_ ): print(data[j] , en...
397
1
'''simple docstring''' import sys from pathlib import Path __snake_case = Path(__file__).resolve().parents[3] / """src""" sys.path.insert(1, str(git_repo_path)) import dataclasses # noqa import io # noqa import itertools # noqa import json # noqa import os # noqa import unittest # noqa from copy impo...
451
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : Tuple = logging.get_logger(__name__) A__ : Dict = { """RWKV/rwkv-4-169m-pile""": """https://huggingface.co/RWKV/rwkv-4-169m-pile/resolve/main/config.json""", """RWKV/r...
13
0
"""simple docstring""" from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration lowerCAmelCase : Any = HfArgumentParser(InitializationArguments) lowerCAmelCase : int = ...
533
"""simple docstring""" def a__ ( snake_case__ = 1_00_00_00 ) -> int: lowerCamelCase = 1 lowerCamelCase = 1 lowerCamelCase = {1: 1} for inputa in range(2 , snake_case__ ): lowerCamelCase = 0 lowerCamelCase ...
533
1
"""simple docstring""" import unittest import numpy as np from datasets import load_dataset 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 ImageProcess...
633
'''simple docstring''' import argparse import ast import logging import os import sys import pandas as pd import torch from tqdm import tqdm from transformers import BartForConditionalGeneration, RagRetriever, RagSequenceForGeneration, RagTokenForGeneration from transformers import...
207
0
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class lowerCamelCase_ ( _A ): '''simple docstring''' a__ = (PNDMScheduler,) a__ = (("num_inference_steps", 50),) def ...
17
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __SCREAMING_SNAKE_CASE = { """configuration_altclip""": [ """ALTCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """AltCLIPConfig""", ...
17
1
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.testing...
221
import torch from torch import nn class UpperCAmelCase__ ( nn.Module ): """simple docstring""" def __init__( self: int , __lowerCAmelCase: List[Any] , __lowerCAmelCase: str , __lowerCAmelCase: int , __lowerCAmelCase: List[Any] ...
221
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) A = { 'configuration_speech_to_text': ['SPEECH_TO_TEXT_PRETRA...
109
"""simple docstring""" import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testing_utils import ...
109
1
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def A ( _lowercase ): SCREAMING_SNAKE_CASE : Tuple = int(number**0.5 ) return number == sq * sq def A ( _lowercase , _lowercase , _lowercase ...
248
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_tor...
53
0
from __future__ import annotations class snake_case : def __init__( self : Any , a_ : int )-> None: """simple docstring""" SCREAMING_SNAKE_CASE__ : List[Any] = data SCREAMING_SNAKE_CASE__ : Node | None = None SCREAMING_SNAKE_CA...
636
import math def _a ( lowercase__ : int ): '''simple docstring''' assert isinstance(lowercase__ , lowercase__ ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: # 2 and 3 are primes return True elif...
636
1
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : int , _SCREAMING_SNAKE_CASE : int ) -> int: """simple docstring""" return abs(_SCREAMING_SNAKE_CASE ) if a == 0 else greatest_common_divisor(b % a , _SCREAMING_SNAKE_CASE ) def a__ ...
71
'''simple docstring''' from __future__ import annotations import unittest from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_...
71
1
'''simple docstring''' def __lowercase (_lowercase ) -> None: """simple docstring""" __lowerCamelCase : List[Any] = generate_pascal_triangle(_lowercase ) for row_idx in range(_lowercase ): # Print left spaces for _ in range(num_rows...
483
'''simple docstring''' import math def __lowercase () -> None: """simple docstring""" __lowerCamelCase : Optional[int] = input("""Enter message: """ ) __lowerCamelCase : Optional[Any] = int(input(f"Enter key [2-{len(_lowercase ) - 1}]: ...
483
1
'''simple docstring''' import argparse import logging import sys from unittest.mock import patch import run_glue_deebert from transformers.testing_utils import TestCasePlus, get_gpu_count, require_torch_non_multi_gpu, slow logging.basicConfig(level=logging.DEBUG) _A : Optional[Any] = lo...
427
'''simple docstring''' from sklearn.metrics import matthews_corrcoef import datasets _A : Any = ''' Compute the Matthews correlation coefficient (MCC) The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes ...
427
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case_ = { """configuration_table_transformer""": [ """TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """TableTransformerConfig""", ...
355
'''simple docstring''' import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from ...
355
1
class lowerCAmelCase_ : """simple docstring""" def __init__( self :List[str] ): UpperCamelCase__ :List[str] = """""" UpperCamelCase__ :Optional[Any] = """""" UpperCamelCase__ :Union[str, Any] = [] def __a ( self ...
45
from __future__ import annotations def A ( lowercase__ : int ) -> list[int]: UpperCamelCase__ :Union[str, Any] = [True] * limit UpperCamelCase__ :int = False UpperCamelCase__ :Optional[Any] = False UpperCamelCase__ :str = True for i in range(3 , int...
45
1
lowercase_ = """Tobias Carryer""" from time import time class __UpperCamelCase : """simple docstring""" def __init__( self : Optional[Any] , _A : Optional[Any] , _A : List[Any] , _A : Any , _A : ...
131
from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase_ = logging.get_logger(__name__) lowercase_ = { """google/switch-base-8""": """https://huggingface.co/google/switch-base-8/blob/main/config.json""", } class __UpperCamelCase ( lowerCAme...
131
1
from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def A__ ( ): SCREAMING_SNAKE_CASE__: Optional[Any]= [randint(-1_000 , 1_000 ) for i in range(10 )] SCREAMING_SNAKE_CASE__: Union[str, Any]= randint(-5_000 ...
64
import math import unittest def __UpperCAmelCase ( __A ) -> bool: '''simple docstring''' assert isinstance(__A , __A ) and ( number >= 0 ), "'number' must been an int and positive" if 1 < number < 4: ...
475
0
import math def A__( __lowerCAmelCase ): _snake_case : int = [True] * n _snake_case : str = False _snake_case : int = False _snake_case : Optional[int] = True for i in range(3 , int(n**0.5 + 1 ) , 2 ): _snake_case ...
652
import functools def A__( __lowerCAmelCase , __lowerCAmelCase ): # Validation if not isinstance(__lowerCAmelCase , __lowerCAmelCase ) or not all(isinstance(__lowerCAmelCase , __lowerCAmelCase ) for day in days ): raise ValueError('The parameter days should be a list of i...
652
1
import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def UpperCAmelCase__( __UpperCAmelCase : Optional[int] ): return x + 2 class __SCREAMING_SNAKE_CASE ( unittest.TestCase): ...
576
"""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_video_inp...
573
0
"""simple docstring""" def a ( __UpperCAmelCase : str , __UpperCAmelCase : int ) -> list[str]: return [sentence[i : i + ngram_size] for i in range(len(__UpperCAmelCase ) - ngram_size + 1 )] if __name__ == "__main__": f...
213
"""simple docstring""" from __future__ import annotations def a ( __UpperCAmelCase : list[int] , __UpperCAmelCase : int ) -> list[int]: __magic_name__: int = 0 __magic_name__: List[str] = len(__UpperCAme...
213
1
import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_t...
639
# This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny vocab first, and then a tiny model - so the outcome is truly tiny - # all files ~60KB. As compared to t...
639
1
from ..utils import DummyObject, requires_backends class lowercase__ ( metaclass=_UpperCAmelCase ): '''simple docstring''' a : Optional[int] = ["flax"] def __init__( self, *__magic_name__, **__magic_name__ ) -> Optional[int]: ...
718
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, ...
369
0
import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class lowercase__ ( UpperCamelCase_): UpperCamelCase_ = """MCTCTFeatureExtractor""" UpperCamelCase_ = """AutoTokenizer""" def __init__( self : Optiona...
248
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def A ( _lowercase , _lowercase , _lowercase ): SCREAMING_SNAKE_CASE : List[Any] = OmegaConf.load(_lowercase ) SCREAMING_SNAKE_...
248
1
def snake_case ( snake_case__ :Dict , snake_case__ :Dict) -> Dict: _A = 0 _A = len(__lowerCAmelCase) - 1 while left <= right: # avoid divided by 0 during interpolation if sorted_collection[left] == sorted_collection[right]...
709
import heapq def snake_case ( snake_case__ :dict) -> set[int]: _A = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Priority Queue # heapq works with a min...
83
0
"""simple docstring""" from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...te...
594
'''simple docstring''' import qiskit def a_ ( _UpperCAmelCase : int = 2 ) -> qiskit.result.counts.Counts: __snake_case : Union[str, Any] = qubits # Using Aer's simulator __snake_case : List[Any] = qiskit.Aer.get_backend('aer_simulato...
286
0
'''simple docstring''' from typing import Optional, Tuple, Union import torch from einops import rearrange, reduce from diffusers import DDIMScheduler, DDPMScheduler, DiffusionPipeline, ImagePipelineOutput, UNetaDConditionModel from diffusers.schedulers.scheduling_ddim import DDIMSchedulerO...
338
'''simple docstring''' def _lowerCAmelCase ( __snake_case : Union[str, Any] , __snake_case : Tuple ) -> Union[str, Any]: __A : Tuple = [0 for i in range(r + 1 )] # nc0 = 1 __A : Dict = 1 for i in range(1 , ...
338
1
lowercase__ : Dict = [ [0, 16, 13, 0, 0, 0], [0, 0, 10, 12, 0, 0], [0, 4, 0, 0, 14, 0], [0, 0, 9, 0, 0, 20], [0, 0, 0, 7, 0, 4], [0, 0, 0, 0, 0, 0], ] def lowerCamelCase__ ( _A , _A , _A , _A ): '''simple docst...
376
import argparse import re from pathlib import Path import requests import torch from PIL import Image from torchvision.transforms import CenterCrop, Compose, Normalize, Resize, ToTensor from transformers import ( EfficientFormerConfig, EfficientFormerForImageClassificationWithTeacher, ...
376
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowercase__ : Dict = logging.get_logger(__name__) lowercase_...
711
"""simple docstring""" from statistics import mean, stdev def __lowercase ( _a , _a = 3 ): snake_case_ : Optional[int] = min(_a ) snake_case_ : str = max(_a ) # normalize data return [round((x - x_min) / (x_max - x_min) , _a ) for x in data...
485
0
import os import random import sys from . import cryptomath_module as cryptomath from . import rabin_miller _UpperCamelCase = 3 def lowerCAmelCase__( lowercase : int ) -> Optional[Any]: print("Generating primitive root of p" ) while True: __snake_case : ...
243
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCAmelCase__ ( metaclass=lowercase__ ): """simple docstring""" __UpperCAmelCase : List[str] = ['''keras_nlp'''] def __init__( self : Union[str, Any] ,*_a : List[An...
229
0
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_att...
573
"""simple docstring""" import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import B...
573
1
'''simple docstring''' import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all feature extractors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_tr...
578
import numpy as np def A__ ( _a : np.array ): '''simple docstring''' return 1 / (1 + np.exp(-vector )) if __name__ == "__main__": import doctest doctest.testmod()
385
0
import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax_available(): from transformer...
714
from __future__ import annotations import inspect import unittest from typing import List, Tuple from transformers import RegNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_...
103
0
"""simple docstring""" import math def _UpperCamelCase ( UpperCamelCase = 100 ) -> int: """simple docstring""" __UpperCAmelCase : Any = sum(i * i for i in range(1 , n + 1 ) ) __UpperCAmelCase : Union[str, Any] =...
77
import math def a_ ( lowerCAmelCase_ : list, lowerCAmelCase_ : int ): __lowerCAmelCase = len(lowerCAmelCase_ ) __lowerCAmelCase = int(math.floor(math.sqrt(lowerCAmelCase_ ) ) ) __lowerCAmelCase = 0 while arr...
53
0
"""simple docstring""" import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class _UpperCAmelCase ( unittest.TestCase): __lowercase : int = JukeboxTokenizer __lowercase : Any = { """artist""": """Zac Brow...
713
"""simple docstring""" from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def a__ ( a : Namespace ): """simple docstring""" return ConvertCommand( args.model_type , args.tf_checkpoint , args.pytorch_du...
87
0
from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable UpperCAmelCase__ = {"configuration_dpt": ["DPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DPTConfig"]} try: if not is_vis...
332
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase__ = {"configuration_vit_msn": ["VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMSNConfig"]} try: if not is_torch_available(): raise OptionalDependencyNotAvailable()...
332
1
"""simple docstring""" def a ( __UpperCAmelCase : int | float | str ) -> tuple[int, int]: try: __magic_name__: Dict = float(__UpperCAmelCase ) except ValueError: raise ValueError("""Please enter a valid nu...
704
"""simple docstring""" import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, sl...
213
0
from maths.prime_factors import prime_factors def lowercase_ ( _UpperCamelCase ): '''simple docstring''' if not isinstance(_UpperCamelCase , _UpperCamelCase ): __lowercase = F'Input value of [number={number}] must be an integer' raise TypeError(_UpperCamelCase ) ...
639
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) fro...
639
1
import pytest import requests from datasets.utils.file_utils import http_head from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline @pytest.mark.integration def __lowerCAmelCase ( ) -> Any: with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT ): ...
703
from sklearn.metrics import fa_score import datasets a_ = """ The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) """ a_ = """ Args: predictions (`list` of `int`): Predicted labels. r...
286
0
"""simple docstring""" import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup UpperCamelCase__ = { '''User-Agent''': '''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36''' ''' (KHTML, like Gecko) Chrome/70.0.3538.102 Safari...
227
"""simple docstring""" import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def UpperCAmelCase ( snake_case : BertModel , snake_case : str , snake_case : str ): _lowerCAmelCa...
227
1
'''simple docstring''' from functools import lru_cache @lru_cache def lowerCamelCase ( UpperCAmelCase__ : int ) -> int: '''simple docstring''' if num < 0: raise ValueError('Number should not be negative.' ) return 1 if num in (0, 1) else num * ...
705
'''simple docstring''' import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import versio...
320
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[Any] = logging.get_logger(__name__) lowerCamelCase : Any = { '''caidas/swin2sr-classicalsr-x2-64''': ( '''https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/r...
149
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCamelCase : List[str] = { '''configuration_conditional_detr''': [ '''CONDITIONAL_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Condition...
149
1
'''simple docstring''' import argparse import os import re import torch from flax.traverse_util import flatten_dict from tax import checkpoints from transformers import ( AutoTokenizer, PixaStructConfig, PixaStructForConditionalGeneration, PixaStructImageProcessor, PixaStructProcessor, ...
717
'''simple docstring''' import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class _snake_case ( lowerCAmelCase_ ): ""...
305
0
'''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_extraction_common imp...
138
'''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_squeezebert import SqueezeBertTokenizer snake_case_ : Optional[int] = l...
138
1
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_ou...
709
'''simple docstring''' import unittest from transformers import DebertaVaTokenizer, DebertaVaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin a__ = get_tests_dir('''fixtu...
566
0