code
stringlengths
81
54k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
'''simple docstring''' import unittest from transformers import is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from tensorflow.python.eager import context from tensorflow.python.framework import ops from transformers import GradientAccumulat...
50
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _lowercase : str = logging.get_logger(__name_...
50
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase : Any = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try...
50
'''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 # # ...
50
1
'''simple docstring''' def lowerCamelCase__ ( ): '''simple docstring''' for n in range(1 , 1_00_00_00 ): yield n * (n + 1) // 2 def lowerCamelCase__ ( A : List[str] ): '''simple docstring''' UpperCAmelCase = 1 Upper...
50
'''simple docstring''' import functools def lowerCamelCase__ ( A : list[int] , A : list[int] ): '''simple docstring''' if not isinstance(A , A ) or not all(isinstance(A , A ) for day in days ): raise ValueError('''The parameter days shou...
50
1
'''simple docstring''' import argparse import os import re import packaging.version _lowercase : Optional[int] = """examples/""" _lowercase : str = { """examples""": (re.compile(r"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), ...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase : Any = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try...
50
1
'''simple docstring''' from dataclasses import asdict, dataclass from typing import Optional from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Union[str, Any] = logging.get_logger(__name__) # TODO Update this _lowercase : int = { """f...
50
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowerCamelCase__ ( A : Optional[Any] , A : Tuple=1 ): '''simple docstring''' if n_shave_prefix_segments >= 0: r...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : List[Any] ): '''simple docstring''' UpperCAmelCase = 1 UpperCAmelCase = 2 while i * i <= n: UpperCAmelCase = 0 while n % i == 0: n //= i ...
50
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Dict = { """facebook/dpr-ctx_encoder-single-nq-base""": ( """https://huggingface.co/facebook/dpr-ctx_encod...
50
1
'''simple docstring''' import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @require_optimum ...
50
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBe...
50
1
'''simple docstring''' import os import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from huggingface_hub.file_download import http_get from requests.exceptions import HTTPError from transformers import ( AlbertTo...
50
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase__( lowerCAmelCase ): __magic_name__ : Tuple = ["image_processor", "tokenizer"] __magic_name__ : Any = "ViT...
50
1
'''simple docstring''' import gc import random import tempfile import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, LMSDiscreteScheduler, PNDMScheduler, UNetaDConditionModel from diffusers.pipeli...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Any = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], ...
50
1
'''simple docstring''' from unittest.mock import patch import pyspark from datasets.packaged_modules.spark.spark import ( Spark, SparkExamplesIterable, _generate_iterable_examples, ) from ..utils import ( require_dill_gt_0_3_2, require_not_windows, ) def lowerCamelCase__ ( A : ...
50
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from acceler...
50
1
'''simple docstring''' import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( Autoencod...
50
'''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 # #...
50
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available, ) _lowercase : Tuple = { """configuration_perceiver""": ["""PERCEIVER_PRETRAINED_CO...
50
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase : List[str] = { """facebook/encodec_24khz""...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : List[Any] , A : Union[str, Any] ): '''simple docstring''' UpperCAmelCase = [0 for i in range(r + 1 )] # nc0 = 1 UpperCAmelCase = 1 for i in range(1 , n + 1 ): ...
50
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
50
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowercase : int = { """configuration_groupvit""": [ """GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GroupViTConfig"""...
50
'''simple docstring''' import heapq def lowerCamelCase__ ( A : dict ): '''simple docstring''' UpperCAmelCase = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Prior...
50
1
'''simple docstring''' import argparse from collections import defaultdict import yaml _lowercase : Dict = """docs/source/en/_toctree.yml""" def lowerCamelCase__ ( A : Any ): '''simple docstring''' UpperCAmelCase = defaultdict(A ) UpperCAmelCa...
50
'''simple docstring''' import argparse import os import re import packaging.version _lowercase : Optional[int] = """examples/""" _lowercase : str = { """examples""": (re.compile(r"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), ...
50
1
'''simple docstring''' import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def lowerCamelCase__ ( A : dict ): '''s...
50
'''simple docstring''' 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,...
50
1
'''simple docstring''' from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo _lowercase : List[str] = """\ @misc{wu2016googles, title={Google's Neural Machine Translation System: Bridging the Gap between Human and Machine Transl...
50
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase__( metaclass=lowerCAmelCase ): __magic_name__ : List[str] = ["note_seq"] def __init__( self : Any , *lowerCAmelCase : List[str] , **lowerCAmelCase : int...
50
1
'''simple docstring''' import sys import webbrowser import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": print("""Googling.....""") _lowercase : List[Any] = """https://www.google.com/search?q=""" + """ """.join(sys.argv[1:]) _lowercase ...
50
'''simple docstring''' import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase__ ( A : List[Any] , A : int , A ...
50
1
'''simple docstring''' import math def lowerCamelCase__ ( A : int ): '''simple docstring''' UpperCAmelCase = [True] * n UpperCAmelCase = False UpperCAmelCase = False UpperCAmelCase = True for i in range(3 , ...
50
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class UpperCamelCase__( unittest.TestCase ): ...
50
1
'''simple docstring''' from functools import lru_cache @lru_cache def lowerCamelCase__ ( A : int ): '''simple docstring''' if num < 0: raise ValueError('''Number should not be negative.''' ) return 1 if num in (0, 1) else num * factorial(num - 1 ) if __n...
50
'''simple docstring''' from argparse import ArgumentParser from . import BaseTransformersCLICommand def lowerCamelCase__ ( A : List[Any] ): '''simple docstring''' return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) ...
50
1
'''simple docstring''' 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,...
50
'''simple docstring''' def lowerCamelCase__ ( A : str ): '''simple docstring''' assert column_title.isupper() UpperCAmelCase = 0 UpperCAmelCase = len(A ) - 1 UpperCAmelCase = 0 while index >= 0: UpperCAmelCase ...
50
1
'''simple docstring''' # This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def lowerCamelCase__ ( A : Op...
50
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling...
50
1
'''simple docstring''' from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor _lowercase : ...
50
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _lowercase : str = logging.get_logger(__name_...
50
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[Any] = { """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/m...
50
'''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 # # ...
50
1
'''simple docstring''' import argparse import random import joblib import numpy as np import torch from igf.igf import ( SecondaryLearner, collect_objective_set, compute_perplexity, generate_datasets, load_gpta, recopy_gpta, set_seed, train_secondary_learner, ) from torch.utils.da...
50
'''simple docstring''' import functools def lowerCamelCase__ ( A : list[int] , A : list[int] ): '''simple docstring''' if not isinstance(A , A ) or not all(isinstance(A , A ) for day in days ): raise ValueError('''The parameter days shou...
50
1
'''simple docstring''' from collections.abc import Generator def lowerCamelCase__ ( ): '''simple docstring''' UpperCAmelCase , UpperCAmelCase = 0, 1 while True: UpperCAmelCase , UpperCAmelCase = b, a + b yield b...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase : Any = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try...
50
1
'''simple docstring''' import re import string import numpy as np import datasets _lowercase : List[str] = """ Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list. """ _lowercase : str ...
50
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowerCamelCase__ ( A : Optional[Any] , A : Tuple=1 ): '''simple docstring''' if n_shave_prefix_segments >= 0: r...
50
1
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( A : int ): '''simple docstring''' UpperCAmelCase = 2 UpperCAmelCase = [] while i * i <= n: if n % i: i += 1 else: ...
50
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Dict = { """facebook/dpr-ctx_encoder-single-nq-base""": ( """https://huggingface.co/facebook/dpr-ctx_encod...
50
1
'''simple docstring''' from functools import reduce _lowercase : int = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """125406987471585238630507156932909632...
50
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBe...
50
1
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase__( metaclass=lowerCAmelCase ): __magic_name__ : int = ["torch", "transformers", "onnx"] def __init__( self : int , *lowerCAmelCase : Any , **lowerCAmelCase ...
50
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase__( lowerCAmelCase ): __magic_name__ : Tuple = ["image_processor", "tokenizer"] __magic_name__ : Any = "ViT...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : int ): '''simple docstring''' UpperCAmelCase = int(A ) if decimal in (0, 1): # Exit cases for the recursion return str(A ) UpperCAmelCase , UpperCAmelCase = divmod(A , ...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Any = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], ...
50
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available _lowercase : List[str] = {"""tokenization_herbert""": ["""HerbertTokenizer"""]} try: if not is_tokenizers_available(): raise OptionalDependencyNotA...
50
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from acceler...
50
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 UpperCamelCase__( unittest.TestCase ): def a__( self : Optional[int] )-> List[Any]: """simple ...
50
'''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 # #...
50
1
'''simple docstring''' import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() _lowercase : int = [ """word...
50
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase : List[str] = { """facebook/encodec_24khz""...
50
1
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings _lowercase : Optional[int] = r""" [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and can be use...
50
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
50
1
'''simple docstring''' import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) _lowercase : Any = pytest.mark.integration @pytest.mark.parametrize(''...
50
'''simple docstring''' import heapq def lowerCamelCase__ ( A : dict ): '''simple docstring''' UpperCAmelCase = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Prior...
50
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowercase : str = { """configuration_canine""": ["""CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """CanineConfig"""], """token...
50
'''simple docstring''' import argparse import os import re import packaging.version _lowercase : Optional[int] = """examples/""" _lowercase : str = { """examples""": (re.compile(r"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), ...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : str ): '''simple docstring''' if n_term == "": return [] UpperCAmelCase = [] for temp in range(int(A ) ): series.append(f"""1/{temp + 1}""" if series else '''1''' ) return se...
50
'''simple docstring''' 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,...
50
1
'''simple docstring''' from __future__ import annotations from scipy.special import comb # type: ignore class UpperCamelCase__: def __init__( self : Union[str, Any] , lowerCAmelCase : list[tuple[float, float]] )-> Any: """simple docstring""" UpperCAme...
50
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase__( metaclass=lowerCAmelCase ): __magic_name__ : List[str] = ["note_seq"] def __init__( self : Any , *lowerCAmelCase : List[str] , **lowerCAmelCase : int...
50
1
'''simple docstring''' from statistics import mean import numpy as np def lowerCamelCase__ ( A : list , A : list , A : list , A : int ): '''simple docstring''' UpperCAmelCase = 0 # Number of processes finished Upper...
50
'''simple docstring''' import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase__ ( A : List[Any] , A : int , A ...
50
1
'''simple docstring''' import socket def lowerCamelCase__ ( ): '''simple docstring''' UpperCAmelCase = socket.socket(socket.AF_INET , socket.SOCK_STREAM ) UpperCAmelCase = socket.gethostname() UpperCAmelCase = 1_23_12 sock.connec...
50
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class UpperCamelCase__( unittest.TestCase ): ...
50
1
'''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 TokenizerTest...
50
'''simple docstring''' from argparse import ArgumentParser from . import BaseTransformersCLICommand def lowerCamelCase__ ( A : List[Any] ): '''simple docstring''' return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) ...
50
1
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling...
50
'''simple docstring''' def lowerCamelCase__ ( A : str ): '''simple docstring''' assert column_title.isupper() UpperCAmelCase = 0 UpperCAmelCase = len(A ) - 1 UpperCAmelCase = 0 while index >= 0: UpperCAmelCase ...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : list[int] ): '''simple docstring''' UpperCAmelCase = [] if len(A ) == 1: return [nums.copy()] for _ in range(len(A ) ): UpperCAmelCase = nums.pop(0 ) UpperCA...
50
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling...
50
1
'''simple docstring''' # This model implementation is heavily inspired by https://github.com/haofanwang/ControlNet-for-Diffusers/ import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer f...
50
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _lowercase : str = logging.get_logger(__name_...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : str ): '''simple docstring''' UpperCAmelCase = 0 # if input_string is "aba" than new_input_string become "a|b|a" UpperCAmelCase = '''''' UpperCAmelCase = '''''' # append eac...
50
'''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 # # ...
50
1
'''simple docstring''' import unittest import numpy as np import torch from diffusers import PNDMPipeline, PNDMScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class UpperCamelCase__( unittest.TestC...
50
'''simple docstring''' import functools def lowerCamelCase__ ( A : list[int] , A : list[int] ): '''simple docstring''' if not isinstance(A , A ) or not all(isinstance(A , A ) for day in days ): raise ValueError('''The parameter days shou...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : int , A : int ): '''simple docstring''' return numa ^ numa < 0 if __name__ == "__main__": import doctest doctest.testmod()
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase : Any = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try...
50
1
'''simple docstring''' from math import factorial def lowerCamelCase__ ( A : int = 20 ): '''simple docstring''' UpperCAmelCase = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... UpperCAmelCase = n // 2 ...
50
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowerCamelCase__ ( A : Optional[Any] , A : Tuple=1 ): '''simple docstring''' if n_shave_prefix_segments >= 0: r...
50
1
'''simple docstring''' 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 fro...
50
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Dict = { """facebook/dpr-ctx_encoder-single-nq-base""": ( """https://huggingface.co/facebook/dpr-ctx_encod...
50
1
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class UpperCamelCase__( lowerCAmelCase ): def __init__( self : Dict )-> Dict: """simple docstring""" self.test() def a__( self : Tuple )-> str: ...
50
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBe...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : str , A : str ): '''simple docstring''' if len(A ) != len(A ): raise ValueError('''String lengths must match!''' ) UpperCAmelCase = 0 for chara, chara in zip(A , A ): ...
50
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase__( lowerCAmelCase ): __magic_name__ : Tuple = ["image_processor", "tokenizer"] __magic_name__ : Any = "ViT...
50
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import numpy as np import tensorflow as tf from transformers import TF...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Any = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], ...
50
1
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging _l...
50
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from acceler...
50
1
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils ...
50
'''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 # #...
50
1
'''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 logging _lowerc...
50
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase : List[str] = { """facebook/encodec_24khz""...
50
1
'''simple docstring''' from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ...
50
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
50
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_squeezebert import SqueezeBertTokenizer _lowercase : str = logging.get_log...
50
'''simple docstring''' import heapq def lowerCamelCase__ ( A : dict ): '''simple docstring''' UpperCAmelCase = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Prior...
50
1
'''simple docstring''' import torch from diffusers import EulerDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class UpperCamelCase__( lowerCAmelCase ): __magic_name__ : Dict = (EulerDiscreteScheduler,) __magic_name__ ...
50
'''simple docstring''' import argparse import os import re import packaging.version _lowercase : Optional[int] = """examples/""" _lowercase : str = { """examples""": (re.compile(r"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), ...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : str , A : bool = False ): '''simple docstring''' if not isinstance(A , A ): UpperCAmelCase = f"""Expected string as input, found {type(A )}""" raise ValueError(A ) if ...
50
'''simple docstring''' 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,...
50
1
'''simple docstring''' import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration _lowercase : Optional[int] = [ # tf -> hf ("""/""", """."""), ("""layer_""",...
50
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase__( metaclass=lowerCAmelCase ): __magic_name__ : List[str] = ["note_seq"] def __init__( self : Any , *lowerCAmelCase : List[str] , **lowerCAmelCase : int...
50
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase : Tuple = { """facebook/s2t-small-librispeech-asr""": ( """https://huggingface.co/facebook/s2t-s...
50
'''simple docstring''' import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase__ ( A : List[Any] , A : int , A ...
50
1
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase__( lowerCAmelCase ): __magic_name__ : Tuple = ["image_processor", "tokenizer"] __magic_name__ : Any = "ViT...
50
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class UpperCamelCase__( unittest.TestCase ): ...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : int , A : int ): '''simple docstring''' return number | (1 << position) def lowerCamelCase__ ( A : int , A : int ): '''simple docstring''' return number & ~(1 << posi...
50
'''simple docstring''' from argparse import ArgumentParser from . import BaseTransformersCLICommand def lowerCamelCase__ ( A : List[Any] ): '''simple docstring''' return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) ...
50
1
'''simple docstring''' import os 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 _lowercase : Any = logging.get_logger(__name__) _lowercase ...
50
'''simple docstring''' def lowerCamelCase__ ( A : str ): '''simple docstring''' assert column_title.isupper() UpperCAmelCase = 0 UpperCAmelCase = len(A ) - 1 UpperCAmelCase = 0 while index >= 0: UpperCAmelCase ...
50
1
'''simple docstring''' import os import torch from ..logging import get_logger from .constants import FSDP_PYTORCH_VERSION, MODEL_NAME, OPTIMIZER_NAME from .versions import is_torch_version if is_torch_version(""">=""", FSDP_PYTORCH_VERSION): import torch.distributed.checkpoint as dist_cp from torch.distrib...
50
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling...
50
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-2....
50
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _lowercase : str = logging.get_logger(__name_...
50
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 ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassification, V...
50
'''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 # # ...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : int , A : int ): '''simple docstring''' return int((input_a, input_a).count(1 ) != 0 ) def lowerCamelCase__ ( ): '''simple docstring''' assert or_gate(0 , 0 ) == 0 assert o...
50
'''simple docstring''' import functools def lowerCamelCase__ ( A : list[int] , A : list[int] ): '''simple docstring''' if not isinstance(A , A ) or not all(isinstance(A , A ) for day in days ): raise ValueError('''The parameter days shou...
50
1
'''simple docstring''' import itertools from dataclasses import dataclass from typing import Any, Callable, Dict, List, Optional, Union import pandas as pd import pyarrow as pa import datasets import datasets.config from datasets.features.features import require_storage_cast from datasets.table import table_cas...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase : Any = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try...
50
1
'''simple docstring''' import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_avai...
50
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowerCamelCase__ ( A : Optional[Any] , A : Tuple=1 ): '''simple docstring''' if n_shave_prefix_segments >= 0: r...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : int ): '''simple docstring''' UpperCAmelCase = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def lowerCamelCase__ ( A : int = 50_00 ): '''simple docstring''' UpperCAmelC...
50
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Dict = { """facebook/dpr-ctx_encoder-single-nq-base""": ( """https://huggingface.co/facebook/dpr-ctx_encod...
50
1
'''simple docstring''' import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion....
50
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBe...
50
1
'''simple docstring''' from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configu...
50
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase__( lowerCAmelCase ): __magic_name__ : Tuple = ["image_processor", "tokenizer"] __magic_name__ : Any = "ViT...
50
1
'''simple docstring''' import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# _lowercase : List[Any] = [ # (stable-diffusion, HF Diffusers) ("""time_embed.0.weight""", "...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Any = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], ...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : list[int] , A : list[int] ): '''simple docstring''' UpperCAmelCase = len(A ) print('''The following activities are selected:''' ) # The first activity is always selected UpperCAmelCase ...
50
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from acceler...
50
1
'''simple docstring''' import requests from bsa import BeautifulSoup def lowerCamelCase__ ( A : str = "AAPL" ): '''simple docstring''' UpperCAmelCase = f"""https://in.finance.yahoo.com/quote/{symbol}?s={symbol}""" UpperCAmelCase = BeautifulSoup(reques...
50
'''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 # #...
50
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _lowercase : Dict = { """configuration_mvp""": ["""MVP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MvpConfig""", """MvpOnnxConfig"""],...
50
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase : List[str] = { """facebook/encodec_24khz""...
50
1
'''simple docstring''' from __future__ import annotations from PIL import Image # Define glider example _lowercase : Dict = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0,...
50
'''simple docstring''' # Copyright 2022 The HuggingFace Team and The OpenBMB Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
50
1
'''simple docstring''' from .imports import is_tqdm_available if is_tqdm_available(): from tqdm.auto import tqdm as _tqdm from ..state import PartialState def lowerCamelCase__ ( A : bool = True , *A : Tuple , **A : Tuple ): '''simple docstring''' ...
50
'''simple docstring''' import heapq def lowerCamelCase__ ( A : dict ): '''simple docstring''' UpperCAmelCase = [] # for each node and his adjacency list add them and the rank of the node to queue # using heapq module the queue will be filled like a Prior...
50
1
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class UpperCamelCase__( unittest.TestCase ): def a__( self : int )-> Union[str, Any]: """simple docstring""" UpperCAmelCase = [ ...
50
'''simple docstring''' import argparse import os import re import packaging.version _lowercase : Optional[int] = """examples/""" _lowercase : str = { """examples""": (re.compile(r"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), ...
50
1
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from acceler...
50
'''simple docstring''' 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,...
50
1
'''simple docstring''' import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_visio...
50
'''simple docstring''' from ..utils import DummyObject, requires_backends class UpperCamelCase__( metaclass=lowerCAmelCase ): __magic_name__ : List[str] = ["note_seq"] def __init__( self : Any , *lowerCAmelCase : List[str] , **lowerCAmelCase : int...
50
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Tuple = logging.get_logger(__name__) _lowercase : int = { """bigcode/gpt_bigcode-santacoder""": """https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/m...
50
'''simple docstring''' import argparse from transformers import BigBirdConfig, BigBirdForPreTraining, BigBirdForQuestionAnswering, load_tf_weights_in_big_bird from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase__ ( A : List[Any] , A : int , A ...
50
1
'''simple docstring''' import unittest import numpy as np from datasets import load_dataset from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, pre...
50
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.generation import DisjunctiveConstraint @require_torch class UpperCamelCase__( unittest.TestCase ): ...
50
1
'''simple docstring''' import collections import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_flax_cross_test, require_flax, require_torch, require_vision, slow, torch_device, ) from transformers.utils import is_flax_available, is_torch_avail...
50
'''simple docstring''' from argparse import ArgumentParser from . import BaseTransformersCLICommand def lowerCamelCase__ ( A : List[Any] ): '''simple docstring''' return DownloadCommand(args.model , args.cache_dir , args.force , args.trust_remote_code ) ...
50
1
'''simple docstring''' from __future__ import annotations from collections.abc import Generator def lowerCamelCase__ ( ): '''simple docstring''' UpperCAmelCase = {} UpperCAmelCase = 2 while True: UpperCAmelCase = factor_map.pop(A ...
50
'''simple docstring''' def lowerCamelCase__ ( A : str ): '''simple docstring''' assert column_title.isupper() UpperCAmelCase = 0 UpperCAmelCase = len(A ) - 1 UpperCAmelCase = 0 while index >= 0: UpperCAmelCase ...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : int ): '''simple docstring''' if number < 0: raise ValueError('''number must not be negative''' ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
50
'''simple docstring''' import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling...
50
1
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from u...
50
'''simple docstring''' import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, BatchEncoding, PreTrainedTokenizer from ...utils import logging _lowercase : str = logging.get_logger(__name_...
50
1
'''simple docstring''' import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transformers.generation import ( ...
50
'''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 # # ...
50
1
'''simple docstring''' import argparse import numpy as np import torch from transformers import SpeechTaHifiGan, SpeechTaHifiGanConfig, logging logging.set_verbosity_info() _lowercase : Optional[Any] = logging.get_logger("""transformers.models.speecht5""") def lowerCamelCase__ ( A : ...
50
'''simple docstring''' import functools def lowerCamelCase__ ( A : list[int] , A : list[int] ): '''simple docstring''' if not isinstance(A , A ) or not all(isinstance(A , A ) for day in days ): raise ValueError('''The parameter days shou...
50
1
'''simple docstring''' import torch from diffusers import DiffusionPipeline class UpperCamelCase__( lowerCAmelCase ): def __init__( self : Tuple , lowerCAmelCase : Optional[int] , lowerCAmelCase : Dict )-> int: """simple docstring""" su...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase : Any = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try...
50
1
'''simple docstring''' import functools def lowerCamelCase__ ( A : list[int] , A : list[int] ): '''simple docstring''' if not isinstance(A , A ) or not all(isinstance(A , A ) for day in days ): raise ValueError('''The parameter days shou...
50
'''simple docstring''' import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def lowerCamelCase__ ( A : Optional[Any] , A : Tuple=1 ): '''simple docstring''' if n_shave_prefix_segments >= 0: r...
50
1
'''simple docstring''' import argparse import json import re from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( MobileNetVaConfig, MobileNetVaForImageClassification, MobileNetVaImageProcessor, load_tf...
50
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Any = logging.get_logger(__name__) _lowercase : Dict = { """facebook/dpr-ctx_encoder-single-nq-base""": ( """https://huggingface.co/facebook/dpr-ctx_encod...
50
1
'''simple docstring''' from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class UpperCamelCase__: def a__( self : Tuple , lowerCAmelCase : List[str] )-> str: """simple docstring""" ...
50
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBe...
50
1
'''simple docstring''' from __future__ import annotations from typing import Dict from ...configuration_utils import PretrainedConfig _lowercase : str = { """susnato/ernie-m-base_pytorch""": """https://huggingface.co/susnato/ernie-m-base_pytorch/blob/main/config.json""", """susnato/ernie...
50
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class UpperCamelCase__( lowerCAmelCase ): __magic_name__ : Tuple = ["image_processor", "tokenizer"] __magic_name__ : Any = "ViT...
50
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowercase : Any = { """configuration_x_clip""": [ """XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XCLIPConfig""", """XCLIPTextCon...
50
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowercase : Any = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], ...
50
1
'''simple docstring''' import argparse import json import os import pickle import shutil import numpy as np import torch from distiller import Distiller from lm_seqs_dataset import LmSeqsDataset from transformers import ( BertConfig, BertForMaskedLM, BertTokenizer, DistilBertConfig, DistilBe...
50
'''simple docstring''' import argparse import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from acceler...
50
1
'''simple docstring''' from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Sequence, Value from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase ) class UpperCamelCase__( lowerCAmelCase ): # `task` is not a ClassVar since we want it...
50
'''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 # #...
50
1
'''simple docstring''' def lowerCamelCase__ ( A : str , A : int ): '''simple docstring''' return [sentence[i : i + ngram_size] for i in range(len(A ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
50
'''simple docstring''' import math from typing import Optional import numpy as np from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : Union[str, Any] = logging.get_logger(__name__) _lowercase : List[str] = { """facebook/encodec_24khz""...
50
1