code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
'''simple docstring''' import logging import os import threading import time try: import warnings except ImportError: lowerCAmelCase__ : Dict = None try: import msvcrt except ImportError: lowerCAmelCase__ : str = None try: import fcntl except ImportError: lowerCAme...
351
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): if p < 2: raise ValueError("p should not be less than 2!" ) elif p == 2: return True __UpperCAmelCase : List[str] = 4 __UpperCAmelCase : int = (1 << p) - 1 for _ in range(p - ...
37
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : str = logging.get_logger(__name__) lowerCAmelCase__ : Dict = { "microsoft/cvt-13": "https://huggingface.co/microsoft/cvt-13/resolve/main/config.json", # See ...
352
'''simple docstring''' from collections.abc import Callable def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): __UpperCAmelCase : float = a __UpperCAmelCase : float = b if function(_UpperCAmelCase ) == 0: # one of the a or...
37
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_tf_available, is_torch_available, ) lowerCAmelCase__ : Optional[Any] = { "configuration_speech_to_t...
353
'''simple docstring''' 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 Toke...
37
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE__ ( metaclass=a__ ): """simple docstring""" SCREAMING_SNAKE_CASE = ['''onnx'''] def __init__( self : List[Any] , *UpperCAmelCase_ : List[An...
354
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def __UpperCamelCase ( _UpperCAmelCase ): return "".join(sorted(_UpperCAmelCase ) ) def __UpperCamelCase ( _UpperCAmelCase ): return word_by_signature[signatu...
37
0
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common import To...
355
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurat...
37
0
'''simple docstring''' import argparse import os import sys from unittest.mock import patch import pytorch_lightning as pl import timeout_decorator import torch from distillation import SummarizationDistiller, distill_main from finetune import SummarizationModule, main from transformers import MarianMTModel f...
356
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _UpperCAmelCase ): if not nums: raise ValueError("List is empty" ) return sum(_UpperCAmelCase ) / len(_UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.testmod()
37
0
'''simple docstring''' 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 ...
357
'''simple docstring''' # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnod...
37
0
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast from ...utils import logging lowerCAmelCase__ ...
358
'''simple docstring''' import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" SCREAMING_SNAKE_CASE = '''M-CLIP''' def __init__( self : List[str] ,...
37
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase__ : Optional[int] = logging.get_logger(__name__) lowerCAmelCase__ : Dict ...
359
'''simple docstring''' import math class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : Any , UpperCAmelCase_ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" __UpperCAmelCase :...
37
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class SCREAMING_SNAKE_CASE__ ( u...
360
'''simple docstring''' from datetime import datetime as dt import os from github import Github lowerCAmelCase__ : Union[str, Any] = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __UpperCamelCase ( ): ...
37
0
'''simple docstring''' from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import compute_effective_a...
361
'''simple docstring''' from heapq import heappop, heappush import numpy as np def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ): __UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = grid.shape __UpperCAmelCase : List[...
37
0
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ : int = {"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]} try: if not is_torch_ava...
362
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_ber...
37
0
'''simple docstring''' lowerCAmelCase__ : Dict = range(2, 20 + 1) lowerCAmelCase__ : Any = [10**k for k in range(ks[-1] + 1)] lowerCAmelCase__ : List[Any] = {} def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): __...
363
'''simple docstring''' # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
37
0
'''simple docstring''' from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand lowerCAmelCase__ : Dict = logging.get_logger(__name__) # pylint: disable=invalid-nam...
364
'''simple docstring''' import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __UpperCamelCase ( _UpperCAmelCase ): ...
37
0
'''simple docstring''' import re from filelock import FileLock try: import nltk lowerCAmelCase__ : Any = True except (ImportError, ModuleNotFoundError): lowerCAmelCase__ : Union[str, Any] = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("pu...
365
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMix...
37
0
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase = 100 ): __UpperCAmelCase : int = (n * (n + 1) // 2) ** 2 __UpperCAmelCase : str = n * (n + 1) * (2 * n + 1) // 6 return sum_cubes - sum_squares if __name__ == "__main__": print(f"{solution() =...
366
'''simple docstring''' import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" ...
37
0
'''simple docstring''' import unittest import numpy as np import requests from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs...
367
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps ...
37
0
'''simple docstring''' import random class SCREAMING_SNAKE_CASE__ : """simple docstring""" @staticmethod def lowerCamelCase_ ( UpperCAmelCase_ : Any ): """simple docstring""" __UpperCAmelCase : Union[str, Any] = [ord...
368
'''simple docstring''' import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc...
37
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import EsmConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ...
369
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available...
37
0
'''simple docstring''' import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets lowerCAmelCase__ : Tuple = "\\n@article{hendrycksmath2021,\n title={Measuring Mathematical Problem Solving With the MATH Dataset},\n author={Dan Hendrycks\n and Collin Burns\n ...
370
'''simple docstring''' from __future__ import annotations import math def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): if depth < 0: raise ValueError("Depth cannot be less than 0" ) if not scores: raise ValueErro...
37
0
'''simple docstring''' import re from filelock import FileLock try: import nltk lowerCAmelCase__ : Any = True except (ImportError, ModuleNotFoundError): lowerCAmelCase__ : Union[str, Any] = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: nltk.download("punkt"...
371
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Dict = logging.get_logger(__name__) lowerCAmelCase__ : int = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "g...
37
0
'''simple docstring''' from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): if not arr: return None,...
350
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): try: __UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase ) except ValueError: raise ValueError("Please enter a valid number" ) __UpperCAmelCase : str = decimal - int(_U...
37
0
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ): return price * (1 + tax_rate) if __name__ == "__main__": print(f"{price_plus_tax(1_00, 0.25) = }") print(f"{price_plus_tax(125.50, 0.05) = }")
351
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): if p < 2: raise ValueError("p should not be less than 2!" ) elif p == 2: return True __UpperCAmelCase : List[str] = 4 __UpperCAmelCase : int = (1 << p) - 1 for _ in range(p - ...
37
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available, is_vision_available, ) lowerCAmelCase__ : Dict = {"""configuration_beit""": ["""BEIT_PRETRAINED_CONFIG_ARCHIVE_MAP""",...
352
'''simple docstring''' from collections.abc import Callable def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): __UpperCAmelCase : float = a __UpperCAmelCase : float = b if function(_UpperCAmelCase ) == 0: # one of the a or...
37
0
'''simple docstring''' import logging from pathlib import Path import numpy as np import pytorch_lightning as pl import torch from pytorch_lightning.callbacks import EarlyStopping, ModelCheckpoint from pytorch_lightning.utilities import rank_zero_only from utils_rag import save_json def __UpperCamelCase ( _Upper...
353
'''simple docstring''' 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 Toke...
37
0
'''simple docstring''' print((lambda quine: quine % quine)("print((lambda quine: quine %% quine)(%r))"))
354
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def __UpperCamelCase ( _UpperCAmelCase ): return "".join(sorted(_UpperCAmelCase ) ) def __UpperCamelCase ( _UpperCAmelCase ): return word_by_signature[signatu...
37
0
import torch from diffusers import DDIMParallelScheduler from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ): """simple docstring""" SCREAMING_SNAKE_CASE = (DDIMParallelScheduler,) SCREAMING_SNAKE_CASE = (('...
355
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurat...
37
0
'''simple docstring''' lowerCAmelCase__ : List[str] = "0.21.0" from .accelerator import Accelerator from .big_modeling import ( cpu_offload, cpu_offload_with_hook, disk_offload, dispatch_model, init_empty_weights, init_on_device, load_checkpoint_and_dispatch, ) from .da...
356
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _UpperCAmelCase ): if not nums: raise ValueError("List is empty" ) return sum(_UpperCAmelCase ) / len(_UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.testmod()
37
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Dict = logging.get_logger(__name__) lowerCAmelCase__ : Union[str, Any] = { "google/vivit-b-16x2-kinetics400": ( "https://huggingface.co/google/vivit-...
357
'''simple docstring''' # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnod...
37
0
'''simple docstring''' import json import os import shutil import tempfile import unittest import numpy as np from transformers import BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES, BertTokenizer from transformers.testing_utils import require_tokenizers, require_vis...
358
'''simple docstring''' import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" SCREAMING_SNAKE_CASE = '''M-CLIP''' def __init__( self : List[str] ,...
37
0
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase__ : List[str] = { "configuration_vivit": ["VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP"...
359
'''simple docstring''' import math class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : Any , UpperCAmelCase_ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" __UpperCAmelCase :...
37
0
'''simple docstring''' import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_a...
360
'''simple docstring''' from datetime import datetime as dt import os from github import Github lowerCAmelCase__ : Union[str, Any] = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __UpperCamelCase ( ): ...
37
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 AddedToken, PreTrainedTokenizer from ...utils import logging lowerCAmelCase__ : str = logging.get_logger(__name__) lower...
361
'''simple docstring''' from heapq import heappop, heappush import numpy as np def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ): __UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = grid.shape __UpperCAmelCase : List[...
37
0
import requests from bsa import BeautifulSoup def __UpperCamelCase ( _UpperCAmelCase = "https://www.worldometers.info/coronavirus" ): __UpperCAmelCase : Any = BeautifulSoup(requests.get(lowercase_ ).text, "html.parser" ) __UpperCAmelCase : Any = s...
362
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_ber...
37
0
'''simple docstring''' from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin,...
363
'''simple docstring''' # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
37
0
'''simple docstring''' from argparse import ArgumentParser from ..pipelines import Pipeline, PipelineDataFormat, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand lowerCAmelCase__ : Tuple = logging.get_logger(__name__) # pylint: disable=invalid-na...
364
'''simple docstring''' import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __UpperCamelCase ( _UpperCAmelCase ): ...
37
0
'''simple docstring''' import os import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer from ...test_tokenization_common import TokenizerTesterMixin class SCREAMING_SNAKE_CASE__ ( lowerCamelCase_ ,unittest.TestCase ): """...
365
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMix...
37
0
'''simple docstring''' from __future__ import annotations lowerCAmelCase__ : Tuple = [] def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): for i in range(len(UpperCamelCase__ ) ): if board[row][i] == 1: return False for i in range(le...
366
'''simple docstring''' import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" ...
37
0
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase = 200 ): __UpperCAmelCase : Optional[Any] = [1, 2, 5, 10, 20, 50, 100, 200] __UpperCAmelCase : int = [0] * (pence + 1) __UpperCAmelCase : List[Any] = 1 # base case: 1 way to make...
367
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps ...
37
0
'''simple docstring''' from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class SCREAMING_SNAKE_CASE__ ( snake_...
368
'''simple docstring''' import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc...
37
0
'''simple docstring''' import argparse import json import pickle from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerImageProcessor, SwinConfig from transf...
369
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available...
37
0
'''simple docstring''' lowerCAmelCase__ : Tuple = { "Pillow": "Pillow", "accelerate": "accelerate>=0.11.0", "compel": "compel==0.1.8", "black": "black~=23.1", "datasets": "datasets", "filelock": "filelock", "flax": "flax>=0.4.1", "hf-doc-builder": "hf-doc-builder>=0.3...
370
'''simple docstring''' from __future__ import annotations import math def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): if depth < 0: raise ValueError("Depth cannot be less than 0" ) if not scores: raise ValueErro...
37
0
'''simple docstring''' from math import asin, atan, cos, radians, sin, sqrt, tan lowerCAmelCase__ : Optional[Any] = 637_8137.0 lowerCAmelCase__ : Any = 635_6752.31_4245 lowerCAmelCase__ : str = 6_37_81_37 def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCA...
371
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Dict = logging.get_logger(__name__) lowerCAmelCase__ : int = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "g...
37
0
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__) lowerCAmelCase...
350
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): try: __UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase ) except ValueError: raise ValueError("Please enter a valid number" ) __UpperCAmelCase : str = decimal - int(_U...
37
0
'''simple docstring''' lowerCAmelCase__ : int = { """A""": """.-""", """B""": """-...""", """C""": """-.-.""", """D""": """-..""", """E""": """.""", """F""": """..-.""", """G""": """--.""", """H""": """....""", """I""": """..""", """J""": """.---""", """K""": """-.-""", """L""": """.-..""", ...
351
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): if p < 2: raise ValueError("p should not be less than 2!" ) elif p == 2: return True __UpperCAmelCase : List[str] = 4 __UpperCAmelCase : int = (1 << p) - 1 for _ in range(p - ...
37
0
'''simple docstring''' import os import sys import unittest lowerCAmelCase__ : List[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 ...
352
'''simple docstring''' from collections.abc import Callable def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): __UpperCAmelCase : float = a __UpperCAmelCase : float = b if function(_UpperCAmelCase ) == 0: # one of the a or...
37
0
'''simple docstring''' import argparse import os import re lowerCAmelCase__ : Optional[Any] = "src/transformers/models/auto" # re pattern that matches mapping introductions: # SUPER_MODEL_MAPPING_NAMES = OrderedDict or SUPER_MODEL_MAPPING = OrderedDict lowerCAmelCase__ : Tuple = re.com...
353
'''simple docstring''' 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 Toke...
37
0
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurat...
354
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def __UpperCamelCase ( _UpperCAmelCase ): return "".join(sorted(_UpperCAmelCase ) ) def __UpperCamelCase ( _UpperCAmelCase ): return word_by_signature[signatu...
37
0
from typing import Dict, List from nltk.translate import gleu_score import datasets from datasets import MetricInfo lowerCAmelCase__ : Optional[Any] = "\\n@misc{wu2016googles,\n title={Google\'s Neural Machine Translation System: Bridging the Gap between Human and Machine Translation},\n ...
355
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurat...
37
0
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _UpperCAmelCase ): __UpperCAmelCase : Tuple = len(_UpperCAmelCase ) # We need to create solution object to save path. __UpperCAmelCase : Tuple = [[0 for _ in range(_Upper...
356
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _UpperCAmelCase ): if not nums: raise ValueError("List is empty" ) return sum(_UpperCAmelCase ) / len(_UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.testmod()
37
0
'''simple docstring''' from __future__ import annotations from functools import lru_cache from math import ceil lowerCAmelCase__ : List[str] = 1_00 lowerCAmelCase__ : Any = set(range(3, NUM_PRIMES, 2)) primes.add(2) lowerCAmelCase__ : Optional[int] = 42 for prime in ran...
357
'''simple docstring''' # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnod...
37
0
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteSch...
358
'''simple docstring''' import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" SCREAMING_SNAKE_CASE = '''M-CLIP''' def __init__( self : List[str] ,...
37
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase__ : Dict = {} try: if not is_sentencepiece_available(): ...
359
'''simple docstring''' import math class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : Any , UpperCAmelCase_ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" __UpperCAmelCase :...
37
0
'''simple docstring''' import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_toke...
360
'''simple docstring''' from datetime import datetime as dt import os from github import Github lowerCAmelCase__ : Union[str, Any] = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __UpperCamelCase ( ): ...
37
0
'''simple docstring''' import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_availab...
361
'''simple docstring''' from heapq import heappop, heappush import numpy as np def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ): __UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = grid.shape __UpperCAmelCase : List[...
37
0
def __UpperCamelCase ( _UpperCAmelCase = 600851475143 ): try: __UpperCAmelCase : List[str] = int(lowercase__ ) except (TypeError, ValueError): raise TypeError("Parameter n must be int or castable to int." ) if n <= 0: raise ValueError("Parameter n must be...
362
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_ber...
37
0
'''simple docstring''' lowerCAmelCase__ : Union[str, Any] = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] lowerCAmelCase__ : str = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] lowerCAmelCase__ : Dict = { 0: 'Sunday', 1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursda...
363
'''simple docstring''' # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
37
0
'''simple docstring''' import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: ...
364
'''simple docstring''' import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __UpperCamelCase ( _UpperCAmelCase ): ...
37
0
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): if len(SCREAMING_SNAKE_CASE_ ) <= 1: return lst __UpperCAmelCase : Optional[Any] = 1 while i < len(SCREAMING_SNAKE_CASE_ ): if lst[i - 1] <= lst[i]: i += 1 else: __UpperC...
365
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMix...
37
0
'''simple docstring''' import logging import os import sys import warnings from dataclasses import dataclass, field from random import randint from typing import Optional import datasets import evaluate import numpy as np from datasets import DatasetDict, load_dataset import transformers from transformers impo...
366
'''simple docstring''' import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" ...
37
0
'''simple docstring''' import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def __UpperCamelCase ( _UpperCAmelCase ): __UpperCAmelCase : Optional[Any] = FileLock(str(tmpdir / "foo.lock" ) ) __UpperCAmelCase : Optional[int...
367
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps ...
37
0
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase = 0 ): __UpperCAmelCase : List[str] = length or len(a__ ) __UpperCAmelCase : Optional[Any] = False for i in range(length - 1 ): if list_data[i] > list_data[i + 1]:...
368
'''simple docstring''' import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc...
37
0
'''simple docstring''' from __future__ import annotations from itertools import permutations from random import randint from timeit import repeat def __UpperCamelCase ( ): __UpperCAmelCase : int = [randint(-1000, 1000 ) for i in range(10 )] __UpperCAmelCase : Uni...
369
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available...
37
0
'''simple docstring''' import math def __UpperCamelCase ( ): __UpperCAmelCase : List[str] = input("Enter message: " ) __UpperCAmelCase : Tuple = int(input(F"Enter key [2-{len(_UpperCAmelCase ) - 1}]: " ) ) __UpperCAmelCase : List[str]...
370
'''simple docstring''' from __future__ import annotations import math def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): if depth < 0: raise ValueError("Depth cannot be less than 0" ) if not scores: raise ValueErro...
37
0
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ): __UpperCAmelCase : Union[str, Any] = len(lowerCamelCase__ ) print("The following activities are selected:" ) # The first activity is always selected __UpperCAmelCase : List[...
371
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Dict = logging.get_logger(__name__) lowerCAmelCase__ : int = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "g...
37
0
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.ut...
350
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): try: __UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase ) except ValueError: raise ValueError("Please enter a valid number" ) __UpperCAmelCase : str = decimal - int(_U...
37
0
'''simple docstring''' from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class SCREAMING_SNAKE_CASE__ ( sn...
351
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): if p < 2: raise ValueError("p should not be less than 2!" ) elif p == 2: return True __UpperCAmelCase : List[str] = 4 __UpperCAmelCase : int = (1 << p) - 1 for _ in range(p - ...
37
0
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare...
352
'''simple docstring''' from collections.abc import Callable def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): __UpperCAmelCase : float = a __UpperCAmelCase : float = b if function(_UpperCAmelCase ) == 0: # one of the a or...
37
0
'''simple docstring''' import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data impo...
353
'''simple docstring''' 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 Toke...
37
0
'''simple docstring''' import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ConvNextConfig, SegformerImageProcessor, UperNetConfig, UperNetForSemanticSegmentation def __UpperCamelCase ( _UpperCAmelCase ): ...
354
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def __UpperCamelCase ( _UpperCAmelCase ): return "".join(sorted(_UpperCAmelCase ) ) def __UpperCamelCase ( _UpperCAmelCase ): return word_by_signature[signatu...
37
0
import json import unittest import numpy as np from huggingface_hub import hf_hub_download 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, prep...
355
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurat...
37
0
'''simple docstring''' import math_equivalence # From: git+https://github.com/hendrycks/math.git import datasets lowerCAmelCase__ : Optional[int] = '''\ @article{hendrycksmath2021, title={Measuring Mathematical Problem Solving With the MATH Dataset}, author={Dan Hendrycks and Collin Bur...
356
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _UpperCAmelCase ): if not nums: raise ValueError("List is empty" ) return sum(_UpperCAmelCase ) / len(_UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.testmod()
37
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffus...
357
'''simple docstring''' # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnod...
37
0
'''simple docstring''' import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO, ) lowerCAmelCase__ : Lis...
358
'''simple docstring''' import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" SCREAMING_SNAKE_CASE = '''M-CLIP''' def __init__( self : List[str] ,...
37
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCAmelCase__ : Tuple = { "configuration_canine": ["CANINE_PRETRAINED_CONFIG_ARCHIVE_MAP", "CanineConfig"], "tokenizatio...
359
'''simple docstring''' import math class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : Any , UpperCAmelCase_ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" __UpperCAmelCase :...
37
0
'''simple docstring''' import math import flax.linen as nn import jax.numpy as jnp def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase = 1, _UpperCAmelCase = 1, _UpperCAmelCase = 1.0E4, _UpperCAmelCase = False, _UpperCAmelCase = 1.0, ): assert timesteps.ndim == 1, "Timestep...
360
'''simple docstring''' from datetime import datetime as dt import os from github import Github lowerCAmelCase__ : Union[str, Any] = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __UpperCamelCase ( ): ...
37
0
'''simple docstring''' from typing import Callable, List, Optional, Tuple, Union import torch from transformers import CLIPTextModel, CLIPTokenizer from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin, TransformeraDModel, VQModel from ...schedulers import VQDiffus...
361
'''simple docstring''' from heapq import heappop, heappush import numpy as np def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ): __UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = grid.shape __UpperCAmelCase : List[...
37
0
import argparse import shlex import runhouse as rh if __name__ == "__main__": # Refer to https://runhouse-docs.readthedocs-hosted.com/en/latest/api/python/cluster.html#hardware-setup for cloud access # setup instructions, if using on-demand hardware # If user passes --user <user> --host <host> --key_...
362
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_ber...
37
0
'''simple docstring''' import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import Tokeniz...
363
'''simple docstring''' # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
37
0
'''simple docstring''' import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_av...
364
'''simple docstring''' import argparse import requests import torch from PIL import Image from torchvision.transforms import Compose, Normalize, Resize, ToTensor from transformers import SwinaSRConfig, SwinaSRForImageSuperResolution, SwinaSRImageProcessor def __UpperCamelCase ( _UpperCAmelCase ): ...
37
0
'''simple docstring''' import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class SCREAMING_SNAKE_CASE__ ( _lowerCAmelCase ): """simple ...
365
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMix...
37
0
'''simple docstring''' import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): """simple docstring""" def lowerCamelCase_ ( self : ...
366
'''simple docstring''' import warnings from ...utils import logging from .image_processing_imagegpt import ImageGPTImageProcessor lowerCAmelCase__ : Optional[Any] = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" ...
37
0
'''simple docstring''' import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=l...
367
'''simple docstring''' from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps ...
37
0
'''simple docstring''' from __future__ import annotations import typing from collections.abc import Iterable import numpy as np lowerCAmelCase__ : Tuple = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 lowerCAmelCase__ : Union[str, Any] = typing.Union[np.floa...
368
'''simple docstring''' import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in_pytorc...
37
0
'''simple docstring''' from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_herbert import HerbertTokenizer lowerCAmelCase__ : int = logging.get_logger(__name__) lowerCAmelCase__ : Tuple ...
369
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available...
37
0
'''simple docstring''' from typing import List, Optional, Tuple, Union import torch from torch import nn from torch.nn import CrossEntropyLoss from ... import AutoBackbone from ...modeling_outputs import SemanticSegmenterOutput from ...modeling_utils import PreTrainedModel from ...utils import add_start_docstr...
370
'''simple docstring''' from __future__ import annotations import math def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): if depth < 0: raise ValueError("Depth cannot be less than 0" ) if not scores: raise ValueErro...
37
0
'''simple docstring''' from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) lowerCAmelCa...
371
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Dict = logging.get_logger(__name__) lowerCAmelCase__ : int = { "google/fnet-base": "https://huggingface.co/google/fnet-base/resolve/main/config.json", "g...
37
0
'''simple docstring''' import argparse import os import torch from transformers import ( XLNetConfig, XLNetForQuestionAnswering, XLNetForSequenceClassification, XLNetLMHeadModel, load_tf_weights_in_xlnet, ) from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, loggin...
350
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): try: __UpperCAmelCase : Union[str, Any] = float(_UpperCAmelCase ) except ValueError: raise ValueError("Please enter a valid number" ) __UpperCAmelCase : str = decimal - int(_U...
37
0
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvail...
351
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): if p < 2: raise ValueError("p should not be less than 2!" ) elif p == 2: return True __UpperCAmelCase : List[str] = 4 __UpperCAmelCase : int = (1 << p) - 1 for _ in range(p - ...
37
0
'''simple docstring''' from .data_collator import ( DataCollatorForLanguageModeling, DataCollatorForPermutationLanguageModeling, DataCollatorForSeqaSeq, DataCollatorForSOP, DataCollatorForTokenClassification, DataCollatorForWholeWordMask, DataCollatorWithPadding, DefaultDataCollator, ...
352
'''simple docstring''' from collections.abc import Callable def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): __UpperCAmelCase : float = a __UpperCAmelCase : float = b if function(_UpperCAmelCase ) == 0: # one of the a or...
37
0
'''simple docstring''' import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging lowerCAmelCase__ : Optional[Any] ...
353
'''simple docstring''' 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 Toke...
37
0
'''simple docstring''' from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets lowerCAmelCase__ : int = "\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},\...
354
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def __UpperCamelCase ( _UpperCAmelCase ): return "".join(sorted(_UpperCAmelCase ) ) def __UpperCamelCase ( _UpperCAmelCase ): return word_by_signature[signatu...
37
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ : Optional[int] = { 'configuration_upernet': ['UperNetConfig'], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except Opt...
355
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configurat...
37
0
'''simple docstring''' import inspect import os import unittest from dataclasses import dataclass import torch from accelerate import Accelerator, DistributedDataParallelKwargs, GradScalerKwargs from accelerate.state import AcceleratorState from accelerate.test_utils import execute_subprocess_async, require_c...
356
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _UpperCAmelCase ): if not nums: raise ValueError("List is empty" ) return sum(_UpperCAmelCase ) / len(_UpperCAmelCase ) if __name__ == "__main__": import doctest doctest.testmod()
37
0
'''simple docstring''' def __UpperCamelCase ( _UpperCAmelCase ): if not isinstance(_A, _A ): raise TypeError("only integers accepted as input" ) else: __UpperCAmelCase : List[str] = str(abs(_A ) ) __UpperCAmelCase : Optional[int] ...
357
'''simple docstring''' # # This a `torch.distributed` diagnostics script that checks that all GPUs in the cluster (one or # many nodes) can talk to each other via nccl and allocate gpu memory. # # To run first adjust the number of processes and nodes: # # python -m torch.distributed.run --nproc_per_node 2 --nnod...
37
0
'''simple docstring''' import warnings from collections import OrderedDict from typing import Any, Mapping, Optional from ... import PreTrainedTokenizer from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast from ...onnx.utils import com...
358
'''simple docstring''' import torch from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" SCREAMING_SNAKE_CASE = '''M-CLIP''' def __init__( self : List[str] ,...
37
0
'''simple docstring''' import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def __UpperCamelCase ( _UpperCAmelCase ): monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings", set() ) @pytest.fixture def __UpperCamelCas...
359
'''simple docstring''' import math class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self : Any , UpperCAmelCase_ : Optional[int]=0 ): # a graph with Node 0,1,...,N-1 """simple docstring""" __UpperCAmelCase :...
37
0
'''simple docstring''' import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class SCREAMING_SNAKE_CASE__ ( datasets.BeamBasedBuilder ): """simple docs...
360
'''simple docstring''' from datetime import datetime as dt import os from github import Github lowerCAmelCase__ : Union[str, Any] = [ "good first issue", "good second issue", "good difficult issue", "feature request", "new model", "wip", ] def __UpperCamelCase ( ): ...
37
0
'''simple docstring''' import torch from accelerate import PartialState from accelerate.utils.operations import broadcast, gather, gather_object, pad_across_processes, reduce def __UpperCamelCase ( _UpperCAmelCase ): return (torch.arange(state.num_processes ) + 1.0 + (state.num_processes * st...
361
'''simple docstring''' from heapq import heappop, heappush import numpy as np def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, ): __UpperCAmelCase , __UpperCAmelCase : Union[str, Any] = grid.shape __UpperCAmelCase : List[...
37
0
import json import os import unittest from transformers.models.roc_bert.tokenization_roc_bert import ( VOCAB_FILES_NAMES, RoCBertBasicTokenizer, RoCBertTokenizer, RoCBertWordpieceTokenizer, _is_control, _is_punctuation, _is_whitespace, ) from transformers.testing_utils import require_...
362
'''simple docstring''' import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_ber...
37
0