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
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...
348
from math import factorial, pi def UpperCAmelCase__ ( __magic_name__ : float , __magic_name__ : int = 30 ): '''simple docstring''' if not isinstance(__magic_name__ , (int, float) ): raise ValueError('''maclaurin_sin() requires either an int or float for theta''' ) ...
348
1
def A ( SCREAMING_SNAKE_CASE = 600851475143 ): """simple docstring""" try: UpperCAmelCase__ :int = int(SCREAMING_SNAKE_CASE ) except (TypeError, ValueError): raise TypeError('Parameter n must be int or castable to int.' ) if n <= 0: raise ValueError...
433
import argparse import math import os from copy import deepcopy import torch from audio_diffusion.models import DiffusionAttnUnetaD from diffusion import sampling from torch import nn from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel __snake_case : Dict = { 'gwf-440...
433
1
"""simple docstring""" import argparse import os import re # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_dummies.py __UpperCamelCase = '''src/diffusers''' # Matches is_xxx_available() __UpperCamelCase = re.com...
247
"""simple docstring""" import itertools import json import os import unittest from transformers import AddedToken, LongformerTokenizer, LongformerTokenizerFast from transformers.models.longformer.tokenization_longformer import VOCAB_FILES_NAMES from transformers.testing_utils import require_token...
247
1
import unittest import numpy as np from transformers.testing_utils import is_flaky, require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
700
def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase ) -> Optional[Any]: """simple docstring""" A : Dict = [0 for i in range(r + 1 )] # nc0 = 1 A : Dict = 1 for i in range(1 , n + 1 ): # to compute current row from previous row. ...
520
0
from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Imag...
511
from __future__ import annotations import os from typing import Any import requests lowerCAmelCase : str = 'https://api.github.com' # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user lowerCAmelCase : Optional[Any] = BASE_URL + '/user' # https://github.co...
511
1
def _SCREAMING_SNAKE_CASE ( a ) -> int: __A : List[str] = [] __A : Tuple = [] __A : Union[str, Any] = { '^': 3, '*': 2, '/': 2, '%': 2, '+': 1, '-': 1, } # Priori...
77
import glob import os import random from string import ascii_lowercase, digits import cva UpperCAmelCase : Dict = '''''' UpperCAmelCase : Union[str, Any] = '''''' UpperCAmelCase : Optional[int] = '''''' UpperCAmelCase : Union[str, Any] = 1 # (0 is vert...
77
1
import random from typing import Any def __lowercase ( a__ ) -> Dict: for _ in range(len(SCREAMING_SNAKE_CASE_ ) ): __SCREAMING_SNAKE_CASE = random.randint(0 , len(SCREAMING_SNAKE_CASE_ ) - 1 ) __SCREAMING_SNAKE_CASE = ...
148
'''simple docstring''' import unittest from queue import Empty from threading import Thread from transformers import AutoTokenizer, TextIteratorStreamer, TextStreamer, is_torch_available from transformers.testing_utils import CaptureStdout, require_torch, torch_device from ..test_modeling_common import ids_te...
18
0
"""simple docstring""" def lowercase__(A = 1_000 ) ->int: """simple docstring""" lowercase__ : Union[str, Any]= 2**power lowercase__ : Dict= str(A ) lowercase__ : List[str]= list(A ) lowercase__ : Un...
85
"""simple docstring""" from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class ...
85
1
import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from transformers.testing_utils i...
225
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCamelCase__ = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""], """tokenization_mvp""": ["""...
225
1
import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def A(__a: Any , __a: str , __a: List[Any]=1024 , __a: Optional[int]=1024 , __a: List[str]=False , **__a: Optional[Any] ...
226
def A(__a: int ): lowerCAmelCase_ = abs(__a ) lowerCAmelCase_ = 0 while n > 0: res += n % 10 n //= 10 return res def A(__a: int ): lowerCAmelCase_ = abs(__a ) return n if n < 10 else n % 10 + sum_of_digits(n // 10 ) def A(__a: int ...
226
1
from abc import ABC, abstractmethod from typing import Optional, Union from .. import Dataset, DatasetDict, Features, IterableDataset, IterableDatasetDict, NamedSplit from ..utils.typing import NestedDataStructureLike, PathLike class A_ ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' ...
303
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( Audio...
71
0
import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn( 'The converted tokeni...
704
import collections import os import re from pathlib import Path __lowerCAmelCase : Tuple = 'src/transformers' # Matches is_xxx_available() __lowerCAmelCase : Union[str, Any] = re.compile(R'is\_([a-z_]*)_available()') # Catches a one-line _import_struct = {xxx} __lowerCAmelCase ...
164
0
def _snake_case ( __snake_case , __snake_case ): return "\n".join( f"""{number} * {i} = {number * i}""" for i in range(1 , number_of_terms + 1 ) ) if __name__ == "__main__": print(multiplication_table(number=5, number_of_terms=10))
10
'''simple docstring''' import warnings from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase_ = logging.get_logger(__n...
539
0
"""simple docstring""" from __future__ import annotations UpperCAmelCase : Dict = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] UpperCAmelCase : Optional[Any] = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def __a ( _lowercase ): ...
706
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCAmelCase : str = { "configuration_deberta": ["DEBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP",...
121
0
import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precision_score, re...
556
import logging import os from dataclasses import dataclass from typing import List, Optional, Union import tqdm from filelock import FileLock from transformers import ( BartTokenizer, BartTokenizerFast, DataProcessor, PreTrainedTokenizer, RobertaTokenizer, RobertaTokenize...
556
1
import torch from diffusers import DDPMScheduler from .test_schedulers import SchedulerCommonTest class _A ( UpperCAmelCase_): SCREAMING_SNAKE_CASE : int = (DDPMScheduler,) def UpperCAmelCase ( self , **_SCREAMING_SNAKE_CASE ): SCREAMING_SNAKE_CASE_ : Dict ...
708
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def A_ ( a , a , a ): """simple docstring""" SCREAMING_SNAKE_CASE_ : int = TaConfig.from...
353
0
"""simple docstring""" import numpy as np a_ : Optional[int] = [ ['''a''', '''b''', '''c''', '''d''', '''e'''], ['''f''', '''g''', '''h''', '''i''', '''k'''], ['''l''', '''m''', '''n''', '''o''', '''p'''], ['''q''', '''r''', '''s''', '''t''', '''u'''], ['''v''', '''w''', '''x'...
594
"""simple docstring""" import unittest import torch from torch import nn from diffusers.models.activations import get_activation class __lowercase( unittest.TestCase ): '''simple docstring''' def snake_case_ ( self ): __lowerCamelCase : int = ...
594
1
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import log...
274
"""simple docstring""" import operator as op def UpperCAmelCase__ ( A__ ) -> Dict: """simple docstring""" lowerCamelCase__ = [] lowerCamelCase__ = lambda A__ , A__ : int(x / y ) # noqa: E731 integer division operation lowerCamelCase__ = { "^...
274
1
from datetime import datetime as dt import os from github import Github __lowercase : Optional[int] =[ """good first issue""", """good second issue""", """good difficult issue""", """feature request""", """new model""", """wip""", ] def a__ ( ...
54
"""simple docstring""" import warnings from ...utils import logging from .image_processing_deformable_detr import DeformableDetrImageProcessor SCREAMING_SNAKE_CASE__:int = logging.get_logger(__name__) class snake_case__ ( snake_case_ ): def __init__( self , *lowerCamelCase...
528
0
'''simple docstring''' import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, is_torch_av...
119
'''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...
119
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _A( snake_case__ ): """simple docstring""" UpperCamelCase : Union[str, Any] = ['''image_processor''', '''tokenizer'''] UpperCamelCase : ...
239
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class _A( yaml.SafeLoader ): """simple docstring""" def UpperCAmelCase_ ( self , _A ): __A : Optional[int] = [self.constructed_objects[key_node]...
239
1
def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAmelCase ) -> int: """simple docstring""" while a != 0: snake_case__ , snake_case__ : str = b % a, a return b def _lowerCAmelCase ( __lowerCAmelCase , __lowerCAme...
219
# 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 # # Unless requi...
219
1
"""simple docstring""" from datetime import datetime import requests def A__ ( __lowerCamelCase ): """simple docstring""" _lowerCAmelCase = 'https://downloadgram.net/wp-json/wppress/video-downloader/video?url=' _lowerCAmelCase = requests.get(base_url +...
589
"""simple docstring""" import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging a__ : Any = logging.get_logger(__name__) a__ : Tuple = { """facebook/encodec_24khz""": """https...
589
1
import json import os from pathlib import Path import pytest from datasets.download.download_config import DownloadConfig from datasets.download.download_manager import DownloadManager from datasets.utils.file_utils import hash_url_to_filename a_ = "http://www.mocksite.com/file1.txt" a_ = "\"te...
375
import argparse import torch from datasets import load_dataset from donut import DonutModel from transformers import ( DonutImageProcessor, DonutProcessor, DonutSwinConfig, DonutSwinModel, MBartConfig, MBartForCausalLM, VisionEncoderDecoderModel, XLMRobertaTokenizerFast, ) def...
375
1
import heapq as hq import math from collections.abc import Iterator class lowerCAmelCase_ : def __init__( self , _lowerCAmelCase ): _lowercase : List[str] = str(id_ ) _lowercase : Tuple = None _lowercase : Op...
66
"""simple docstring""" from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concate...
499
0
"""simple docstring""" import numpy as np from transformers import Pipeline def __A (_SCREAMING_SNAKE_CASE ) ->List[Any]: """simple docstring""" lowerCAmelCase__ :Union[str, Any] = np.max(_SCREAMING_SNAKE_CASE , axis=-1 , keepdims=_SCREAMING_SNAKE_C...
560
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, Blipa...
560
1
"""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 ...mod...
213
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils...
213
1
'''simple docstring''' import tensorflow as tf from ...tf_utils import shape_list class SCREAMING_SNAKE_CASE( tf.keras.layers.Layer ): def __init__( self , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase...
163
'''simple docstring''' 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 imp...
163
1
"""simple docstring""" import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImagePro...
549
import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse("""9.1.0"""): _lowerCamelCase ={ """linear""": PIL.Image.Resampling.BILINEAR, """bilinear""": PIL.Image.Resampling.BILI...
681
0
'''simple docstring''' import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class lowe...
706
'''simple docstring''' import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC a__ : Any = parse(importlib.metadata.version('torch')) def __snake_case ( SCREAMING_SNAKE_CASE_ : Union[str, Version] , SCREAMI...
570
0
from typing import Dict, Optional import numpy as np import datasets _lowerCamelCase : Optional[int] = ''' IoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union between the predicted segmentation and the ground truth. For ...
663
import argparse import gc import json import os import shutil import warnings import torch from transformers import LlamaConfig, LlamaForCausalLM, LlamaTokenizer try: from transformers import LlamaTokenizerFast except ImportError as e: warnings.warn(e) warnings.warn( '''The ...
663
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, convert_to_rgb, get_resize_output_image_size, normalize, rescale, resize, to_channel...
144
import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, AutoModelForMaskedL...
144
1
"""simple docstring""" import os import socket from contextlib import contextmanager import torch from ..commands.config.default import write_basic_config # noqa: F401 from ..state import PartialState from .dataclasses import DistributedType from .imports import is_deepspeed_available, is_tpu_available fro...
153
"""simple docstring""" import os from typing import Dict, List, Union import tensorflow as tf from keras_nlp.tokenizers import BytePairTokenizer from tensorflow_text import pad_model_inputs from .tokenization_gpta import GPTaTokenizer class _lowercase ( tf.keras.layers.Layer ): def ...
490
0
def UpperCAmelCase_ ( _UpperCAmelCase ): return sum(i for i in range(1 , number // 2 + 1 ) if number % i == 0 ) == number if __name__ == "__main__": print("""Program to check whether a number is a Perfect number or not...""") lowercase : List[Any] = int(in...
584
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 Accelera...
584
1
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applic...
35
"""simple docstring""" from typing import List, Optional, Union import numpy as np from ....audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ....feature_extraction_sequence_utils import SequenceFeatureExtractor from ....feature_extraction_utils import BatchFeature from .....
123
0
"""simple docstring""" import warnings from typing import List from unittest.mock import Mock import torch from torch.utils.data import DataLoader, IterableDataset, TensorDataset from accelerate.accelerator import Accelerator from accelerate.utils.dataclasses import DistributedType class _UpperCAmelCas...
700
"""simple docstring""" import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization imp...
524
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 requir...
256
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) _lowerCamelCase : Optional[Any] = { 'configuration_mobilevit': ['MOBILEVIT_PRETRAINED_CONFIG_AR...
121
0
'''simple docstring''' import argparse import collections import torch from flax import traverse_util from tax import checkpoints from transformers import TaConfig, TaEncoderModel, TaForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() def UpperCAmelCase__( ...
717
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import load_numpy, slow f...
679
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusionPanorama...
33
from copy import deepcopy class __magic_name__ : '''simple docstring''' def __init__( self:int , _a:list[int] | None = None , _a:int | None = None ): if arr is None and size is not None: snake_case__ = size snake_case__ = ...
33
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) __snake_case : Dict = { 'configuration_vision_encoder_decoder'...
615
"""simple docstring""" import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtraction...
615
1
from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers import AutoTokenizer, TFAutoM...
625
from typing import List, Optional import numpy as np from ...processing_utils import ProcessorMixin from ...utils import to_numpy class snake_case_ ( a ): '''simple docstring''' __UpperCamelCase = 'EncodecFeatureExtractor' __UpperCamelCase ...
625
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _snake_case ( lowerCAmel...
708
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class _snake_case ( lowerCAmel...
305
0
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGeneratio...
2
import argparse import json import subprocess def UpperCamelCase ( _A, _A ): """simple docstring""" __magic_name__ : Union[str, Any] = [] __magic_name__ : Optional[int] = ( f'curl -H "Accept: application/vnd.github+json" -H "Autho...
324
0
print((lambda quine: quine % quine)("""print((lambda quine: quine %% quine)(%r))"""))
700
import argparse import os import shutil import torch from emmental.modules import MagnitudeBinarizer, ThresholdBinarizer, TopKBinarizer def UpperCAmelCase ( _snake_case ): lowerCAmelCase = args.pruning_method lowerCAmelCase = args.threshold lo...
33
0
'''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...
459
import numpy as np def a_ ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ): lowerCAmelCase__ = int(np.ceil((x_end - xa) / h ) ) lowerCAmelCase__ = np.zeros((n + 1,) ) lowerCAmelCase__ = ...
615
0
import os import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _lowerCAmelCase ( __a , unittest.TestCase ): _lowercase =PhobertTokenizer _lowercase =Fal...
279
import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators import ThreadedIterator from tqdm import...
279
1
def snake_case ( lowerCamelCase ): '''simple docstring''' for i in range(len(lowerCamelCase ) - 1 , 0 , -1 ): __lowercase = False for j in range(lowerCamelCase , 0 , -1 ): if unsorted[j] < unsorted[j - 1]: __lowercase , __lo...
80
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : int = 4000000 ) -> int: _a : Optional[Any] =[] _a , _a : Union[str, Any] =0, 1 while b <= n: if b % 2 == 0: ...
694
0
'''simple docstring''' import numpy as np def __lowercase ( __SCREAMING_SNAKE_CASE ) -> np.ndarray: """simple docstring""" return 1 / (1 + np.exp(-vector )) def __lowercase ( __SCREAMING_SNAKE_CASE ) -> np.ndarray: """simple docstri...
702
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_ = {...
201
0
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipel...
621
"""simple docstring""" import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp fro...
621
1
"""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_with_warmup, set_seed f...
91
"""simple docstring""" from math import sqrt def __snake_case ( UpperCamelCase__ ) -> int: """simple docstring""" A = 0 for i in range(1 , int(sqrt(UpperCamelCase__ ) + 1 ) ): if n % i == 0 and i != sqrt(UpperCamelCase__ ): total += i + n // i elif...
91
1
from collections import deque from .hash_table import HashTable class UpperCAmelCase_ ( __lowerCamelCase ): def __init__( self , *_lowerCAmelCase , **_lowerCAmelCase ): super().__init__(*_lowerCAmelCase , **_lowerCAmelCase ) ...
79
'''simple docstring''' from __future__ import annotations def a_ ( __snake_case : int ) -> list[int]: """simple docstring""" lowerCamelCase_ =[True] * limit lowerCamelCase_ =False lowerCamelCase_ =False lowerCamelCase_ =True for i i...
676
0
'''simple docstring''' def __UpperCAmelCase ( a_: str = 1_000_000 ): _UpperCAmelCase : Optional[int] = limit + 1 _UpperCAmelCase : List[Any] = [0] * limit for first_term in range(1, SCREAMING_SNAKE_CASE_ ): for n in range(SCREAMING_S...
715
'''simple docstring''' import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class A__ : """simple docstring""" def __init__( self ...
257
0
import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def snake_case__ ( lowercase ): lowerCAmelCase_: List[str] = SwinConfig() ...
613
import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline A_ : List[Any] =argparse.ArgumentParser("""Stable Diffusion script with intel optimization""", add_help=False) parser.add_argument("""-...
483
0
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __snake_case : str = logging.get_logger(__name__) __snake_case : Dict = { "microsoft/unispeech-large-1500h-cv": ( "https://hugging...
718
'''simple docstring''' import os import unittest from transformers import BatchEncoding from transformers.models.bert.tokenization_bert import ( BasicTokenizer, WordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.models.prophetnet.tokenization_prophetnet imp...
691
0
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) UpperCAmelCase...
533
'''simple docstring''' from __future__ import annotations def snake_case_ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): """simple docstring""" if len(SCREAMING_SNAKE_CASE__ ) <= 1 or n <= 1: return insert_next(SCREAMING_SNAKE_CASE__ , n - 1 ) rec_in...
533
1
'''simple docstring''' import argparse import json from collections import OrderedDict from functools import partial from pathlib import Path import timm import torch from huggingface_hub import hf_hub_download from transformers import LevitConfig, LevitForImageClassificationWithTeacher, LevitImagePr...
708
'''simple docstring''' import warnings from functools import wraps from typing import Callable def A_ ( snake_case ): @wraps(snake_case ) def _inner_fn(*snake_case , **snake_case ): warnings.warn( (F'''\'{fn.__name__}\' is experimental and might be subject to bre...
465
0
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def __lowercase () -> str: """simple docstring""" import os as original_os from os import path as original_path from os import rename as original_rename fr...
150
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ :List[str] = logging.get_logger(__name__) UpperCAmelCase__ :Union[str, Any] = { """BAAI/AltCLIP""": """htt...
150
1
import numpy as np class _SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : List[Any] ): SCREAMING_SNAKE_CASE = (0, 0) SCREAMING_SNAKE_CASE = None SCREAMING_SNAKE_CASE = 0 SCREAMIN...
715
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __A : Any = { 'configuration_longt5': ['LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP', 'LongT5Config', 'LongT5OnnxConfig'], } try: if not is_torch_available(): ...
698
0
from __future__ import annotations import math _lowerCAmelCase = "2020.9.26" _lowerCAmelCase = "xcodz-dot, cclaus, dhruvmanila" def _snake_case ( __snake_case , __snake_case , __snake_case , __snake_case , __snake_case ): if not all(isinstance(__snake_case , (flo...
10
from __future__ import annotations import math import random from collections.abc import Collection from typing import overload class _UpperCAmelCase : '''simple docstring''' def __init__( self : List[Any] , UpperCamelCase__ : Collection[float] | None = None ): if...
699
0
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=_A ) class _lowercase ( _A ): # `task` is not a ClassVar since we want it to be part of the `asdi...
448
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__ ( _a : int , _a : Any , _a : Union[str, Any] , _a : ...
448
1
import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart import BartTok...
606
from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import torch i...
606
1
import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor from ....
713
import unittest from transformers import AutoTokenizer, NystromformerConfig, 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 .....
225
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) SCREAMING_SNAKE_CASE_: Tuple ={ 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig', ], 'fe...
78
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _lowercase ( snake_case_ ): lowercase ...
417
0
"""simple docstring""" import unittest from transformers.models.xlm_prophetnet.tokenization_xlm_prophetnet import SPIECE_UNDERLINE, XLMProphetNetTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import cached_property from ...test_tokenizati...
439
"""simple docstring""" from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_...
439
1
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def A__ ( __A : Optional[int] ) ->Optional[Any]: if "cls_token" in name: __A =name.replace('''cls_token''' , ''...
184
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE ): """simple docstring""" def lowerCamelCase(self , lowerCAmelCase_=None , lowerCAmelCase_=None , lowerCAmelCase_=None , **lowerCAmelCase_ ...
180
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _lowercase : Tuple ={ "configuration_longt5": ["LONGT5_PRETRAINED_CONFIG_ARCHIVE_MAP", "LongT5Config", "LongT5OnnxConfig"], } try: ...
708
'''simple docstring''' import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate _lowercase : List[Any] =TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow...
574
0
"""simple docstring""" import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ......
624
"""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, PNDMScheduler, Stab...
624
1
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=__lowercase ) class a ( __lowercase ): # `task` is not a ClassVar since we want it to be part of the `asdict` output for J...
146
import math import numpy as np import qiskit from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute def lowerCAmelCase ( UpperCamelCase__ : int = 3 ) -> qiskit.result.counts.Counts: """simple docstring""" if isinstance(UpperCamelCase...
146
1
'''simple docstring''' import numpy as np class _UpperCAmelCase : def __init__( self ): '''simple docstring''' __lowerCAmelCase = (0, 0) __lowerCAmelCase = None __lowerCAmelCase = 0 __lowerCAmelCase = 0 __lowe...
689
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def _lowerCAmelCase ( lowercase ) -> Optional[Any]: # vision encoder if "img_encoder.pos_embed" in name: __lowerCAm...
689
1
from collections import deque def __lowerCAmelCase (SCREAMING_SNAKE_CASE )-> Dict: """simple docstring""" snake_case_ = len(SCREAMING_SNAKE_CASE ) snake_case_ = deque() snake_case_ = [False for _ in range(SCREAMING_SNAKE_CASE )] snake_case_ = ...
531
import unittest import numpy as np from diffusers import LMSDiscreteScheduler, OnnxStableDiffusionInpaintPipeline from diffusers.utils.testing_utils import ( is_onnx_available, load_image, nightly, require_onnxruntime, require_torch_gpu, ) from ..test_pipelines_onnx_common import OnnxPipelineT...
531
1
"""simple docstring""" def UpperCAmelCase ( a__ , a__ ): '''simple docstring''' lowerCAmelCase :Tuple = len(a__ ) print('The following activities are selected:' ) # The first activity is always selected lowerCAmelCase :Dict = ...
553
"""simple docstring""" import qiskit def UpperCAmelCase ( a__ , a__ ): '''simple docstring''' lowerCAmelCase :List[Any] = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q register lowerCAmelCase :Option...
553
1
import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datasets import load_dataset, lo...
563
def _lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' A_ = 0 while b > 0: if b & 1: res += a a += a b >>= 1 return res def _lowerCamelCase ...
563
1
def SCREAMING_SNAKE_CASE__ ( ): return [list(range(1_000 - i , -1_000 - i , -1 ) ) for i in range(1_000 )] _lowerCamelCase = generate_large_matrix() _lowerCamelCase = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]], [[3, 2], ...
6
import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization import from_bytes, to_byte...
6
1
'''simple docstring''' from __future__ import annotations def a__ ( _SCREAMING_SNAKE_CASE : Tuple ) -> Optional[Any]: """simple docstring""" UpperCAmelCase_ : Optional[int] = 0.00 UpperCAmelCase_ : List[Any] = 0 for resistor in...
717
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase = { """configuration_swinv2""": ["""SWINV2_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Swinv2Config"""], } try: if not is_torch_ava...
323
0
'''simple docstring''' from pathlib import Path import fire from tqdm import tqdm def lowerCamelCase_ ( __UpperCamelCase : Optional[int]="ro" , __UpperCamelCase : Dict="en" , __UpperCamelCase : Union[str, Any]="wmt16" , __UpperCamelCase : ...
292
'''simple docstring''' def lowerCamelCase_ ( __UpperCamelCase : int ) -> list: """simple docstring""" _A = int(__UpperCamelCase ) if n_element < 1: _A = ValueError('a should be a positive number' ) raise my_error ...
292
1
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__) UpperCamelCase__ ...
381
from PIL import Image def lowerCamelCase__ (__lowerCamelCase ): _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE : List[str] = image.size _SCREAMING_SNAKE_CASE : Tuple = 0 _SCREAMING_SNAKE_CASE : Dict = image.load() f...
381
1
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class lowercase_ (lowerCamelCase__ )...
41
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) _UpperCamelCase = {"""configuration_vit""": ["""VIT_PRETRAI...
111
0
import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : List[str] , _SCREAMING_SNAKE_CASE : Any , _SCREAMING_SNAKE_CA...
702
import baseaa def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : str ): return baseaa.baaencode(string.encode("""utf-8""" ) ) def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : bytes ): return baseaa.baadecode(_SCREAMING_SNAKE_CASE ).decode("""utf-8"...
138
0
'''simple docstring''' 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_att...
69
"""simple docstring""" from __future__ import annotations def __UpperCamelCase ( snake_case__ , snake_case__ = None , snake_case__ = None ): if start is None: A_ : Dict = 0 if end is None: A_ : Dict = len(snake_case__ ) - 1 if start >= end: ret...
180
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) a : int = { """configuration_trocr""": ["""TROCR_PRETRAINED_CONFIG_ARCHIVE_MAP...
719
"""simple docstring""" from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class __Upper...
85
0
class __lowercase : def __init__( self ) ->int: '''simple docstring''' __lowerCAmelCase : List[str] = 0 __lowerCAmelCase : Optional[int] = 0 __lowerCAmelCase : Union[str, Any] = {} def UpperCamelCase__ ( self , A_ ) ->Tuple: ...
492
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _UpperCamelCase = {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "X...
492
1
"""simple docstring""" import argparse import gdown import numpy as np import torch from huggingface_hub import hf_hub_download from transformers import ( CLIPTokenizer, CLIPTokenizerFast, VideoMAEImageProcessor, XCLIPConfig, XCLIPModel, XCLIPProcessor, XCLIPTextConfig, XCLIPVisio...
158
"""simple docstring""" from __future__ import annotations __lowerCAmelCase : Union[str, Any] = list[tuple[int, int]] __lowerCAmelCase : Optional[int] = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstacles [0, 0, 0, 0, 0, ...
158
1
"""simple docstring""" import copy import json import os import tempfile from transformers import is_torch_available from .test_configuration_utils import config_common_kwargs class __lowerCAmelCase ( _lowercase ): """simple docstring""" def __init__( self : List[Any...
115
"""simple docstring""" def A_ (__a ): '''simple docstring''' A_ = len(__a ) while cur > 1: # Find the maximum number in arr A_ = arr.index(max(arr[0:cur] ) ) # Reverse from 0 to mi A_ = arr[mi::-1] + ar...
115
1
from string import ascii_uppercase UpperCAmelCase_ = {char: i for i, char in enumerate(ascii_uppercase)} UpperCAmelCase_ = dict(enumerate(ascii_uppercase)) def UpperCAmelCase__ ( _SCREAMING_SNAKE_CASE : str , _SCREAMING_SNAKE_CASE : str )->str: _lowerCAmel...
706
from __future__ import annotations def UpperCAmelCase__ ( _SCREAMING_SNAKE_CASE : list )->list: if len(_SCREAMING_SNAKE_CASE ) == 0: return [] _lowerCAmelCase , _lowerCAmelCase = min(_SCREAMING_SNAKE_CASE ), max(_SCREAMING_SNAKE_CASE ) _lowerCAmelCase ...
664
0
"""simple docstring""" from string import ascii_uppercase _snake_case = {str(ord(c) - 55): c for c in ascii_uppercase} def snake_case ( _a: int , _a: int )-> str: '''simple docstring''' if isinstance(_a , _a ): raise TypeError('int() can\'...
510
"""simple docstring""" import os from datetime import datetime as dt from github import Github _snake_case = [ "good first issue", "good second issue", "good difficult issue", "enhancement", "new pipeline/model", "new scheduler", "wip", ] def sna...
510
1
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize("""dataset_size""" , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize("""input_in_memory_max_size""" , ["""default""", 0, 100 * 2**20, 900 * 2**20] ) def ...
321
def lowerCamelCase ( UpperCAmelCase_ : int = 10 , UpperCAmelCase_ : int = 1000 , UpperCAmelCase_ : bool = True )-> int: """simple docstring""" assert ( isinstance(UpperCAmelCase_ , UpperCAmelCase_ ) and isinstance(Up...
321
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokeniza...
65
"""simple docstring""" import argparse import os import torch from transformers import FlavaConfig, FlavaForPreTraining from transformers.models.flava.convert_dalle_to_flava_codebook import convert_dalle_checkpoint def __UpperCAmelCase ( __UpperCamelCase ): # encod...
76
0
def SCREAMING_SNAKE_CASE__ ( lowerCAmelCase_ : int ,lowerCAmelCase_ : int ) -> int: """simple docstring""" while b: SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ : Optional[int] =b, a % b return a def ...
153
from __future__ import annotations __SCREAMING_SNAKE_CASE = '#' class lowerCAmelCase_ : '''simple docstring''' def __init__( self ): SCREAMING_SNAKE_CASE_ : dict ={} def __lowerCamelCase ( self , __UpperCAmelCase ): ...
153
1
'''simple docstring''' import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def _UpperCame...
42
'''simple docstring''' def a__ ( lowercase : Dict, lowercase : Optional[Any] ) -> int: """simple docstring""" _UpperCamelCase = 0 _UpperCamelCase = len(lowercase ) - 1 while left <= right: # avoid divided by 0 durin...
98
0
"""simple docstring""" import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import cached_property, is_torch_available,...
117
"""simple docstring""" import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _lowerCAmelCase ( unittest.T...
117
1
def UpperCamelCase ( _A : int = 600851475143 )-> Tuple: """simple docstring""" try: A__ = int(_A ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise V...
491
"""simple docstring""" import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch....
179
0
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters _lowerCamelCase =(7_20, 12_80) # Height, Width _lowerCamelCase =(0.4, 0.6) # if height or width lower than this scale, drop it. _lowerCamelCase =1 / 1_00 _lowerCamelCase ...
710
from ..utils import DummyObject, requires_backends class a_ ( metaclass=lowerCamelCase_ ): """simple docstring""" __UpperCAmelCase = ['torch', 'scipy'] def __init__( self : Any ,*snake_case : Any ,**snake_case : str ): requires...
252
0
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_ = logging.get_logger(__name__) lowercase_ = { """google/mobilenet_v2_1.4_224""": "...
74
"""simple docstring""" import importlib import inspect import os import re # 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_docstrings.py __A = "src/transformers" # This is to make sure the transformers m...
346
0
'''simple docstring''' import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class SCREAMING_SNAKE_CASE__ ( snake_case_ ...
716
'''simple docstring''' lowerCAmelCase : Optional[Any] = '\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install ...
432
0
'''simple docstring''' import socket def _UpperCamelCase ( ) -> Optional[int]: '''simple docstring''' snake_case : Optional[Any] = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) snake_case : Dict = socket.gethostname() ...
638
'''simple docstring''' from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCo...
638
1
"""simple docstring""" from typing import List from ...configuration_utils import PretrainedConfig from ...utils import logging A__ : Any = logging.get_logger(__name__) A__ : Optional[Any] = { 'snap-research/efficientformer-l1-300': ( 'https://huggingface.co/snap-researc...
707
"""simple docstring""" import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, slow from utils ...
272
0
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 __A : Union[str, Any] = {1: (1, 1), 2: (2, 1), 3: (3, 1), 4: (2, ...
27
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, ) snake_case_ : Tuple = { "configuration_albert": ["ALBERT_PRE...
488
0
'''simple docstring''' import os import tempfile import unittest from transformers import DistilBertConfig, is_torch_available from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common impo...
703
'''simple docstring''' from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forwa...
271
0
import os import pytest import yaml from datasets.features.features import Features, Value from datasets.info import DatasetInfo, DatasetInfosDict @pytest.mark.parametrize( """files""" , [ ["""full:README.md""", """dataset_infos.json"""], ["""empty:README.md""", """dataset_infos.json...
354
import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import ANY if is_vision_avai...
354
1
"""simple docstring""" import pprint import requests SCREAMING_SNAKE_CASE_ = '''https://zenquotes.io/api''' def A__ ( ) -> list: '''simple docstring''' return requests.get(API_ENDPOINT_URL + "/today" ).json() def A__ ( ) -> list: '''simple docstring''...
579
"""simple docstring""" def A__ ( A__ ) -> str: '''simple docstring''' _UpperCAmelCase = "" for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def A__ ( A__ ) -> dict[str, str]: ...
579
1