code
stringlengths
87
55.2k
code_codestyle
int64
0
349
style_context
stringlengths
135
49.1k
style_context_codestyle
int64
0
349
label
int64
0
1
"""simple docstring""" import os from collections.abc import Iterator def lowercase__ ( snake_case_ :str = "." ): for dir_path, dir_names, filenames in os.walk(snake_case_ ): __UpperCAmelCase = [d for d in dir_names if d != '''scripts''' and d[0] not in '''._'''] f...
332
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class _UpperCAmelCase : def __init__( self : Union[str, Any] , _lowercase : Optional[Any] ): __UpperCAmelCase = str(id_ ) __UpperCAmelCase = None ...
332
1
"""simple docstring""" import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_...
332
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Dict = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swin...
332
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available _lowercase : List[str] = { 'configuration_xlm': ['XLM_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLMConfig', 'XLMOnnxConfig'], '...
332
"""simple docstring""" import pprint import requests _lowercase : Optional[Any] = 'https://zenquotes.io/api' def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + ...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :int , snake_case_ :list ): _enforce_args(snake_case_ , snake_case_ ) if n == 0: return 0 __UpperCAmelCase = float('''-inf''' ) for i in range(1 , n + 1 ): __UpperCAmelCase ...
332
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _lowercase : List[str] = logging.get_logger(__name__) def lowercase__ ( snake_case_ :Union[tf.Tensor, np.ndarray] ): if isins...
332
1
"""simple docstring""" import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) _lowercase : List[Any] = logging.getLogge...
332
"""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/LI...
332
1
"""simple docstring""" from __future__ import annotations from math import gcd def lowercase__ ( snake_case_ :int , snake_case_ :int = 2 , snake_case_ :int = 1 , snake_case_ :int = 3 , ): # A value less than 2 can cause an inf...
332
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
332
1
"""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/LI...
332
"""simple docstring""" import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def lowercase__ ( ): raise RuntimeError('''CUDA out of memory.''' ) class _Up...
332
1
"""simple docstring""" import pytest _lowercase : str = '__dummy_dataset1__' _lowercase : Tuple = '\nimport json\nimport os\n\nimport datasets\n\n\nREPO_URL = "https://huggingface.co/datasets/albertvillanova/tests-raw-jsonl/resolve/main/"\nURLS = {"train": REPO_URL + "wiki...
332
"""simple docstring""" import argparse import copy def lowercase__ ( snake_case_ :Tuple ): __UpperCAmelCase = {} with open(snake_case_ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __UpperCAmelCase = [] _list.append(...
332
1
"""simple docstring""" import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transf...
332
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowercase__ ( snake_case_ :ndarray ): return np.dot(snake_case_ , snake_case_ ) class _UpperCAmelCase : def __init__( ...
332
1
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common ...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule _lowercase : int = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys ...
332
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : Optiona...
332
"""simple docstring""" from __future__ import annotations class _UpperCAmelCase : def __init__( self : Tuple , _lowercase : str , _lowercase : str ): __UpperCAmelCase , __UpperCAmelCase = text, pattern __UpperCAmelCase , __Upp...
332
1
"""simple docstring""" import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def lowercase__ ( snake_case_ ...
332
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class _UpperCAmelCase : a__ : int a__ : Node | None = None a_...
332
1
"""simple docstring""" from math import factorial _lowercase : List[Any] = {str(d): factorial(d) for d in range(10)} def lowercase__ ( snake_case_ :int ): return sum(DIGIT_FACTORIAL[d] for d in str(snake_case_ ) ) def lowercase__ ( ): __UpperCAmelC...
332
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiec...
332
1
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Iterator from dataclasses import dataclass @dataclass class _UpperCAmelCase : a__ : int a__ : int class _UpperCAmelCase : def...
332
"""simple docstring""" def lowercase__ ( snake_case_ :Union[str, Any] ): # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection __UpperCAmelCase = len(snake_case_ ) __UpperCAmelCase = max(snake_c...
332
1
"""simple docstring""" import random import unittest import torch from diffusers import IFInpaintingSuperResolutionPipeline from diffusers.utils import floats_tensor from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.testing_utils import skip_mps, torch_device ...
332
"""simple docstring""" from collections import defaultdict def lowercase__ ( snake_case_ :str , snake_case_ :str ): __UpperCAmelCase = first_str.lower().strip() __UpperCAmelCase = second_str.lower().strip() # Remove whitespace __UpperCAmel...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :int = 2_000_000 ): __UpperCAmelCase = [0 for i in range(n + 1 )] __UpperCAmelCase = 1 __UpperCAmelCase = 1 for i in range(2 , int(n**0.5 ) + 1 ): if primality_list[i] == 0: for j ...
332
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBe...
332
1
"""simple docstring""" import unittest from transformers import JukeboxTokenizer from transformers.testing_utils import require_torch class _UpperCAmelCase ( unittest.TestCase ): a__ : List[Any] = JukeboxTokenizer a__ : str = { "artist...
332
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class _UpperCAmelCase ( _lowerCAmelCase ): def a ( self : Tuple , _lowercase : Dict=None , _lowercase : str=None , _lowercase : Union[str, Any]=...
332
1
"""simple docstring""" from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _lowercase : Optional[int] = logging.get_logger(__name__) _lowercase : List[Any] = { 'nielsr/canine-s': ...
332
"""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 ...
332
1
"""simple docstring""" import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConfig, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaForCTC, WavaVecaForPreTraining, WavaVecaPro...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : Union[str, Any] = { 'configuration_resnet': ['RESNET_PRETRAI...
332
1
"""simple docstring""" _lowercase : List[Any] = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers...
332
"""simple docstring""" _lowercase : Any = '\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https:/...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :int = 3 , snake_case_ :int = 7 , snake_case_ :int = 1_000_000 ): __UpperCAmelCase = 0 __UpperCAmelCase = 1 for current_denominator in range(1 , limit + 1 ): __UpperCAme...
332
"""simple docstring""" import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, ...
332
1
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import center_crop, normalize, rescale, resize, to_channel_dimension_format from ...image_utils imp...
332
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list[float] , snake_case_ :list[float] ): __UpperCAmelCase = sorted(numsa + numsa ) __UpperCAmelCase , __UpperCAmelCase = divmod(len(snake_case_ )...
332
1
"""simple docstring""" import math import random def lowercase__ ( snake_case_ :float , snake_case_ :bool = False ): if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value _lowercase : Union[str, Any] = 0.02 ...
332
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class _UpperCAmelCase : def __init__( self : Union[str, Any] , _lowercase : Optional[Any] ): __UpperCAmelCase = str(id_ ) __UpperCAmelCase = None ...
332
1
"""simple docstring""" from sklearn.metrics import mean_squared_error import datasets _lowercase : List[str] = '\\n@article{scikit-learn,\n title={Scikit-learn: Machine Learning in {P}ython},\n author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V.\n and Thirio...
332
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Dict = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swin...
332
1
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _lowercase : int = logging.get_logger(__name__) _lowercase : Optional[int]...
332
"""simple docstring""" import pprint import requests _lowercase : Optional[Any] = 'https://zenquotes.io/api' def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + ...
332
1
"""simple docstring""" from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder _lowercase : Tuple = datasets.utils.logging.get_logger(__name__) class _UpperCAmelCase ( folder_based_bui...
332
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _lowercase : List[str] = logging.get_logger(__name__) def lowercase__ ( snake_case_ :Union[tf.Tensor, np.ndarray] ): if isins...
332
1
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class _UpperCAmelCase ( _lowerCAmelCase ): def a ( self : Tuple , _lowercase : Dict=None , _lowercase : str=None , _lowercase : Union[str, Any]=...
332
"""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/LI...
332
1
"""simple docstring""" import json from typing import Dict, List, Optional, Tuple, Union from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding, EncodedInput from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils imp...
332
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
332
1
"""simple docstring""" from manim import * class _UpperCAmelCase ( _lowerCAmelCase ): def a ( self : List[Any] ): __UpperCAmelCase = Rectangle(height=0.5 , width=0.5 ) __UpperCAmelCase = Rectangle(height=0.46 , width=0.46 ).set...
332
"""simple docstring""" import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def lowercase__ ( ): raise RuntimeError('''CUDA out of memory.''' ) class _Up...
332
1
"""simple docstring""" from abc import ABC, abstractmethod from argparse import ArgumentParser class _UpperCAmelCase ( _lowerCAmelCase ): @staticmethod @abstractmethod def a ( _lowercase : ArgumentParser ): raise NotImplementedError() @abstractmethod de...
332
"""simple docstring""" import argparse import copy def lowercase__ ( snake_case_ :Tuple ): __UpperCAmelCase = {} with open(snake_case_ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __UpperCAmelCase = [] _list.append(...
332
1
"""simple docstring""" from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu,...
332
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowercase__ ( snake_case_ :ndarray ): return np.dot(snake_case_ , snake_case_ ) class _UpperCAmelCase : def __init__( ...
332
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 ...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule _lowercase : int = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys ...
332
1
"""simple docstring""" from collections import defaultdict def lowercase__ ( snake_case_ :str , snake_case_ :str ): __UpperCAmelCase = first_str.lower().strip() __UpperCAmelCase = second_str.lower().strip() # Remove whitespace __UpperCAmel...
332
"""simple docstring""" from __future__ import annotations class _UpperCAmelCase : def __init__( self : Tuple , _lowercase : str , _lowercase : str ): __UpperCAmelCase , __UpperCAmelCase = text, pattern __UpperCAmelCase , __Upp...
332
1
"""simple docstring""" import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor...
332
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class _UpperCAmelCase : a__ : int a__ : Node | None = None a_...
332
1
"""simple docstring""" import argparse import torch from transformers import ( WavaVecaConfig, WavaVecaFeatureExtractor, WavaVecaForAudioFrameClassification, WavaVecaForSequenceClassification, WavaVecaForXVector, logging, ) logging.set_verbosity_info() _lowercase ...
332
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiec...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :list[int] ): __UpperCAmelCase = len(snake_case_ ) for i in range(snake_case_ ): for j in range(i + 1 , snake_case_ ): if numbers[j] < numbers[i]: __UpperCAmelCase , __UpperCAmelCase = ...
332
"""simple docstring""" def lowercase__ ( snake_case_ :Union[str, Any] ): # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection __UpperCAmelCase = len(snake_case_ ) __UpperCAmelCase = max(snake_c...
332
1
"""simple docstring""" from __future__ import annotations class _UpperCAmelCase : def __init__( self : Dict , _lowercase : int = 0 ): __UpperCAmelCase = key def a ( self : Optional[int] , _lowercase : str , _lowercase...
332
"""simple docstring""" from collections import defaultdict def lowercase__ ( snake_case_ :str , snake_case_ :str ): __UpperCAmelCase = first_str.lower().strip() __UpperCAmelCase = second_str.lower().strip() # Remove whitespace __UpperCAmel...
332
1
"""simple docstring""" import json import os import shutil import tempfile import unittest from multiprocessing import get_context from pathlib import Path import datasets import numpy as np from datasets import load_dataset from parameterized import parameterized from transformers import Au...
332
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBe...
332
1
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list[float] , snake_case_ :list[float] ): __UpperCAmelCase = sorted(numsa + numsa ) __UpperCAmelCase , __UpperCAmelCase = divmod(len(snake_case_ )...
332
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class _UpperCAmelCase ( _lowerCAmelCase ): def a ( self : Tuple , _lowercase : Dict=None , _lowercase : str=None , _lowercase : Union[str, Any]=...
332
1
"""simple docstring""" import pandas as pd from matplotlib import pyplot as plt from sklearn.linear_model import LinearRegression # Splitting the dataset into the Training set and Test set from sklearn.model_selection import train_test_split # Fitting Polynomial Regression to the dataset from skl...
332
"""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 ...
332
1
"""simple docstring""" from pathlib import Path from typing import List from transformers import is_torch_available, is_vision_available from transformers.testing_utils import get_tests_dir, is_tool_test from transformers.tools.agent_types import AGENT_TYPE_MAPPING, AgentAudio, AgentImage, AgentText ...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : Union[str, Any] = { 'configuration_resnet': ['RESNET_PRETRAI...
332
1
"""simple docstring""" from __future__ import annotations class _UpperCAmelCase : def __init__( self : Tuple , _lowercase : str , _lowercase : str ): __UpperCAmelCase , __UpperCAmelCase = text, pattern __UpperCAmelCase , __Upp...
332
"""simple docstring""" _lowercase : Any = '\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https:/...
332
1
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=_lowerCAmelCase ) class _UpperCAmelCase ( _lowerCAmelCase ): # `task` i...
332
"""simple docstring""" import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, ...
332
1
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_video_inputs ...
332
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list[float] , snake_case_ :list[float] ): __UpperCAmelCase = sorted(numsa + numsa ) __UpperCAmelCase , __UpperCAmelCase = divmod(len(snake_case_ )...
332
1
"""simple docstring""" import argparse import os import pickle import sys import torch from transformers import TransfoXLConfig, TransfoXLLMHeadModel, load_tf_weights_in_transfo_xl from transformers.models.transfo_xl import tokenization_transfo_xl as data_utils from transformers.models.transfo_x...
332
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class _UpperCAmelCase : def __init__( self : Union[str, Any] , _lowercase : Optional[Any] ): __UpperCAmelCase = str(id_ ) __UpperCAmelCase = None ...
332
1
"""simple docstring""" import os from typing import Optional import fsspec from fsspec.archive import AbstractArchiveFileSystem from fsspec.utils import DEFAULT_BLOCK_SIZE class _UpperCAmelCase ( _lowerCAmelCase ): a__ : Any = "" a__ : str ...
332
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Dict = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swin...
332
1
"""simple docstring""" import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class _UpperCAmelC...
332
"""simple docstring""" import pprint import requests _lowercase : Optional[Any] = 'https://zenquotes.io/api' def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + ...
332
1
"""simple docstring""" import argparse import copy def lowercase__ ( snake_case_ :Tuple ): __UpperCAmelCase = {} with open(snake_case_ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __UpperCAmelCase = [] _list.append(...
332
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _lowercase : List[str] = logging.get_logger(__name__) def lowercase__ ( snake_case_ :Union[tf.Tensor, np.ndarray] ): if isins...
332
1
"""simple docstring""" from __future__ import annotations from random import random from typing import Generic, TypeVar _lowercase : Tuple = TypeVar('KT') _lowercase : List[str] = TypeVar('VT') class _UpperCAmelCase ( Generic[KT, VT] ): def __init__( ...
332
"""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/LI...
332
1
"""simple docstring""" import operator def lowercase__ ( snake_case_ :list , snake_case_ :bool = False , snake_case_ :list | None = None ): __UpperCAmelCase = operator.lt if reverse else operator.gt __UpperCAmelCase = solution or ...
332
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
332
1
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowercase__ ( snake_case_ :ndarray ): return np.dot(snake_case_ , snake_case_ ) class _UpperCAmelCase : def __init__( ...
332
"""simple docstring""" import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def lowercase__ ( ): raise RuntimeError('''CUDA out of memory.''' ) class _Up...
332
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/licens...
332
"""simple docstring""" import argparse import copy def lowercase__ ( snake_case_ :Tuple ): __UpperCAmelCase = {} with open(snake_case_ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __UpperCAmelCase = [] _list.append(...
332
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer f...
332
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowercase__ ( snake_case_ :ndarray ): return np.dot(snake_case_ , snake_case_ ) class _UpperCAmelCase : def __init__( ...
332
1
"""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, SwinCo...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule _lowercase : int = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys ...
332
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_dpt import DPTImageProcessor _lowercase : Optional[Any] = logging.get_logger(__name__) class _UpperCAmelCase ( _lowerCAmelCase ): def __init__( self : Optional[Any] ...
332
"""simple docstring""" from __future__ import annotations class _UpperCAmelCase : def __init__( self : Tuple , _lowercase : str , _lowercase : str ): __UpperCAmelCase , __UpperCAmelCase = text, pattern __UpperCAmelCase , __Upp...
332
1
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_tf_available from transformers.testing_utils import require_tf if is_tf_available(): import tensorflow as tf from transformers import TensorFlowBenchmark...
332
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class _UpperCAmelCase : a__ : int a__ : Node | None = None a_...
332
1
"""simple docstring""" from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class _UpperCAmelCase : a__ : int a__ : TreeNode | None = None a__ : TreeNode | None = None ...
332
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiec...
332
1
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiec...
332
"""simple docstring""" def lowercase__ ( snake_case_ :Union[str, Any] ): # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection __UpperCAmelCase = len(snake_case_ ) __UpperCAmelCase = max(snake_c...
332
1
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except ...
332
"""simple docstring""" from collections import defaultdict def lowercase__ ( snake_case_ :str , snake_case_ :str ): __UpperCAmelCase = first_str.lower().strip() __UpperCAmelCase = second_str.lower().strip() # Remove whitespace __UpperCAmel...
332
1
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_tf_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_tf_available(): import tensorflow as tf _lowercase : ...
332
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBe...
332
1
"""simple docstring""" import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated _lowercase : List[str] = col...
332
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class _UpperCAmelCase ( _lowerCAmelCase ): def a ( self : Tuple , _lowercase : Dict=None , _lowercase : str=None , _lowercase : Union[str, Any]=...
332
1
"""simple docstring""" # We ignore warnings about stepping the scheduler since we step it ourselves during gradient accumulation import warnings from .state import AcceleratorState, GradientState warnings.filterwarnings('ignore', category=UserWarning, module='torch.optim.lr_scheduler') class ...
332
"""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 ...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :list ): __UpperCAmelCase = len(snake_case_ ) for i in range(1 , snake_case_ ): __UpperCAmelCase = collection[i] __UpperCAmelCase = 0 __UpperCAmelCase = i - 1 while low ...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : Union[str, Any] = { 'configuration_resnet': ['RESNET_PRETRAI...
332
1
"""simple docstring""" import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_fla...
332
"""simple docstring""" _lowercase : Any = '\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https:/...
332
1
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Dict = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swin...
332
"""simple docstring""" import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, ...
332
1
"""simple docstring""" import copy from typing import Dict, List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING _lowercase : Union[str, Any] = { 'facebook/mask2former-swin-small-coco-instance': ( ...
332
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list[float] , snake_case_ :list[float] ): __UpperCAmelCase = sorted(numsa + numsa ) __UpperCAmelCase , __UpperCAmelCase = divmod(len(snake_case_ )...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :float , snake_case_ :float ): if mass < 0: raise ValueError('''The mass of a body cannot be negative''' ) return 0.5 * mass * abs(snake_case_ ) * abs(snake_case_ ) if __name__ == "__main__": import doctest ...
332
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class _UpperCAmelCase : def __init__( self : Union[str, Any] , _lowercase : Optional[Any] ): __UpperCAmelCase = str(id_ ) __UpperCAmelCase = None ...
332
1
"""simple docstring""" from typing import Union import fire import torch from tqdm import tqdm def lowercase__ ( snake_case_ :str , snake_case_ :str = "cpu" , snake_case_ :Union[str, None] = None ): __UpperCAmelCase = torch.load(snake_cas...
332
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Dict = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swin...
332
1
"""simple docstring""" from __future__ import annotations from typing import Any class _UpperCAmelCase : def __init__( self : Union[str, Any] , _lowercase : int , _lowercase : int , _lowercase : float = 0 ): __UpperCAmelCase , __Uppe...
332
"""simple docstring""" import pprint import requests _lowercase : Optional[Any] = 'https://zenquotes.io/api' def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + ...
332
1
"""simple docstring""" import argparse import torch from transformers import BertConfig, BertForPreTraining, load_tf_weights_in_bert from transformers.utils import logging logging.set_verbosity_info() def lowercase__ ( snake_case_ :Union[str, Any] , snake_case_ ...
332
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _lowercase : List[str] = logging.get_logger(__name__) def lowercase__ ( snake_case_ :Union[tf.Tensor, np.ndarray] ): if isins...
332
1
"""simple docstring""" class _UpperCAmelCase : def __init__( self : Union[str, Any] , _lowercase : list ): __UpperCAmelCase = set_counts __UpperCAmelCase = max(_lowercase ) __UpperCAmelCase = len(_lowercase ) __UpperCAmelCase...
332
"""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/LI...
332
1
"""simple docstring""" # This script creates a super tiny model that is useful inside tests, when we just want to test that # the machinery works, without needing to the check the quality of the outcomes. # # This version creates a tiny model through reduction of a normal pre-trained model, but keeping ...
332
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
332
1
"""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, EulerAn...
332
"""simple docstring""" import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def lowercase__ ( ): raise RuntimeError('''CUDA out of memory.''' ) class _Up...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :int ): __UpperCAmelCase = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def lowercase__ ( snake_case_ :int = 100 ): __UpperCAmelCase = 1 __UpperCAmelCase = ...
332
"""simple docstring""" import argparse import copy def lowercase__ ( snake_case_ :Tuple ): __UpperCAmelCase = {} with open(snake_case_ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __UpperCAmelCase = [] _list.append(...
332
1
"""simple docstring""" import os def lowercase__ ( ): with open(os.path.dirname(snake_case_ ) + '''/p022_names.txt''' ) as file: __UpperCAmelCase = str(file.readlines()[0] ) __UpperCAmelCase = names.replace('''"''' , '''''' ).split(''',''' ) ...
332
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowercase__ ( snake_case_ :ndarray ): return np.dot(snake_case_ , snake_case_ ) class _UpperCAmelCase : def __init__( ...
332
1
"""simple docstring""" from pathlib import Path import fire def lowercase__ ( snake_case_ :str , snake_case_ :str , snake_case_ :int ): __UpperCAmelCase = Path(snake_case_ ) __UpperCAmelCase = Path(snake_case_ ) dest_dir.mk...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule _lowercase : int = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys ...
332
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : int = { 'configuration_vision_text_dual_encoder': ['VisionTe...
332
"""simple docstring""" from __future__ import annotations class _UpperCAmelCase : def __init__( self : Tuple , _lowercase : str , _lowercase : str ): __UpperCAmelCase , __UpperCAmelCase = text, pattern __UpperCAmelCase , __Upp...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :list ): if any(not isinstance(snake_case_ , snake_case_ ) or x < 0 for x in sequence ): raise TypeError('''Sequence must be list of non-negative integers''' ) for _ in range(len(snake_case_ ) ): for i, (rod_upper, rod...
332
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class _UpperCAmelCase : a__ : int a__ : Node | None = None a_...
332
1
"""simple docstring""" import math def lowercase__ ( snake_case_ :List[str] , snake_case_ :List[str] ): if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(snake_case_ ) else: if x == 0: # 0 raised to any...
332
"""simple docstring""" import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiec...
332
1
"""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...
332
"""simple docstring""" def lowercase__ ( snake_case_ :Union[str, Any] ): # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection __UpperCAmelCase = len(snake_case_ ) __UpperCAmelCase = max(snake_c...
332
1
"""simple docstring""" _lowercase : Any = '\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https:/...
332
"""simple docstring""" from collections import defaultdict def lowercase__ ( snake_case_ :str , snake_case_ :str ): __UpperCAmelCase = first_str.lower().strip() __UpperCAmelCase = second_str.lower().strip() # Remove whitespace __UpperCAmel...
332
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 : Optional[int] = pytest.mark.integration...
332
"""simple docstring""" import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBe...
332
1
"""simple docstring""" import warnings from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils i...
332
"""simple docstring""" from typing import Dict from .base import GenericTensor, Pipeline class _UpperCAmelCase ( _lowerCAmelCase ): def a ( self : Tuple , _lowercase : Dict=None , _lowercase : str=None , _lowercase : Union[str, Any]=...
332
1
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import TransformeraDModel, VQDiffusionPipeline, VQDiffusionScheduler, VQModel from diffusers.pipelines.vq_diffusion.pipeline_vq_dif...
332
"""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 ...
332
1
"""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, prepar...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _lowercase : Union[str, Any] = { 'configuration_resnet': ['RESNET_PRETRAI...
332
1
"""simple docstring""" import pytest from datasets.splits import SplitDict, SplitInfo from datasets.utils.py_utils import asdict @pytest.mark.parametrize( '''split_dict''' , [ SplitDict(), SplitDict({'''train''': SplitInfo(name='''train''' , num_b...
332
"""simple docstring""" _lowercase : Any = '\n# Installazione di Transformers\n! pip install transformers datasets\n# Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e\n# rimuovi la modalità commento al comando seguente.\n# ! pip install git+https:/...
332
1
"""simple docstring""" from ..utils import DummyObject, requires_backends class _UpperCAmelCase ( metaclass=_lowerCAmelCase ): a__ : Tuple = ["torch", "scipy"] def __init__( self : str , *_lowercase : Union[str, Any] , **_lowercase :...
332
"""simple docstring""" import importlib.util import os import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import ( is_accelerate_available, is_flax_available, is_safetensors_available, is_tf_available, ...
332
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _lowercase : int = { 'configuration_falcon': ['FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FalconConfig'], } try: ...
332
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list[float] , snake_case_ :list[float] ): __UpperCAmelCase = sorted(numsa + numsa ) __UpperCAmelCase , __UpperCAmelCase = divmod(len(snake_case_ )...
332
1
"""simple docstring""" from multiprocessing import Lock, Pipe, Process # lock used to ensure that two processes do not access a pipe at the same time _lowercase : int = Lock() def lowercase__ ( snake_case_ :Dict , snake_case_ :Tuple , snake_cas...
332
"""simple docstring""" import heapq as hq import math from collections.abc import Iterator class _UpperCAmelCase : def __init__( self : Union[str, Any] , _lowercase : Optional[Any] ): __UpperCAmelCase = str(id_ ) __UpperCAmelCase = None ...
332
1
"""simple docstring""" import warnings warnings.warn( 'memory_utils has been reorganized to utils.memory. Import `find_executable_batchsize` from the main `__init__`: ' '`from accelerate import find_executable_batch_size` to avoid this warning.', FutureWarning, )
332
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _lowercase : str = logging.get_logger(__name__) _lowercase : Dict = { 'microsoft/swinv2-tiny-patch4-window8-256': ( 'https://huggingface.co/microsoft/swin...
332
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_torch_available _lowercase : List[Any] = {'configuration_speech_encoder_decoder': ['SpeechEncoderDecoderConfig']} try: if not is_torch...
332
"""simple docstring""" import pprint import requests _lowercase : Optional[Any] = 'https://zenquotes.io/api' def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + '''/today''' ).json() def lowercase__ ( ): return requests.get(API_ENDPOINT_URL + ...
332
1
"""simple docstring""" from torch import nn def lowercase__ ( snake_case_ :Optional[Any] ): if act_fn in ["swish", "silu"]: return nn.SiLU() elif act_fn == "mish": return nn.Mish() elif act_fn == "gelu": return nn.GELU() else: raise ValueError(F'''Unsupported activa...
332
"""simple docstring""" from typing import List, Optional, Union import numpy as np import tensorflow as tf from .utils import logging _lowercase : List[str] = logging.get_logger(__name__) def lowercase__ ( snake_case_ :Union[tf.Tensor, np.ndarray] ): if isins...
332
1
"""simple docstring""" import math def lowercase__ ( snake_case_ :list , snake_case_ :int ): __UpperCAmelCase = len(snake_case_ ) __UpperCAmelCase = int(math.floor(math.sqrt(snake_case_ ) ) ) __UpperCAmelCase = 0 while arr[min...
332
"""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/LI...
332
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterator from typing import Generic, TypeVar _lowercase : str = TypeVar('T') class _UpperCAmelCase ( Generic[T] ): def __init__( self : Union[str, Any] , _lowercase ...
332
"""simple docstring""" import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, ...
332
1
"""simple docstring""" from __future__ import annotations def lowercase__ ( snake_case_ :list[int | str] ): create_state_space_tree(snake_case_ , [] , 0 , [0 for i in range(len(snake_case_ ) )] ) def lowercase__ ( snake_case_ :l...
332
"""simple docstring""" import unittest import torch from torch import nn from accelerate.test_utils import require_cuda from accelerate.utils.memory import find_executable_batch_size, release_memory def lowercase__ ( ): raise RuntimeError('''CUDA out of memory.''' ) class _Up...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :int = 600_851_475_143 ): try: __UpperCAmelCase = int(snake_case_ ) except (TypeError, ValueError): raise TypeError('''Parameter n must be int or castable to int.''' ) if n <= 0: raise ValueError('''Parameter n mus...
332
"""simple docstring""" import argparse import copy def lowercase__ ( snake_case_ :Tuple ): __UpperCAmelCase = {} with open(snake_case_ ) as f: for line in f: if line.split()[0] not in dict_of_neighbours: __UpperCAmelCase = [] _list.append(...
332
1
"""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, apply_forward_hook from .modeling_utils import ModelMixin from ....
332
"""simple docstring""" import numpy as np from numpy import ndarray from scipy.optimize import Bounds, LinearConstraint, minimize def lowercase__ ( snake_case_ :ndarray ): return np.dot(snake_case_ , snake_case_ ) class _UpperCAmelCase : def __init__( ...
332
1
"""simple docstring""" from typing import Any def lowercase__ ( snake_case_ :list ): if not input_list: return [] __UpperCAmelCase = [input_list.count(snake_case_ ) for value in input_list] __UpperCAmelCase = max(snake_case_ ) # Gets the maximum count ...
332
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule _lowercase : int = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys ...
332
1
"""simple docstring""" def lowercase__ ( snake_case_ :Dict , snake_case_ :List[str] , snake_case_ :str , snake_case_ :Optional[Any] ): global f # a global dp table for knapsack if f[i][j] < 0: if j < wt[i - 1]: __UpperCAmelCase = ...
332
"""simple docstring""" from __future__ import annotations class _UpperCAmelCase : def __init__( self : Tuple , _lowercase : str , _lowercase : str ): __UpperCAmelCase , __UpperCAmelCase = text, pattern __UpperCAmelCase , __Upp...
332
1
import argparse import logging import os from pathlib import Path from typing import Any, Dict import pytorch_lightning as pl from pytorch_lightning.utilities import rank_zero_info from transformers import ( AdamW, AutoConfig, AutoModel, AutoModelForPreTraining, AutoMod...
0
"""simple docstring""" from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class _UpperCAmelCase : a__ : int a__ : Node | None = None a_...
332
0