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
'''simple docstring''' from math import isqrt, loga def __snake_case ( UpperCAmelCase_ : int ): lowerCamelCase_ = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: for j in range(i**2 , UpperCAmelCase_ , ...
675
'''simple docstring''' def __snake_case ( UpperCAmelCase_ : str ): lowerCamelCase_ = "" 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 __snake_case ( UpperCAmelCase_ : str ): lowerCamelCase_ ...
675
1
"""simple docstring""" import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @d...
718
"""simple docstring""" from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def lowerCAmelCase__ ( ) -> Optional[Any]: import os as original_os from os import path as original_path from os import rename as original_rename ...
109
0
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging lowercase__ =logging.get_logger(__name__) # TODO: upload to AWS lowercase__ ={ 'yjernite/retribert-base-uncased': ( 'https://huggingface.co/yjernite/retribert-base-uncased/resolv...
263
'''simple docstring''' import comet # From: unbabel-comet import torch import datasets lowercase__ =datasets.logging.get_logger(__name__) lowercase__ ='\\n@inproceedings{rei-EtAl:2020:WMT,\n author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon},\n title ...
263
1
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCAmelCase_ ( __snake_case ): '''simple docstring''' _lowercase : int = ['''image_processor''', '''tokenizer'''] _lowercase : ...
702
'''simple docstring''' def A (__lowerCamelCase :int ): if not isinstance(__lowerCamelCase , __lowerCamelCase ): raise ValueError("""Input must be an integer""" ) if input_num <= 0: raise ValueError("""Input must be positive""" ) return sum( divisor for di...
162
0
import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def lowercase ( _a ) -> List[Any]: UpperCAmelCase_: Dict = [ "encoder.version", "decoder.version", "model.encoder.version", "model.dec...
137
from math import pi def lowercase ( _a ,_a ) -> float: return 2 * pi * radius * (angle / 360) if __name__ == "__main__": print(arc_length(90, 10))
137
1
from __future__ import annotations import unittest from transformers import DebertaVaConfig, 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...
206
def __lowerCAmelCase ( __magic_name__ , __magic_name__ ): return abs(__magic_name__ ) if a == 0 else greatest_common_divisor(b % a , __magic_name__ ) def __lowerCAmelCase ( __magic_name__ , __magic_name__ ): while y: # --> when y=0 then loop will terminate and retu...
206
1
import argparse from collections import defaultdict def lowerCAmelCase_ ( _SCREAMING_SNAKE_CASE : Union[str, Any] , _SCREAMING_SNAKE_CASE : List[Any] , _SCREAMING_SNAKE_CASE : List[Any] , _SCREAMING_SNAKE_CASE : Optional[int] , _SCREAMING_SNAKE_CASE : Any )...
635
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available SCREAMING_SNAKE_CASE : Union[str, Any] = { "configuration_bridgetower": [ "BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP", "BridgeTowerConfig...
635
1
import logging import os import quant_trainer import torch from torch.utils.data import DataLoader from transformers import Trainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput lowerCamelCase :Optional[Any] = logging.getLogger(__name__) if is_torch_tpu_av...
346
import argparse import glob import logging import os import time from argparse import Namespace import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from torch.utils.data import DataLoader, TensorDataset from transformers import glue_compute_metri...
346
1
from __future__ import annotations import copy import inspect import unittest import numpy as np from transformers import is_tf_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_tf, slow from transformers.utils import cached_prope...
197
'''simple docstring''' import socket def __snake_case ( ): snake_case_ = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) snake_case_ = socket.gethostname() snake_case_ = 12_312 sock.connect((host, port) ) sock.send(b"Hello server!" ) with ope...
508
0
"""simple docstring""" import unittest from parameterized import parameterized from transformers import OpenLlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configura...
500
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : list ): if len(UpperCAmelCase_ ) <= 1: return lst A__ = 1 while i < len(UpperCAmelCase_ ): if lst[i - 1] <= lst[i]: i += 1 else: A__ ...
500
1
import unittest from transformers import PegasusTokenizer, PegasusTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin a_ ...
175
import os import sys import unittest a_ = 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 import create_dummy_files, create_dummy_object, find_backend, read_in...
175
1
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, require_torch, slo...
712
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(a ) , """Tatoeba direc...
647
0
import copy import tempfile import unittest from transformers import MaMaaaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from transformers.utils import cached_property from ...generation.test_utils import GenerationTes...
457
'''simple docstring''' from __future__ import annotations from collections.abc import Iterator from typing import Any class snake_case : """simple docstring""" def __init__( self , lowerCamelCase ) -> int: """simple docstring""" snake_case__ : Any ...
261
0
def snake_case (__lowercase , __lowercase ) -> int: '''simple docstring''' while a != 0: _snake_case ,_snake_case : Tuple = b % a, a return b def snake_case (__lowercase , __lowercase ) -> int: '''simple docstring''' if...
580
import asyncio import os import shutil import subprocess import sys import tempfile import unittest from distutils.util import strtobool from functools import partial from pathlib import Path from typing import List, Union from unittest import mock import torch from ..state import AcceleratorState, PartialState from ...
580
1
import dataclasses import json import warnings from dataclasses import dataclass, field from time import time from typing import List from ..utils import logging __lowerCamelCase : str = logging.get_logger(__name__) def SCREAMING_SNAKE_CASE__ ( snake_case_=None, ...
416
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_to...
316
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, ...
525
import unittest from transformers import AutoTokenizer, is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, slow if is_flax_available(): import jax.numpy as jnp from transformers import FlaxXLMRobertaModel @require_sentencepiece @require_t...
525
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 applicab...
513
import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( MaxLengthCriteria, MaxNewToke...
513
1
import os import sys import unittest SCREAMING_SNAKE_CASE_:Any = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, """utils""")) import get_test_info # noqa: E402 from get_test_info import ( # noqa: E402 get_model_to_test_mapping, ...
520
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available SCREAMING_SNAKE_CASE_:Optional[int] = {"""configuration_swin""": ["""SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SwinConfig""", """SwinOnnxConfig"""]} try: if not is_tor...
520
1
def lowerCamelCase__ ( lowercase ): """simple docstring""" if bit_count < 0: raise ValueError("The given input must be positive" ) # get the generated string sequence SCREAMING_SNAKE_CASE : Optional[int] = gray_code_sequence_string(lowercase ) # # c...
62
# 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 required ...
62
1
# 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, ) from...
252
def snake_case__ ( lowerCAmelCase_ = 1000000 ): """simple docstring""" SCREAMING_SNAKE_CASE =limit + 1 SCREAMING_SNAKE_CASE =[0] * limit for first_term in range(1, lowerCAmelCase_ ): for n in range(lowerCAmelCase_, lowerCAmelCase_, lowe...
252
1
'''simple docstring''' __UpperCAmelCase = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" __Uppe...
329
'''simple docstring''' 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 ...
329
1
"""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, load_image,...
147
"""simple docstring""" import os import unittest from transformers import LayoutLMTokenizer, LayoutLMTokenizerFast from transformers.models.layoutlm.tokenization_layoutlm import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin ...
147
1
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ): lowerCamelCase_ = ("dense.weight", "attention.self.query", "...
463
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available __A ={ '''configuration_gpt_neo''': ['''GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoConfig''', '''GPTNeoOnnxConfig'''], } try: if not is_torch_available(): ...
463
1
from __future__ import annotations class snake_case__ : '''simple docstring''' def __init__( self , a__ , a__ ) -> Union[str, Any]: '''simple docstring''' __snake_case , __snake_case :...
291
import unittest from transformers import ( MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING, Pipeline, ZeroShotClassificationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, nested_simplify, require_tf, requ...
291
1
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": A__ = '''%20'''.join(argv[1:]) if len(argv) > 1 else quote(str(input('''Search: '''))) print...
252
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_convbert import ConvBertTokenizer A__ = logging.get_logger(__name__) A__ = {'''v...
252
1
from collections import namedtuple import requests from lxml import html # type: ignore __A = namedtuple("covid_data", "cases deaths recovered") def lowerCamelCase_ ( UpperCamelCase__ : str = "https://www.worldometers.info/coronavirus/" ) -> covid_data: ...
716
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def lowerCamelCase_ ( UpperCamelCase__ : Optional[Any] ) ->...
167
0
from ..utils import DummyObject, requires_backends class __UpperCamelCase ( metaclass=A__ ): __A : Optional[Any] = ["""flax""", """transformers"""] def __init__( self , *_UpperCamelCase , **_UpperCamelCase ): requires_backends(self ...
32
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) ...
32
1
import json import os from functools import lru_cache from typing import TYPE_CHECKING, List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conv...
409
def a ( snake_case__: int ): '''simple docstring''' lowercase_ = [0] * len(snake_case__ ) lowercase_ = [] lowercase_ = [] lowercase_ = 0 for values in graph.values(): for i in values: ...
409
1
'''simple docstring''' import numpy as np import torch from torch.utils.data import Dataset from utils import logger class UpperCamelCase_ ( A ): """simple docstring""" def __init__( self : Any , _lowerCamelCase : int , _lowerCamelCase ...
664
'''simple docstring''' import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_...
664
1
from typing import Any, Dict, List, Optional, Tuple, Union import torch from torch import nn from torch.utils.data import DistributedSampler, RandomSampler from transformers import PreTrainedModel, Trainer, logging from transformers.integrations import is_fairscale_available from transformers.models.fsmt.conf...
719
"""simple docstring""" import json import sys import tempfile import unittest from pathlib import Path import transformers from transformers import ( CONFIG_MAPPING, IMAGE_PROCESSOR_MAPPING, AutoConfig, AutoImageProcessor, CLIPConfig, CLIPImageProcessor, ) from transformers....
173
0
import json import os from typing import Dict, List, Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase : Tuple = logging.get_logger(__name__) lowercase : str = { """vocab_file""": """vocab.json""", ...
568
import os import sys lowerCamelCase__ : Optional[int] = os.path.join(os.path.dirname(__file__), """src""") sys.path.append(SRC_DIR) from transformers import ( AutoConfig, AutoModel, AutoModelForCausalLM, AutoModelForMaskedLM, AutoModelForQuestionAnswering...
33
0
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def lowerCamelCase__ ( _A ): '''simple docstring''' snake_case_ = os.path.join(args.tf_model_dir , "parameters.json" ...
139
import unittest from parameterized import parameterized from transformers import LlamaConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import Con...
139
1
import inspect import os import torch from transformers import AutoModel from transformers.testing_utils import mockenv_context from transformers.trainer_utils import set_seed import accelerate from accelerate.accelerator import Accelerator from accelerate.state import AcceleratorState from accelerate.test_util...
6
def A_ ( a ): """simple docstring""" if p < 2: raise ValueError('p should not be less than 2!' ) elif p == 2: return True SCREAMING_SNAKE_CASE_ : Tuple = 4 SCREAMING_SNAKE_CASE_ : List[str] = (1 << p) - 1 for _ in ran...
511
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = ...
523
"""simple docstring""" from math import isqrt def __UpperCAmelCase ( __UpperCamelCase ): return all(number % divisor != 0 for divisor in range(2 , isqrt(__UpperCamelCase ) + 1 ) ) def __UpperCAmelCase ( __UpperCamelCase = 10**6 ): __...
523
1
'''simple docstring''' from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCamelCase =logging.get_logger(__name__) UpperCamelCase ={ "CarlCochet/trajectory-transformer-halfcheetah-medium-v2": ( "https://huggingface.co/CarlCochet/trajectory-t...
208
'''simple docstring''' from transformers import DistilBertTokenizer, DistilBertTokenizerFast from transformers.testing_utils import require_tokenizers, slow from ..bert.test_tokenization_bert import BertTokenizationTest @require_tokenizers class A ( SCREAMING_SNAKE_CASE__ ): """simple ...
208
1
import unittest from transformers import XLMConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, i...
26
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before to...
26
1
"""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 ...
223
"""simple docstring""" import inspect import os import re from transformers.configuration_utils import PretrainedConfig from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python util...
223
1
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_torch, requi...
701
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, require_tf, ...
82
0
from __future__ import annotations from typing import Any class _SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__( self : Optional[Any] , __lowerCamelCase : str ): SCREAMING_SNAKE_CASE = num_of_nodes SCREAMIN...
16
'''simple docstring''' import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transformers.u...
679
0
'''simple docstring''' from sklearn.metrics import fa_score import datasets SCREAMING_SNAKE_CASE__ = """ The F1 score is the harmonic mean of the precision and recall. It can be computed with the equation: F1 = 2 * (precision * recall) / (precision + recall) """ SCREAMING_SNAKE_CASE__ = ...
704
import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelT...
601
0
import math def A ( __UpperCamelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes return False # All primes number ...
9
from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand __A = logging.get_logger(__name__) # pylint: disable=invalid-name def lowerCa...
469
0
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_diffusion import LearnedClassifierFreeSamp...
705
import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import NestedDataStructureLike, PathL...
501
0
import os import unittest from transformers import LxmertTokenizer, LxmertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class l...
471
"""simple docstring""" def __lowercase ( snake_case_ : int ) ->int: '''simple docstring''' __A : str = 1 for i in range(1 ,num + 1 ): fact *= i return fact def __lowercase ( snake_case_ : int ) ->int: '''simple do...
177
0
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 SCREAMING_SNAKE_CASE__ = "." # Internal TensorFlow ops that can be ...
712
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder import ...
140
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_flax, require_tf, require_torch from transformers.utils import ( expand_dims, flatten_dict, is_flax_available, is_tf_available, is_torch_available, reshape, squeeze, tra...
34
def __snake_case ( ) -> int: return 1 def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def __snake_case ( lowerCAmelCase_ ) -> int: return 0 if x < 0 else five_pence(x - 5 ) +...
100
0
from __future__ import annotations def A__ ( __lowerCamelCase ): if not nums: raise ValueError('''List is empty''' ) return sum(__lowerCamelCase ) / len(__lowerCamelCase ) if __name__ == "__main__": import doctest doctest.testmod()
597
import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_simplify, require_tf, ...
597
1
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 lowerCamelCase( a__ ,a__ ,a__ ...
691
import requests from bsa import BeautifulSoup def lowerCamelCase( a__ = "https://www.worldometers.info/coronavirus"): _SCREAMING_SNAKE_CASE =BeautifulSoup(requests.get(a__).text ,'''html.parser''') _SCREAMING_SNAKE_CASE =soup.findAll('''h1''') _SCREAMING_SNAKE_CASE =soup...
691
1
"""simple docstring""" import unittest import numpy as np import torch from .utils_summarization import build_mask, compute_token_type_ids, process_story, truncate_or_pad class lowerCAmelCase__ ( unittest.TestCase ): def lowercase ( self : List[str] ...
718
"""simple docstring""" from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class lowerCAmelCase__ : __a = 42 __a...
430
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase__ : List[Any] = { 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig', ], 'feature_ex...
410
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCAmelCase : Optional[int] = logging.get_logger(__name__) lowerCAmelCase : List[Any] = { 'xlm-mlm-en-2048': 'https://hu...
511
0
from __future__ import annotations import math def _snake_case ( SCREAMING_SNAKE_CASE ) -> list[int]: """simple docstring""" if num <= 0: _lowerCAmelCase : Union[str, Any] = f'''{num}: Invalid input, please enter a positive integer.''' r...
503
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin __UpperCAmelCase = '\nHugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers....
503
1
import argparse import os import re import packaging.version __lowercase : Tuple ="""examples/""" __lowercase : Optional[Any] ={ """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), """init""": (re.c...
54
import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase_ = logging.get_logger(__name__) lowerCAmelCase_ = { 'facebook/encodec_24khz': 'https://huggingface.co/facebook/enc...
217
0
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaProcessor, logging, ) from trans...
700
from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_xpu, requi...
638
0
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 lowerCamelCase( ...
27
"""simple docstring""" import sys _snake_case = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' ...
580
0
'''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, ...
713
'''simple docstring''' import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import BatchEncoding, MarianTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, slow from transformers.utils import is_sen...
631
0
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration __lowerCamelCase : int = { 'tiny.en': 'https://openaipublic.azureedge.net/main/whisper/models/d3dd...
297
from itertools import count def UpperCamelCase__ ( _A: int = 50 ): '''simple docstring''' __lowerCamelCase = [1] * min_block_length for n in count(_A ): fill_count_functions.append(1 ) for block_length in range(_A , ...
479
0
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, ...
443
def SCREAMING_SNAKE_CASE_ ( __A : int , __A : int , __A : int ) -> float: """simple docstring""" a_ : Optional[int] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series ...
443
1
import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": a_ = """%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """))) print("""Googling...
221
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, is_vision_available from .....
221
1
import inspect import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_config_docstrings.py __UpperCAmelCase = """src/transformers""" # This is to make sure the trans...
582
from argparse import ArgumentParser from datasets.commands.convert import ConvertCommand from datasets.commands.dummy_data import DummyDataCommand from datasets.commands.env import EnvironmentCommand from datasets.commands.run_beam import RunBeamCommand from datasets.commands.test import TestCommand from datasets.u...
582
1
'''simple docstring''' import gc import unittest from transformers import MODEL_FOR_MASKED_LM_MAPPING, TF_MODEL_FOR_MASKED_LM_MAPPING, FillMaskPipeline, pipeline from transformers.pipelines import PipelineException from transformers.testing_utils import ( is_pipeline_test, is_torch_available, nested_s...
538
'''simple docstring''' import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def a ( UpperCamelCase_ : Any ) -> List[str]: snake_case__ =os.path.join(args.tf_model_dir , 'parameters.json' ) ...
538
1
"""simple docstring""" import copy import fnmatch import json import os import pickle as pkl import shutil import sys import tarfile import tempfile from collections import OrderedDict from contextlib import contextmanager from functools import partial from hashlib import shaaaa from io import Byt...
713
"""simple docstring""" import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...
19
0
from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand UpperCamelCase = logging.get_logger(__name__) # pylint: disable=invalid-name def _SCREAMING_SNAKE_CA...
590
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { """microsoft/trocr-base-handwritten""": ( """https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config...
590
1
def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ ) -> tuple[int, int]: try: lowerCAmelCase__ : Union[str, Any] = float(lowerCAmelCase__ ) except ValueError: raise ValueError('Please enter a valid number' ) lowerCAmelCase__ : int = decimal - int(lowerCAm...
721
import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class A__ ( __magic_name__ ): lowercase = (DDPMParallelScheduler,) def _lowerCamelCase ( self : str , **a : Optional[i...
69
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ = { 'configuration_maskformer': ['MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'MaskFormerConfig'], 'configuration_maskformer_swin': ['MaskForme...
496
"""simple docstring""" from heapq import heappop, heappush import numpy as np def snake_case__ ( _snake_case : np.ndarray , _snake_case : tuple[int, int] , _snake_case : tuple[int, int] , _snake_case : bool , ): ...
516
0
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE( UpperCamelCase ,UpperCamelCase ) -> str: if len(_lowerCamelCase ) < k or k < 0: raise ValueError('Invalid Input' ) UpperCAmelCase_ : int = sum(array[:k] ) for i in...
704
'''simple docstring''' import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple impo...
471
0
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2....
473
"""simple docstring""" UpperCamelCase = '0.18.2' from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_l...
473
1
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, AutoModelForMaskedLM, ...
710
import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from transformers import (...
322
0
import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp ...
443
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached_property ...
443
1
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transfo...
351
from itertools import zip_longest import requests from bsa import BeautifulSoup from pandas import DataFrame def A_ ( __a : str = "laptop" ): """simple docstring""" a__ = F'''https://www.amazon.in/laptop/s?k={product}''' a__ = { """User-Agent...
351
1
from typing import TYPE_CHECKING from ...utils import _LazyModule __lowercase : int ={"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys __...
54
import requests def _A( UpperCamelCase__ : str , UpperCamelCase__ : str ) -> None: '''simple docstring''' __lowercase = {'''Content-Type''': '''application/json'''} __lowercase = requests.post(UpperCamelCase__ , jso...
332
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_ava...
679
import inspect import unittest from transformers import MobileViTConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test_mo...
679
1
"""simple docstring""" A_ = "0.18.2" from .configuration_utils import ConfigMixin from .utils import ( OptionalDependencyNotAvailable, is_flax_available, is_inflect_available, is_invisible_watermark_available, is_k_diffusion_available, is_k_diffusion_version, is_libro...
391
from math import factorial def UpperCamelCase ( snake_case__ , snake_case__): # If either of the conditions are true, the function is being asked # to calculate a factorial of a negative number, which is not possible if n < k or k < 0: raise ValueError("Please enter pos...
659
0
from ...configuration_utils import PretrainedConfig from ...utils import logging snake_case = logging.get_logger(__name__) snake_case = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json" ), # See all Vivit models ...
587
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, ids_tensor, rando...
587
1
import os from collections import deque import torch from torch.utils.data import Dataset class __A( a ): def __init__( self , _snake_case="" , _snake_case="train" ) -> Union[str, Any]: '''simple docstring''' assert os.path.isdir(_snake_case ...
219
import os import warnings from typing import List, Optional from ...tokenization_utils_base import BatchEncoding from ...utils import logging from .configuration_rag import RagConfig A : Any = logging.get_logger(__name__) class __A: def __init__( self , _snake_case , _sn...
219
1
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class UpperCAmelCase__ ( nn.Module ): '''simple docstring''' def __init__( self : Optional[Any] , a_ : int = 16 , a_ ...
241
def a ( _UpperCAmelCase : int = 1 , _UpperCAmelCase : int = 10_00 ): '''simple docstring''' __UpperCAmelCase : List[str] = 1 __UpperCAmelCase : Dict = 0 for divide_by_number in range(_UpperCAmelCase , di...
241
1
"""simple docstring""" # Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def __lowercase ( snake_case_ : Optional[int] ) ->str: '''simple docstring''...
177
"""simple docstring""" import requests a_ = """https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=""" def __lowercase ( snake_case_ : str ) ->None: '''simple docstring''' __A : str = requests.get(_NEWS_API + bbc_news_api_key ).json()...
177
1
from __future__ import annotations import queue class __UpperCamelCase : """simple docstring""" def __init__( self : Optional[Any] , _A : Union[str, Any] ): """simple docstring""" __SCREAMING_SNAKE_CASE : List[str] =...
702
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTokenizer @require_torch @require_sentencepiece @requir...
131
0
"""simple docstring""" def a__ ( lowerCAmelCase__ = 50 ): UpperCAmelCase_ = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ): ...
82
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = { """camembert-base""": """https://hu...
451
0
'''simple docstring''' import itertools import random import unittest import numpy as np from transformers import BatchFeature, SpeechTaFeatureExtractor from transformers.testing_utils import require_torch from transformers.utils.import_utils import is_torch_available from ...test_sequence_feature_extractio...
420
'''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...
420
1
import random class lowercase : @staticmethod def __snake_case( _UpperCamelCase : str ) -> Optional[Any]: '''simple docstring''' SCREAMING_SNAKE_CASE = [ord(_lowerCamelCase ) for i in text] S...
403
"""simple docstring""" 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 __SCREAMING_SNAKE_CASE ...
357
0
'''simple docstring''' import os from datetime import datetime as dt from github import Github __snake_case : Dict = [ 'good first issue', 'feature request', 'wip', ] def _UpperCAmelCase ( ) -> Union[str, Any]: A_ = Github(os.environ['''G...
719
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusion...
174
0
'''simple docstring''' # We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('ignore', category=UserWarning, module='torch.optim.lr_scheduler') class A__ ...
494
'''simple docstring''' def __UpperCAmelCase ( a_: int, a_: int ): if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) _UpperCAmelCase : Any = str(bin(a_ ) )[2:] # remove the leading "0b" _UpperCAmelCase : Optional[Any] ...
494
1
import copy from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING _UpperCAmelCase : Optional[int] = logging.get_l...
704
import os from typing import BinaryIO, Optional, Union import numpy as np import pyarrow.parquet as pq from .. import Audio, Dataset, Features, Image, NamedSplit, Value, config from ..features.features import FeatureType, _visit from ..formatting import query_table from ..packaged_modules import _PACKAGED_DATASETS_...
108
0
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from sklearn.preproces...
425
"""simple docstring""" import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device __SCREAMING_SNAKE_CASE =False class UpperCamel...
425
1
def __snake_case ( _UpperCamelCase ) -> float: return 10 - x * x def __snake_case ( _UpperCamelCase , _UpperCamelCase ) -> float: # Bolzano theory in order to find if there is a root between a and b if equation(_UpperCamelCase ) * equation(_UpperCamelCase ) >= 0: r...
346
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipeline_test, ...
346
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 __UpperCamelCase : List[Any] = logging.get_logger(__name__) __UpperCamelCas...
468
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING __UpperCamelCase : Any = logging.get_logger(__name__) __UpperCamelCase : Tuple = { "SenseTime/deformable-detr": "https://huggingface.co/sen...
468
1
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( SwiftFormerConfig, SwiftFormerForImageClassification, ViTImageProcessor, ) from transformers.utils ...
707
"""simple docstring""" from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def __lowercase ( a : str ) -> None: __snake_case , __snake_case : List[Any] =analyze_text(a ) __snake_case : ...
497
0
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 : Tuple = {"configuration_xglm": ["XGLM_PRETRAINED...
193
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor __magic_name__ = logging.get_logger(__name__) class lowercase ( A__ ): '''simple docstring''' def __init__( self , *_snake_case...
254
0
from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCamelCase = logging.get_logger(__name__) class snake_case__ ( __snake_case , __snake_case ): _...
716
from datetime import datetime import requests from bsa import BeautifulSoup if __name__ == "__main__": lowerCamelCase : str = input('Enter image url: ').strip() print(F"""Downloading image from {url} ...""") lowerCamelCase : Optional[Any] = BeautifulSoup(requests.get(url).content, 'html....
303
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCAmelCase_ = { """configuration_mobilevit""": ["""MOBILEVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Mobi...
2
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) __snake_case : int = { """configuration_llama""": ["""LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Llam...
540
0
"""simple docstring""" from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_n...
579
"""simple docstring""" from timeit import timeit def A__ ( A__ ) -> int: '''simple docstring''' if number < 0: raise ValueError("the value of input must not be negative" ) _UpperCAmelCase = 0 while number: number &= number - 1 result += 1 ret...
579
1
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ = { 'huggingface/time-series-transformer-tourism-monthly': ( 'htt...
621
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
621
1
"""simple docstring""" import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import A...
22
"""simple docstring""" import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter _lowercase =...
22
1
"""simple docstring""" import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational ...
58
import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def __lowercase ( _UpperCamelCase, _UpperCamelCase, _UpperCamelCase ) ->Optional[int]: """s...
319
0
'''simple docstring''' _lowercase = [sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_00_00)] def lowerCamelCase__ ( a ): __snake_case = 0 while number: # Increased Speed Slightly by checking every 5 digits together. sum_of_digits_squar...
427
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( a , a ): print(f'Vertex\tShortest Distance from vertex {src}' ) for i, d in enumerate(a ): print(f'{i}\t\t{d}' ) def lowerCamelCase__ ( a , a ,...
427
1
def a ( ): '''simple docstring''' return 1 def a ( snake_case__: Optional[int] ): '''simple docstring''' return 0 if x < 0 else two_pence(x - 2 ) + one_pence() def a ( snake_case__: Optional[Any] ): '''simple docstring''...
97
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 SCREAMING_SNAKE_CASE_ : Union[str, Any] = '''http://www...
375
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_beit import BeitImageProcessor __A : str = logging.get_logger(__name__) class __UpperCamelCase ( lowercase__ ): def __init__( self :str ,*_UpperCamelCase :List[str] ,**_UpperC...
267
'''simple docstring''' import random from typing import Any def UpperCAmelCase ( lowerCamelCase_ :list ): '''simple docstring''' for _ in range(len(lowerCamelCase_ ) ): snake_case_ : Union[str, Any] = random.randint(0 , len(lowerCamelCase_ ) - 1 ) ...
267
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Union[str, Any] = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { "tanreinama/GPTSAN-2.8B-spout_is_uniform": ( "https://huggingface.co/tanreinama...
21
'''simple docstring''' def UpperCAmelCase_ ( __lowercase : int ) -> None: '''simple docstring''' _UpperCAmelCase = generate_pascal_triangle(__lowercase ) for row_idx in range(__lowercase ): # Print left spaces for _ in range(num_rows - ro...
236
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available UpperCAmelCase_ : Union[str, Any] = { 'configuration_gpt_neo': ['GPT_NEO_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPTNeoConfig', 'GPTNeoOnnxConfig'], } try: i...
718
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger UpperCAmelCase_ : int = get_logger(__name__) class lowercase__ ( enum.Enum ): __UpperCamelCase = """all_checks""" __UpperCamelCase ...
440
0
'''simple docstring''' import os import sys import tempfile import torch from .state import AcceleratorState from .utils import PrecisionType, PrepareForLaunch, is_mps_available, patch_environment def __lowerCamelCase ( __snake_case : Any, __snake_case : List[str]=(), __snake_case : ...
215
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import debug_launcher from accelerate.test_utils import ( execute_subprocess_async, require_cpu, require_huggingface_suite, require_multi_gpu, require_...
179
0
"""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 from...
715
"""simple docstring""" import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxrunt...
248
0