code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
from __future__ import annotations import unittest from transformers import DistilBertConfig, 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_attention_mask fr...
76
'''simple docstring''' # DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_c...
93
0
from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_axis_dimension from ...uti...
364
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __UpperCamelCase ( lowerCamelCase__ ): lowercase : List[str] =['image_processor', 'tokenizer'] lowercase : Optional[int] ...
6
0
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore a : int = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" a : Union[str, Any] = [fi...
114
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class a__ ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__...
67
0
import math def _a ( _lowercase : int ): '''simple docstring''' if not isinstance(_snake_case , _snake_case ): __UpperCAmelCase : Tuple = F'Input value of [number={number}] must be an integer' raise TypeEr...
352
'''simple docstring''' import os import sys import unittest __UpperCAmelCase :Optional[int] = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies...
240
0
'''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, WavaVecaCTCTokeniz...
55
import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print('Googling.....') lowerCamelCase__ : List[Any] = 'https://www.google.com/search?q=' + ' '.join(sys.argv[1:]) lowerCamelCase__ : List[Any] = ...
225
0
import argparse import torch from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_from_original_stable_diffusion_ckpt if __name__ == "__main__": SCREAMING_SNAKE_CASE_:Tuple = argparse.ArgumentParser() parser.add_argument( """--checkpoint_path""", default=None,...
115
from random import randint, random def __UpperCamelCase ( _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase , _lowerCAmelCase = False , _lowerCAmelCase = False , _lowerCAmelCase = 5 , ) -> list: """simple docstring""" A : Any = ...
115
1
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE_ ) class __A ( SCREAMING_SNAKE_CASE_ ): _UpperCamelCase : ...
44
"""simple docstring""" import numpy as np def __lowerCAmelCase (_UpperCamelCase ): return 1 / (1 + np.exp(-vector )) def __lowerCAmelCase (_UpperCamelCase ): return vector * sigmoid(_UpperCamelCase ) if __name__ == "__main__": import doctest doctest.testmod()
86
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_av...
368
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, EfficientFormerIma...
141
0
'''simple docstring''' def __magic_name__( lowerCamelCase): return credit_card_number.startswith(('''34''', '''35''', '''37''', '''4''', '''5''', '''6''')) def __magic_name__( lowerCamelCase): __lowerCAmelCase = credit_card_number __lowerCAmelCase = 0...
174
# flake8: noqa # Lint as: python3 A : Optional[Any] = [ 'VerificationMode', 'Version', 'disable_progress_bar', 'enable_progress_bar', 'is_progress_bar_enabled', 'experimental', ] from .info_utils import VerificationMode from .logging import disable_progress_bar, enable_progress_bar, is_...
6
0
import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils import is_torch_available ...
367
# Lint as: python3 import itertools import os import re lowerCAmelCase__ : Optional[int] =re.compile(R'([A-Z]+)([A-Z][a-z])') lowerCAmelCase__ : List[Any] =re.compile(R'([a-z\d])([A-Z])') lowerCAmelCase__ : Dict =re.compile(R'(?<!_)_(?!_)') lowerCAmelCase__ : i...
162
0
def _snake_case ( lowerCAmelCase : list ): """simple docstring""" if len(lowerCAmelCase ) <= 1: return [tuple(lowerCAmelCase )] SCREAMING_SNAKE_CASE_ : Tuple = [] def generate(lowerCAmelCase : int , lowerCAmelCase : list ): if k == 1: res.ap...
18
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 snake_case_ (lowerCamelCase_ , unittest.TestCase ): ...
240
0
"""simple docstring""" from graphs.minimum_spanning_tree_kruskal import kruskal def _SCREAMING_SNAKE_CASE ( ) ->Union[str, Any]: '''simple docstring''' a : str = 9 a : Dict = [ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1],...
370
"""simple docstring""" import math def _SCREAMING_SNAKE_CASE ( _lowercase : int = 100 ) ->int: '''simple docstring''' a : Dict = sum(i * i for i in range(1 , n + 1 ) ) a : Tuple = int(math.pow(sum(range(1 , n + 1...
79
0
"""simple docstring""" import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration UpperCAmelCase : Dict = 50_0000 UpperCAmelCase , UpperCAmelCase : Optional[int] = os.path.split(__file__) UpperCAme...
115
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 ...
115
1
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
350
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { ...
241
0
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 from .transformer_engine import ...
103
'''simple docstring''' import random import unittest import torch from diffusers import IFImgaImgSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device from ..pipeline_params ...
141
0
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict lowercase__ = namedtuple( "_TestCommandArgs", [ "dataset", "name...
359
from pathlib import Path import fire from tqdm import tqdm def UpperCamelCase ( lowerCAmelCase__="ro" , lowerCAmelCase__="en" , lowerCAmelCase__="wmt16" , lowerCAmelCase__=None ): '''simple docstring''' try: import datasets except (ModuleNotFoundError, Import...
97
0
"""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 __snake_case ( tf.keras.layers.Layer ): """si...
179
'''simple docstring''' def UpperCAmelCase__ ( UpperCAmelCase__ ) -> bool: return str(UpperCAmelCase__ ) == str(UpperCAmelCase__ )[::-1] def UpperCAmelCase__ ( UpperCAmelCase__ ) -> int: return int(UpperCAmelCase__ ) + int(str(UpperCAmelCase__ )[::-1] ) def UpperCAmelCas...
162
0
'''simple docstring''' from collections import defaultdict from typing import Optional from ..image_utils import load_image from ..utils import ( add_end_docstrings, is_torch_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, ChunkPipeline ...
366
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaControlnetImgaImgPipeline, KandinskyVaaPriorEmbaEmbPipeline, UNetaDConditionModel, VQModel, ) ...
3
0
import argparse import json from tqdm import tqdm def _UpperCAmelCase ( ): __UpperCamelCase =argparse.ArgumentParser() # Required parameters parser.add_argument( '--src_path' , type=SCREAMING_SNAKE_CASE__ , default='biencoder-nq-dev.json' , help='Path...
62
'''simple docstring''' import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel lowerCamelCase_ ...
79
0
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging _snake_case = logging.get_logger(__name__) _snake_case = {...
343
# Copyright (c) 2021-, NVIDIA CORPORATION. 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...
343
1
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def _snake_case ( _snake_case : int , _snake_case : int , _snake_case : int , _snake_case : int , _snake_case : int , _snak...
60
"""simple docstring""" from ..utils import DummyObject, requires_backends class __lowerCamelCase ( metaclass=A__ ): '''simple docstring''' a_ : Union[str, Any] = ["""flax"""] def __init__( self : Dict , *a_ : Optional[Any] , **a_ ...
241
0
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ) def lowerCAmelCase__ ( ) -> Dict: '''simpl...
350
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, ) lowerCAmelCase__ :Any = {'''configuration_xglm''': ['''...
185
0
def _A ( SCREAMING_SNAKE_CASE : list ): """simple docstring""" a__ : Tuple =len(SCREAMING_SNAKE_CASE ) for _ in range(SCREAMING_SNAKE_CASE ): for i in range(_ % 2 , arr_size - 1 , 2 ): if arr[i + ...
95
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable __snake_case = {'''configuration_dpt''': ['''DPT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''...
97
0
'''simple docstring''' from collections.abc import Callable from math import pi, sqrt from random import uniform from statistics import mean def lowercase (_A ): """simple docstring""" def is_in_circle(_A , _A ) -> bool: ...
25
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase : Optional[Any] = { """CarlCochet/trajectory-transformer-halfcheetah-m...
25
1
def __A ( __lowerCAmelCase )-> bool: """simple docstring""" _UpperCAmelCase = [int(__lowerCAmelCase ) for i in ip_va_address.split('.' ) if i.isdigit()] return len(__lowerCAmelCase ) == 4 and all(0 <= int(__lowerCAmelCase ) <= 254 for octet in octets...
39
'''simple docstring''' import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel lowercase : Union[str, Any] = { 'text_branch': 'text_model', 'audio_branch': 'audio_model.audio_encoder', 'a...
3
0
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, ...
353
import glob import os import random from string import ascii_lowercase, digits import cva __UpperCAmelCase : Optional[int] = "" __UpperCAmelCase : Union[str, Any] = "" __UpperCAmelCase : Optional[int] = "" __UpperCAmelCase : Any = 1 # (0 is vertical, 1 is horizontal) de...
315
0
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _...
343
import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXTRACTOR_MAPPING, AutoConfig, AutoFeatureExtractor, WavaVecaConfig, WavaVecaFeatureExtractor, ) from transformers.testing_utils import DUMMY_UN...
343
1
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() __UpperCamelCase : Any = logging.get_logger(__name__) __UpperCamelCase : Any = {name: getattr(transformers, name + "Fast")...
51
# Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING import numpy as np import pyarrow as pa from .. import config from ..utils.py_utils import map_nested from .formatting import TensorFormatter if TYPE_CHECKING: import torch class __magic_name__ ( Te...
51
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __lowercase = logging.get_logger(__name__) __lowercase = { ...
40
'''simple docstring''' import unittest import torch from diffusers import VQModel from diffusers.utils import floats_tensor, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin, UNetTesterMixin enable_full_determinism() class ...
185
0
'''simple docstring''' import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='''session''' ) def ...
240
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __UpperCAmelCase :Union[str, Any] = { "configuration_rag": ["RagConfig"], "retrieval_rag": ["RagRetriever"], ...
240
1
"""simple docstring""" import json import os import re import unittest from transformers import CodeGenTokenizer, CodeGenTokenizerFast from transformers.models.codegen.tokenization_codegen import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokeniz...
25
"""simple docstring""" import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py UpperCAmelCase__ : List[str...
25
1
from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def SCREAMING_SNAKE_CASE_ (UpperCamelCase = True , *UpperCamelCase , **UpperCamelCase ) -> Union[str, Any]: if not is_...
363
'''simple docstring''' import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def SCREAMING_SNAKE_CASE_ (UpperCamelCase ) -> List[Any]: if "cls_token" in name: ...
129
0
def lowerCAmelCase_ ( __a , __a ) -> str: """simple docstring""" lowerCamelCase__: int =[[] for _ in range(_snake_case )] lowerCamelCase__: Union[str, Any] =key - 1 if key <= 0: raise ValueError("Height of grid can\'t be 0 or negative" ) if key ==...
10
"""simple docstring""" 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...
315
0
from ..utils import DummyObject, requires_backends class lowerCamelCase_ ( metaclass=__lowercase ): '''simple docstring''' a__ : Optional[int] = ["torch"] def __init__( self , *__lowercase , **__lowercase) -> Dict: requires_backe...
352
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) __lowercase = { '''configuration_layoutlmv3''': [ '''LAYOUTLMV3_PRETRAINED_CONFIG_ARCH...
105
0
def A (__A : int ) -> None: """simple docstring""" UpperCAmelCase_ = generate_pascal_triangle(__A ) for row_idx in range(__A ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): ...
51
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_ : Dict = {"configuration_mbart"...
51
1
"""simple docstring""" import datasets UpperCamelCase_ ="""\ @InProceedings{conneau2018xnli, author = \"Conneau, Alexis and Rinott, Ruty and Lample, Guillaume and Williams, Adina and Bowman, Samuel R. ...
363
"""simple docstring""" from functools import lru_cache @lru_cache def a_ ( _lowercase ): if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __name__...
128
0
snake_case : Optional[Any] = { '''A''': '''.-''', '''B''': '''-...''', '''C''': '''-.-.''', '''D''': '''-..''', '''E''': '''.''', '''F''': '''..-.''', '''G''': '''--.''', '''H''': '''....''', '''I''': '''..''', '''J''': '''.---''', '''K''': '''-.-''', '''L''': '''.-..''', '''M''': '''...
240
import argparse snake_case : int = '''docs/source/_static/js/custom.js''' def __lowercase ( __lowerCAmelCase : Optional[Any] ): with open(__lowerCAmelCase , encoding='utf-8' , newline='\n' ) as f: a__ = f.readlin...
240
1
"""simple docstring""" import os from collections import deque import torch from torch.utils.data import Dataset class snake_case__ ( snake_case_ ): def __init__( self , lowerCamelCase="" , lowerCamelCase="train" ): assert os.path.isdir(lowerCamelCase ) __...
365
"""simple docstring""" import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging SCREAMING_SNAKE_CASE__:Optional[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__:str = { """asapp/sew-d-tiny-100k""": """https://huggingface.co/asapp/sew-d-ti...
268
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, CycleDiffusionPipeline, DDIMScheduler, UNetaDConditionModel from diffusers.utils import floats_tensor, loa...
54
from jiwer import compute_measures import datasets __snake_case : Dict ='\\n@inproceedings{inproceedings,\n author = {Morris, Andrew and Maier, Viktoria and Green, Phil},\n year = {2004},\n month = {01},\n pages = {},\n title = {From WER and RIL to MER and WIL: improved evaluation mea...
129
0
'''simple docstring''' from typing import List, Optional, Union import numpy as np from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging lowerCAmelCase : Dict = lo...
251
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase : int = { 'facebook/timesformer': 'https://huggingface.co/facebook/timesformer/resolve/main/config.jso...
251
1
import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.util...
87
"""simple docstring""" from datetime import datetime import requests def _SCREAMING_SNAKE_CASE ( _lowercase : str ) ->bytes: '''simple docstring''' a : Dict = "https://downloadgram.net/wp-json/wppress/video-downloader/video?url...
105
0
'''simple docstring''' import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common import Toke...
366
'''simple docstring''' import os from pickle import UnpicklingError from typing import Dict, Tuple import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict, unflatten_dict import transformers from .utils import lo...
31
0
"""simple docstring""" import argparse import os import torch from transformers.utils import WEIGHTS_NAME lowerCAmelCase : List[str] = ["""small""", """medium""", """large"""] lowerCAmelCase : int = """lm_head.decoder.weight""" lowerCAmelCase : Lis...
291
def _lowerCAmelCase (_lowerCAmelCase): if n_term == "": return [] UpperCamelCase_ = [] for temp in range(int(_lowerCAmelCase)): series.append(f"""1/{temp + 1}""" if series else "1") return series if __name__ == "__main__": UpperCAmelCase : ...
128
0
def UpperCAmelCase_ ( __UpperCAmelCase : list ) -> list: if len(__UpperCAmelCase ) <= 1: return [tuple(__UpperCAmelCase )] SCREAMING_SNAKE_CASE_ = [] def generate(__UpperCAmelCase : int , __UpperCAmelCase ...
210
import random from typing import Any def UpperCAmelCase_ ( __UpperCAmelCase : list ) -> list[Any]: for _ in range(len(__UpperCAmelCase ) ): SCREAMING_SNAKE_CASE_ = random.randint(0 , len(__UpperCAmelCase ) - 1 ) ...
210
1
'''simple docstring''' from __future__ import annotations def _A ( snake_case ) -> Union[str, Any]: _lowercase : Dict = len(A__ ) # We need to create solution object to save path. _lowercase : Dict = [[0 for _ in range(A__ )] for _ in range(A__ )...
250
"""simple docstring""" 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_availa...
268
0
'''simple docstring''' def snake_case_ ( __SCREAMING_SNAKE_CASE : Any , __SCREAMING_SNAKE_CASE : int , __SCREAMING_SNAKE_CASE : List[str]=False ): """simple docstring""" if isinstance(__SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ...
264
'''simple docstring''' import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor _lowercase : Any = logging.get_logger(__name__) class lowerCAmelCase__ ( lowerCamelCase_ ): def __init__( s...
264
1
'''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 _a ...
251
'''simple docstring''' from __future__ import annotations def lowercase__( __UpperCamelCase: int ): """simple docstring""" SCREAMING_SNAKE_CASE : Tuple = [True] * limit SCREAMING_SNAKE_CASE : List[str] = False SCREAMING_SNAKE_CA...
251
1
"""simple docstring""" import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging __UpperCamelCase : int = logging.get_lo...
309
"""simple docstring""" from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, i...
309
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = { '''configuration_bigbird_pegasus''': [ '''BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BigBirdPegasusConfig''...
104
'''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_inputs if is_torch_avai...
31
0
"""simple docstring""" import argparse import os import re _SCREAMING_SNAKE_CASE : List[str] = """src/diffusers""" # Pattern that looks at the indentation in a line. _SCREAMING_SNAKE_CASE : Optional[int] = re.compile(r"""^(\s*)\S""") # Pattern that matches `"key":" and puts `key` in grou...
157
"""simple docstring""" import torch from diffusers import StableDiffusionPipeline _SCREAMING_SNAKE_CASE : Optional[int] = """path-to-your-trained-model""" _SCREAMING_SNAKE_CASE : Optional[Any] = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("""cuda""") ...
157
1
import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor __a : List[Any] = logging.get_logger(__name__) class _UpperCamelCase ( _UpperCAmelCase ): """simple docstring""" def __init__( self , *lowerCAmelCase__ ...
210
from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time __a : List[str] = Lock() def UpperCAmelCase ( lowercase , lowercase , lowercase , lowercase , lowercase , lowercase ,...
210
1
"""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_retribert import RetriBertTokenizer __SCREAMING_SNAKE_CASE =logging.get_logger...
321
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark, TensorFlow...
321
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, Pi...
264
"""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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import ( ...
264
1
'''simple docstring''' from __future__ import annotations import queue class _SCREAMING_SNAKE_CASE : def __init__( self : int , a__ : Dict ): __magic_name__ = data __magic_name__ = None __magic_name__ = None def ...
362
'''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 ImageProcessingSavingTestMixin, pre...
98
0
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperC...
309
'''simple docstring''' import json import os from pathlib import Path from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple, Union import sentencepiece from ...tokenization_utils import BatchEncoding, PreTrainedTokenizer from ...utils import logging UpperCamelCase_ = logging.get_lo...
309
1
def lowerCAmelCase__ ( a__: Dict , a__: Any ) -> List[Any]: '''simple docstring''' _UpperCAmelCase = [0 for i in range(r + 1 )] # nc0 = 1 _UpperCAmelCase = 1 for i in range(1 , n + 1 ): # to compute current row from pre...
185
from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def lowerCAmelCase__ ( a__: Sequence[float] , a__: int , a__: int ) -> tuple[int | None, int | None, float]: '''simple docstring''' ...
185
1
# This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for tests from os.path import j...
157
from math import sqrt def _UpperCamelCase ( snake_case__ ) -> int: __UpperCAmelCase : Union[str, Any] = 0 for i in range(1, int(sqrt(snake_case__ ) + 1 ) ): if n % i == 0 and i != sqrt(snake_case__ ): ...
157
1
'''simple docstring''' import csv import tweepy # Twitter API credentials __snake_case : Union[str, Any] = '' __snake_case : Any = '' __snake_case : int = '' __snake_case : int = '' def _UpperCAmelCase ( _UpperCamelCase : ...
18
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, Compose, Normalize, ...
18
1
'''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_retribert import RetriBertTokenizer SCREAMING_SNAKE_CASE__ =...
321
'''simple docstring''' def lowercase__ ( __UpperCamelCase = 4000000 )-> int: UpperCamelCase = [] UpperCamelCase ,UpperCamelCase = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__UpperCamelCase ) Upp...
321
1
from __future__ import annotations def SCREAMING_SNAKE_CASE ( snake_case_ : list[int] , snake_case_ : int ): snake_case__ : Any = 0 snake_case__ : Optional[int] = len(snake_case_ ) - 1 while i < j: if nums[i] + nums[j] == target: retu...
286
__lowerCamelCase : Optional[int] = """Tobias Carryer""" from time import time class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : List[Any] , __A : List[Any] , __A : Optional[int] , __A : List[st...
286
1
import logging from transformers.configuration_utils import PretrainedConfig __A = logging.getLogger(__name__) class _SCREAMING_SNAKE_CASE ( __SCREAMING_SNAKE_CASE ): '''simple docstring''' lowercase_ = "masked_bert" def __init__(self : Dict , UpperCAmelCase_ ...
10
"""simple docstring""" import numpy as np import torch from torch.nn import CrossEntropyLoss from transformers import AutoModelForCausalLM, AutoTokenizer import datasets from datasets import logging lowerCAmelCase__ : List[Any] = '\\n\n' lowerCAmelCase__ : Tuple = '\nPerplexity (PPL) i...
98
0
'''simple docstring''' # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .for...
4
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
4
1
'''simple docstring''' import argparse import collections import json import os import re import string import sys import numpy as np A__ : Optional[int] = re.compile(R"""\b(a|an|the)\b""", re.UNICODE) A__ : Tuple = None def UpperCAmelCase__ ( ) -> Optional[Any...
185
'''simple docstring''' import inspect import jax import jax.lax as lax import jax.numpy as jnp from ..utils import add_start_docstrings from ..utils.logging import get_logger A__ : List[str] = get_logger(__name__) A__ : str = R""" Args: input_ids (`jnp.ndarray` ...
185
1
"""simple docstring""" class lowerCamelCase__ : '''simple docstring''' def __init__( self , __UpperCAmelCase , __UpperCAmelCase=None , __UpperCAmelCase=None ) -> Union[str, Any]: _lowerCAmelCase =data _lowerCAmelCase =previous...
341
"""simple docstring""" import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class lowerCamelCase__ : '''simple docstring''' lowerCamelCase = None lowerCamelCase = False lowerCamelCase = F...
341
1
import sys __lowerCamelCase : List[Any] = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' '''6689664895044...
18
def _snake_case ( lowerCAmelCase : int ): """simple docstring""" SCREAMING_SNAKE_CASE_ : Tuple = int(lowerCAmelCase ) if decimal in (0, 1): # Exit cases for the recursion return str(lowerCAmelCase ) SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ : Dict ...
18
1
from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging lowerCAmelCase__ : List[str] =logging.get_logger(__name__) def __lowercase ( a__ ) -> List[int]: if isinstance(a__ , np.ndarray ): ...
361
from __future__ import annotations from collections.abc import Generator def __lowercase ( ) -> Generator[int, None, None]: __SCREAMING_SNAKE_CASE = {} __SCREAMING_SNAKE_CASE = 2 while True: __SCREAMING_SNAKE_CASE = factor_map.pop(a...
118
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowerCamelCase_ : int = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDepend...
286
"""simple docstring""" def UpperCAmelCase__ ( _UpperCAmelCase ): """simple docstring""" if isinstance(_UpperCAmelCase , _UpperCAmelCase ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(_UpperCAmelCase , _UpperCAmelCas...
286
1
"""simple docstring""" from collections import deque from .hash_table import HashTable class __snake_case ( __lowerCAmelCase ): def __init__( self , *lowercase , **lowercase) -> Optional[Any]: '''simple docstring''' super().__init__(*lowe...
203
"""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 lowercase__ = {'vocab_file': 'vocab.txt', 'tokenizer_file': 'tokenizer.json'} lowercase...
203
1
'''simple docstring''' # Lint as: python3 import sys from collections.abc import Mapping from typing import TYPE_CHECKING, Dict, Optional import numpy as np import pyarrow as pa from .. import config from ..utils.logging import get_logger from ..utils.py_utils import map_nested from .formatt...
4
'''simple docstring''' # Copyright (c) 2021-, NVIDIA CORPORATION. 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/lice...
4
1
import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class __magic_name__ ( lower...
70
# flake8: noqa # Lint as: python3 from typing import Dict, List, Optional, Type from .. import config from ..utils import logging from .formatting import ( ArrowFormatter, CustomFormatter, Formatter, PandasFormatter, PythonFormatter, TensorFormatter, format_table, query_table, ) ...
70
1
'''simple docstring''' class _lowerCAmelCase : '''simple docstring''' def __init__(self , UpperCAmelCase , UpperCAmelCase=None , UpperCAmelCase=None ) -> int: _snake_case = data _snake_case = previous _snake_case = next_node ...
341
'''simple docstring''' def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE = 10**9 ): _snake_case = 1 _snake_case = 2 _snake_case = 0 _snake_case = 0 _snake_case = 0 while perimeter <= max_perimeter: perimeters_sum += perimeter ...
341
1
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 _a ( Up...
93
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers...
93
1
import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils import flo...
30
def a__ ( __UpperCamelCase = 1_0_0_0 ): SCREAMING_SNAKE_CASE_ = -1 SCREAMING_SNAKE_CASE_ = 0 for a in range(1 , n // 3 ): # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c SCREAMING_SNAKE_CASE_ = (n * n - 2 * a *...
118
0
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _lowercase : Any = logging.get_...
351
"""simple docstring""" from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...file_utils import TensorType, is_torch_available from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeq...
272
0
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tok...
203
"""simple docstring""" from typing import List import numpy as np def __lowerCAmelCase ( lowercase : dict ) -> int: """simple docstring""" snake_case : Union[str, Any] = {key: len(lowercase ) for key, value in gen_kwargs.items() if isinstance(lowercas...
203
1
"""simple docstring""" from __future__ import annotations def a__ ( snake_case__ , snake_case__ ) -> list[str]: if partitions <= 0: raise ValueError("""partitions must be a positive number!""" ) if partitions > number_of_bytes: raise ValueError("""partitions can not > ...
168
"""simple docstring""" import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMSchedu...
168
1
'''simple docstring''' from queue import PriorityQueue from typing import Any import numpy as np def UpperCamelCase__ ( lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , lowerCAmelCase , ...
70
'''simple docstring''' import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class UpperCAmelCase ( snake_case_ ): _lowercase: Union[str, Any] = ['''image_processor''', '''tokenizer'''] _...
70
1
def __lowerCamelCase ( lowerCAmelCase__ ): if p < 2: raise ValueError('p should not be less than 2!' ) elif p == 2: return True lowerCAmelCase__ = 4 lowerCAmelCase__ = (1 << p) - 1 for _ in range(p - 2 ): ...
370
import copy from dataclasses import dataclass from pathlib import Path from typing import Dict, Optional, Union @dataclass class a_ : '''simple docstring''' UpperCAmelCase_ = None UpperCAmelCase_ = False UpperCAmelCase_ = False UpperCAmelCase_ = False UpperCAmelCase_ ...
119
0
'''simple docstring''' import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_com...
93
'''simple docstring''' import torch from transformers import AutoModel class lowerCAmelCase__ ( torch.nn.Module ): def __init__( self , __SCREAMING_SNAKE_CASE="sayef/fsner-bert-base-uncased" ): """simple docstring""" ...
93
1
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import is_xformers_available...
360
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATURE_EXT...
169
0
import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() A__ = logging.get_logger...
82
'''simple docstring''' import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class a__( enum.En...
272
0
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): __UpperCAmelCase : Optional[int] = len(_UpperCAmelCase ) for i in range(1, _UpperCAmelCase ): __UpperCAmelCase : int = collection[i] __UpperCAmelCase : Optional[int] ...
37
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig 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_configurat...
37
1
'''simple docstring''' import qiskit def _A (lowerCAmelCase__ :int , lowerCAmelCase__ :int ) -> qiskit.result.counts.Counts: '''simple docstring''' _a = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum ...
168
'''simple docstring''' import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModel...
168
1
import os import tempfile import unittest from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter from transformers.testing_utils import slow from transformers.utils import cached_property @unittest.skipUnless(os.path.exists(UpperCAmelCase_ ) , 'Tatoeba d...
367
from __future__ import annotations def __UpperCamelCase ( _A ): lowerCAmelCase_ = len(_A ) # We need to create solution object to save path. lowerCAmelCase_ = [[0 for _ in range(_A )] for _ in range(_A )] lowerCAmelCase_ = run_maze(_A , 0 , ...
167
0
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def UpperCAmelCase ( a_ ...
15
import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu __UpperCAmelCase = get_tests_...
119
0
import unittest import numpy as np from transformers import AlbertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as ...
355
import sacrebleu as scb from packaging import version from sacrebleu import TER import datasets SCREAMING_SNAKE_CASE :Optional[int] = """\ @inproceedings{snover-etal-2006-study, title = \"A Study of Translation Edit Rate with Targeted Human Annotation\", author = \"Snover, Matthew...
60
0
'''simple docstring''' import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot fro...
28
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class _UpperCamelCase ( lowerCAmelCase ): UpperCAme...
169
0
def __lowerCamelCase ( __magic_name__ : int , __magic_name__ : int ): if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) a__: int =str(bin(__a ) )[2:] # remove the leading "0b" a__: Optional[int] =s...
365
from __future__ import annotations from math import gcd def __lowerCamelCase ( __magic_name__ : int , __magic_name__ : int = 2 , __magic_name__ : int = 1 , __magic_name__ : int = 3 , ): # A value less than 2 can cause an infinite loop in the algorithm. ...
42
0
'''simple docstring''' import json import os import re import sys import urllib.request import requests from bsa import BeautifulSoup _lowerCAmelCase = { '''User-Agent''': '''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36''' ''' (KHTML, like Gecko) Chrome/70.0.3538.102 Safari...
37
'''simple docstring''' # coding=utf-8 # Copyright 2020 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 #...
37
1
"""simple docstring""" import multiprocessing import time from arguments import PretokenizationArguments from datasets import load_dataset from transformers import AutoTokenizer, HfArgumentParser def lowercase (SCREAMING_SNAKE_CASE_ : str ) -> List[str]: SCREAMING_SNAKE_CASE ...
358
"""simple docstring""" import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils i...
38
0
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device from dif...
101
"""simple docstring""" from manim import * class lowercase ( __UpperCAmelCase): def a_ ( self : int ): """simple docstring""" A_ : List[str] = Rectangle(height=0.5 , width=0.5 ) A_ : List[Any] ...
167
0
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( lowercase__ ): """simple docstring""" if num < 0: return False A = num A = 0 while num > 0: A = rev_num * 10 + (num % 10) num //= 10 return num_copy == rev_num if ...
359
"""simple docstring""" import json import os import unittest from typing import Tuple from transformers import WavaVecaPhonemeCTCTokenizer from transformers.models.wavaveca.tokenization_wavaveca import VOCAB_FILES_NAMES from transformers.models.wavaveca_phoneme.tokenization_wavaveca_phoneme import WavaVecaPhonem...
57
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging a = logging.get_logger(__name__) a = { '''edbeeching/decision-transformer-gym-hopper-medium''': ( '''https://huggingface.co/edbeeching/decision-transformer...
155
"""simple docstring""" def _snake_case ( _snake_case : int ): if not isinstance(_snake_case , _snake_case ): raise TypeError('''only integers accepted as input''' ) else: lowerCAmelCase : List[str] = str(abs(_snake_case ) ) lowerCAmelC...
60
0
import unittest from dataclasses import dataclass import pytest from accelerate.commands.config.config_args import SageMakerConfig from accelerate.utils import ComputeEnvironment from accelerate.utils.launch import _convert_nargs_to_dict @dataclass class UpperCAmelCase_ ( SCREAMING_SNAKE_CASE__ )...
368
import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def lowerCAmelCase__ ( _a : str ): snake_case_ : str = FileLock(str(tmpdir / "foo.lock" ) ) snake_case_ : Optional[Any] = FileLock(str(tmpdir / "foo.lock" ...
36
0
from transformers import BertTokenizer, EncoderDecoderModel, SeqaSeqTrainer, SeqaSeqTrainingArguments from transformers.testing_utils import TestCasePlus, require_torch, slow from transformers.utils import is_datasets_available if is_datasets_available(): import datasets class UpperCamelCase_ ( UpperC...
14
'''simple docstring''' import argparse import intel_extension_for_pytorch as ipex import torch from diffusers import DPMSolverMultistepScheduler, StableDiffusionPipeline lowercase : Optional[Any] = argparse.ArgumentParser("Stable Diffusion script with intel optimization", add_help=False) p...
42
0
import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py _lowerCamelCase : Optional[int] = '''\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, title = {BLEU: a...
130
from __future__ import annotations _lowerCamelCase : Optional[Any] = [-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0] _lowerCamelCase : Optional[int] = [-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1] def a_ ( __lowercase : list[float] ) -> ...
130
1
import json import os import tempfile from unittest.mock import patch import torch from torch.utils.data import DataLoader, TensorDataset from accelerate import DistributedType, infer_auto_device_map, init_empty_weights from accelerate.accelerator import Accelerator from accelerate.state impor...
29
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...utils.du...
38
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/vit-base-patch16-224"...
20
import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import AutoProcessor from transformers.models.wavaveca imp...
20
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available _UpperCAmelCase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: _UpperCAmelCas...
140
"""simple docstring""" def _lowerCamelCase ( ): '''simple docstring''' __lowerCAmelCase = [] __lowerCAmelCase = 1 while len(_UpperCamelCase ) < 1e6: constant.append(str(_UpperCamelCase ) ) i += 1 __lowerCAmelCase = "".join(_UpperCamelCase...
57
0
import warnings from contextlib import contextmanager from ....processing_utils import ProcessorMixin class UpperCAmelCase ( __A ): '''simple docstring''' lowerCamelCase_ = '''MCTCTFeatureExtractor''' lowerCamelCase_ = '''AutoTokenizer''' def __init__( ...
192
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() ...
192
1