code
stringlengths
82
54.1k
code_codestyle
int64
0
699
style_context
stringlengths
111
35.6k
style_context_codestyle
int64
0
699
label
int64
0
1
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE__ : str = logging.get_logger(__name__) SCREAMING_SNAKE_CASE__ : Optional[int] = [ ["""...
0
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __a = logging.getLogger(__name__) _...
97
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __snake_case = { '''configuration_groupvit''': [ '''GROUPVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GroupViTConfig''', '''Group...
1
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py __a = 'src/transformers' __a = 'docs/source/en/tasks' ...
97
0
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 lowerCamelCase__ ( datasets.BeamBasedBuilder): """simple docstring""" def snak...
2
from __future__ import annotations __a = 8.988E9 # units = N * m^s * C^-2 def a ( snake_case__: float , snake_case__: float , snake_case__: float , snake_case__: float ): '''simple docstring''' lowercase_ = abs(chargea * chargea ) if (forc...
97
0
'''simple docstring''' def A_( A : list): for i in range(len(A) - 1 , 0 , -1): UpperCamelCase = False for j in range(A , 0 , -1): if unsorted[j] < unsorted[j - 1]: UpperCamelCase , Up...
3
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_...
97
0
"""simple docstring""" import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def _SCREAMING_SNAKE_CASE (): lowerCAmelCase = ArgumentParser( description=( 'PyTorch TPU distributed train...
4
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_...
97
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule _lowercase = {"""processing_wav2vec2_with_lm""": ["""Wav2Vec2ProcessorWithLM"""]} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys _lowerc...
5
def a ( snake_case__: int ): '''simple docstring''' if not isinstance(snake_case__ , snake_case__ ): raise ValueError('''Input must be an integer''' ) if input_num <= 0: raise ValueError('''Input must be positive''' ) return sum( divisor for di...
97
0
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 SCREAMING_SNAKE_CASE__ ( UpperCamelCase__: List[An...
6
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict __a = namedtuple( '_TestCommandArgs', [ 'dataset', ...
97
0
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from...
7
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def a ( snake_case__: List[Any] ): '''simple docstring''' if "cls_token" in name: lowercase_ = name.replace(...
97
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UN...
8
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_bar...
97
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder import...
9
from __future__ import annotations from math import pi, sqrt def a ( snake_case__: float , snake_case__: float ): '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: rais...
97
0
import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class lowerCAmelCase_ ( ctypes.Structure ): # _fields is a specific attr expected by ctypes UpperCAmelCase = [("size", ctypes...
10
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'xlm-mlm-en-2048': 'https://huggingface.co/xlm-mlm-en-2048/re...
97
0
'''simple docstring''' import math def lowerCAmelCase (__A): """simple docstring""" _a = math.loga(math.sqrt(4 * positive_integer + 1) / 2 + 1 / 2) return exponent == int(__A) def lowerCAmelCase (__A = 1 / 12_345): """simple docstring""" _a ...
11
import os # Precomputes a list of the 100 first triangular numbers __a = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def a ( ): '''simple docstring''' lowercase_ = os.path.dirname(os.path.realpath(snake_case__ ) ) lowercase_ = os.path.join(sna...
97
0
import os lowerCamelCase__ : int = {"""I""": 1, """V""": 5, """X""": 1_0, """L""": 5_0, """C""": 1_0_0, """D""": 5_0_0, """M""": 1_0_0_0} def UpperCamelCase ( lowercase_ ) -> int: '''simple docstring''' lowercase__ : Optional[Any] = 0 lowercase__ : L...
12
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('''dataset_size''' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('''input_in_memory_max_size''' , ['''default''', 0, 100 * 2**20, 900 * 2**20] ) def a ( ...
97
0
'''simple docstring''' from ....utils import logging A__ : Tuple = logging.get_logger(__name__) class UpperCAmelCase_ (_UpperCAmelCase ): """simple docstring""" def __init__( self , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_=None , SCREAMING_SNAKE_C...
13
import unittest from knapsack import knapsack as k class lowercase__( unittest.TestCase ): """simple docstring""" def _lowercase ( self : Optional[int] ) -> str: lowercase_ = 0 lowercase_ = [0] lowercase_ = [0] lowercase_ ...
97
0
from __future__ import annotations def __UpperCAmelCase ( __a : str ) -> list[int]: """simple docstring""" return [ord(__a ) - 96 for elem in plain] def __UpperCAmelCase ( __a : list[int] ) -> str: """simple docstring""" ...
14
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { 'vocab_file': 'vocab.json', 'tokenizer_config_file': 'tokenizer_config.json',...
97
0
import json import os import tempfile import unittest import unittest.mock as mock from pathlib import Path from requests.exceptions import HTTPError from transformers.utils import ( CONFIG_NAME, FLAX_WEIGHTS_NAME, TF2_WEIGHTS_NAME, TRANSFORMERS_CACHE, WEIGHTS_NAME, cached...
15
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) class lowercase__( UpperCAmelCase ): """simple docstring""" a :List[str] = 'encoder-decoder' a :Any = Tr...
97
0
import os def __a ( ): SCREAMING_SNAKE_CASE = os.path.join(os.path.dirname(A__ ) , "num.txt" ) with open(A__ ) as file_hand: return str(sum(int(A__ ) for line in file_hand ) )[:10] if __name__ == "__main__": print(so...
16
from __future__ import annotations def a ( snake_case__: Optional[int] , snake_case__: Optional[int] , snake_case__: Any , snake_case__: Optional[int] ): # noqa: E741 '''simple docstring''' while r - l > 1: lowercase_ = (l + r) // 2 if v[m] >=...
97
0
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Tuple = logging.get_logger(__name__) class lowerCamelCase_ ( _lowercase ): _lowercase : Optional[int] = '''encoder-decoder''' _lowercase : str = ...
17
__a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def a ( snake_case__: bytes ): '''simple docstring''' # Make sure the supplied data is a bytes-like object if not isinstance(snake_case__ , snake_case__ ): lowercase_ = F'''...
97
0
'''simple docstring''' import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import sklear...
18
from __future__ import annotations def a ( snake_case__: list[list[int]] ): '''simple docstring''' # preprocessing the first row for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in rang...
97
0
"""simple docstring""" _a = [0, 2, 4, 6, 8] _a = [1, 3, 5, 7, 9] def lowerCamelCase__ ( __snake_case, __snake_case, __snake_case, __snake_case ) -> int: """simple docstring""" if remaining_length == 0: if digits[0] ...
19
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = '▁' __a = {'vocab_file':...
97
0
def _lowercase( __a : str , __a : str ): assert x is not None assert y is not None a__ =len(__a ) a__ =len(__a ) # declaring the array for storing the dp values a__ =[[0] * (n + 1) for _ in range(m + 1 )] # noqa:...
20
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'facebook/wav2vec2-base-960h': 'https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json', # See al...
97
0
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor UpperCAmelCase_ : Union[str, Any] = logging.getLogger(__name__) Upper...
21
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 a ( snake_case__: Any ...
97
0
'''simple docstring''' from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils impo...
22
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __a = logging.getLogger(__name__) _...
97
0
import torch from torch import nn from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class _a ( UpperCAmelCase__ , UpperCAmelCase__ ): """simple docstring""" @register_to_config def __init__( ...
23
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py __a = 'src/transformers' __a = 'docs/source/en/tasks' ...
97
0
'''simple docstring''' import argparse import json import os import sys import tempfile import unittest from argparse import Namespace from dataclasses import dataclass, field from enum import Enum from pathlib import Path from typing import List, Literal, Optional import yaml from transformers import HfArgum...
24
from __future__ import annotations __a = 8.988E9 # units = N * m^s * C^-2 def a ( snake_case__: float , snake_case__: float , snake_case__: float , snake_case__: float ): '''simple docstring''' lowercase_ = abs(chargea * chargea ) if (forc...
97
0
from __future__ import annotations def lowerCamelCase__ ( _a): if len(_a) == 0: return [] SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Tuple = min(_a), max(_a) SCREAMING_SNAKE_CASE : Dict = int(max_value - min_value) + 1 SCREAMING_SNAKE_CASE : list[list] = ...
25
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_...
97
0
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCamelCase = { "configuration_mctct": ["MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MCTCTConfig"], "feature_extraction_mctct":...
26
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_...
97
0
import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ) def __lowerCAmelCase( ...
27
def a ( snake_case__: int ): '''simple docstring''' if not isinstance(snake_case__ , snake_case__ ): raise ValueError('''Input must be an integer''' ) if input_num <= 0: raise ValueError('''Input must be positive''' ) return sum( divisor for di...
97
0
'''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_com...
28
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict __a = namedtuple( '_TestCommandArgs', [ 'dataset', ...
97
0
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMScheduler, DPMSolverMultistepIn...
29
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def a ( snake_case__: List[Any] ): '''simple docstring''' if "cls_token" in name: lowercase_ = name.replace(...
97
0
from ..utils import DummyObject, requires_backends class __a( metaclass=_a ): """simple docstring""" lowerCAmelCase = ['''torch''', '''torchsde'''] def __init__( self ,*_SCREAMING_SNAKE_CASE ,**_SCREAMING_SNAKE_CASE ) -> Union[str, Any]: requires_bac...
30
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_bar...
97
0
lowerCamelCase__ : int = 8.314_4598 def UpperCAmelCase_ ( __UpperCAmelCase : float , __UpperCAmelCase : float ) -> float: if temperature < 0: raise Exception('Temperature cannot be less than 0 K' ) if molar_mass <= 0: ra...
31
from __future__ import annotations from math import pi, sqrt def a ( snake_case__: float , snake_case__: float ): '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: rais...
97
0
from typing import Dict, List, Optional, Tuple, Union import torch from ...models import AutoencoderKL, TransformeraDModel from ...schedulers import KarrasDiffusionSchedulers from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __UpperCamelCase ( ...
32
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'xlm-mlm-en-2048': 'https://huggingface.co/xlm-mlm-en-2048/re...
97
0
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_image_inpu...
33
import os # Precomputes a list of the 100 first triangular numbers __a = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def a ( ): '''simple docstring''' lowercase_ = os.path.dirname(os.path.realpath(snake_case__ ) ) lowercase_ = os.path.join(sna...
97
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging SCREAMING_SNAKE_CASE_ = logging.get_logger(__name__) SCREAMING_S...
34
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('''dataset_size''' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('''input_in_memory_max_size''' , ['''default''', 0, 100 * 2**20, 900 * 2**20] ) def a ( ...
97
0
import argparse import json import torch from diffusers import DDPMScheduler, LDMPipeline, UNetaDModel, VQModel def a ( A__ , A__=1 ) -> int: '''simple docstring''' if n_shave_prefix_segments >= 0: return ".".join(path.split('''.''' )[n_shave_prefix_s...
35
import unittest from knapsack import knapsack as k class lowercase__( unittest.TestCase ): """simple docstring""" def _lowercase ( self : Optional[int] ) -> str: lowercase_ = 0 lowercase_ = [0] lowercase_ = [0] lowercase_ ...
97
0
def lowercase ( __A : int = 400_0000 ) -> int: '''simple docstring''' snake_case : int = [] snake_case , snake_case : Any = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(__A ) snake_case , snake_ca...
36
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { 'vocab_file': 'vocab.json', 'tokenizer_config_file': 'tokenizer_config.json',...
97
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase : Optional[Any] = logging.get_logger(__name__) UpperCamelCase : str = { """EleutherAI/gpt-neox-20b""": """https://huggingface.co/EleutherAI/gpt-neox-20b/resolve/main/config.j...
37
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) class lowercase__( UpperCAmelCase ): """simple docstring""" a :List[str] = 'encoder-decoder' a :Any = Tr...
97
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class __snake_case ( metaclass=__SCREAMING_SNAKE_CASE ): '''simple docstring''' lowerCamelCase__ = ['''torch'''] def __init__( self , *__SCREAMING_SNAKE_CASE , **__SCREAMING_...
38
from __future__ import annotations def a ( snake_case__: Optional[int] , snake_case__: Optional[int] , snake_case__: Any , snake_case__: Optional[int] ): # noqa: E741 '''simple docstring''' while r - l > 1: lowercase_ = (l + r) // 2 if v[m] >=...
97
0
def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ ): if length <= 0 or not isinstance(SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): raise ValueError('''Length must be a positive integer.''' ) return [n * (2 * n - 1) for n in range(SCREAMING_SNAKE_CASE__ )] ...
39
__a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def a ( snake_case__: bytes ): '''simple docstring''' # Make sure the supplied data is a bytes-like object if not isinstance(snake_case__ , snake_case__ ): lowercase_ = F'''...
97
0
from __future__ import annotations import queue class lowerCAmelCase_ : def __init__( self, SCREAMING_SNAKE_CASE_ ) -> Optional[int]: UpperCamelCase : Optional[Any] = data UpperCamelCase : Any = None UpperC...
40
from __future__ import annotations def a ( snake_case__: list[list[int]] ): '''simple docstring''' # preprocessing the first row for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in rang...
97
0
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property fr...
41
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = '▁' __a = {'vocab_file':...
97
0
'''simple docstring''' import math from ...configuration_utils import PretrainedConfig from ...utils import logging A_ = logging.get_logger(__name__) A_ = { "facebook/data2vec-base-960h": "https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main/config.json", # See all Data2VecAudio mode...
42
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'facebook/wav2vec2-base-960h': 'https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json', # See al...
97
0
def _a ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): """simple docstring""" print('''\nThe shortest path matrix using Floyd Warshall algorithm\n''' ) for i in range(SCREAMING_SNAKE_CASE ): for j in range(SCREAMING_SNAKE_CASE ): if dist[i][j] != float('''inf''' )...
43
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 a ( snake_case__: Any ...
97
0
'''simple docstring''' import functools def A_ ( _lowerCAmelCase : list[int] , _lowerCAmelCase : list[int] ): """simple docstring""" if not isinstance(_lowerCAmelCase , _lowerCAmelCase ) or not all(isinstance(_lowerCAmelCase , _lower...
44
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __a = logging.getLogger(__name__) _...
97
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import XLMRobertaTokenizerFast from diffusers import DDIMScheduler, KandinskyInpaintPipeline, KandinskyPriorPipeline, UNetaDConditionModel, VQModel from diffusers.pipelines.kandinsky.text_encoder imp...
45
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py __a = 'src/transformers' __a = 'docs/source/en/tasks' ...
97
0
"""simple docstring""" import argparse import os import gluonnlp as nlp import mxnet as mx import numpy as np import torch from gluonnlp.base import get_home_dir from gluonnlp.model.bert import BERTEncoder from gluonnlp.model.utils import _load_vocab from gluonnlp.vocab import Vocab from packaging import vers...
46
from __future__ import annotations __a = 8.988E9 # units = N * m^s * C^-2 def a ( snake_case__: float , snake_case__: float , snake_case__: float , snake_case__: float ): '''simple docstring''' lowercase_ = abs(chargea * chargea ) if (forc...
97
0
from __future__ import annotations import math def UpperCAmelCase__ ( lowerCamelCase_ : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, al...
47
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_...
97
0
'''simple docstring''' # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
48
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_...
97
0
"""simple docstring""" def lowercase__ ( snake_case_ :float , snake_case_ :float ): if density <= 0: raise ValueError('''Impossible fluid density''' ) if bulk_modulus <= 0: raise ValueError('''Impossible bulk modulus''' ) return (bulk_modulus / density) ** 0...
49
def a ( snake_case__: int ): '''simple docstring''' if not isinstance(snake_case__ , snake_case__ ): raise ValueError('''Input must be an integer''' ) if input_num <= 0: raise ValueError('''Input must be positive''' ) return sum( divisor for di...
97
0
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class UpperCamelCase__ (a ): '''simple docstring''' def __init__( self ): # test for the above condition self.test() def UpperCamelCase_ ( ...
50
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict __a = namedtuple( '_TestCommandArgs', [ 'dataset', ...
97
0
'''simple docstring''' import gc import unittest import numpy as np import torch from diffusers import AutoencoderKL, DDIMScheduler, DiTPipeline, DPMSolverMultistepScheduler, TransformeraDModel from diffusers.utils import is_xformers_available, load_numpy, slow, torch_device from diffusers.utils.testing_utils...
51
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def a ( snake_case__: List[Any] ): '''simple docstring''' if "cls_token" in name: lowercase_ = name.replace(...
97
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { '''microsoft/trocr-base-handwritten''': ( '''https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main...
52
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_bar...
97
0
import unittest import numpy as np from transformers import DistilBertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax.numpy as jnp ...
53
from __future__ import annotations from math import pi, sqrt def a ( snake_case__: float , snake_case__: float ): '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: rais...
97
0
def a__ ( lowercase__ , lowercase__ , lowercase__ , lowercase__ , lowercase__ , ): '''simple docstring''' UpperCAmelCase_ =[redshift, radiation_density, matter_density, dark_energy] if any(p < 0 for p in parameters ): rais...
54
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'xlm-mlm-en-2048': 'https://huggingface.co/xlm-mlm-en-2048/re...
97
0
import argparse import os import transformers from .convert_slow_tokenizer import SLOW_TO_FAST_CONVERTERS from .utils import logging logging.set_verbosity_info() SCREAMING_SNAKE_CASE :Optional[int] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE :Tuple = {name: getattr(tran...
55
import os # Precomputes a list of the 100 first triangular numbers __a = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def a ( ): '''simple docstring''' lowercase_ = os.path.dirname(os.path.realpath(snake_case__ ) ) lowercase_ = os.path.join(sna...
97
0
'''simple docstring''' import importlib import math import os from dataclasses import dataclass from enum import Enum from typing import Any, Dict, Optional, Tuple, Union import flax import jax.numpy as jnp from ..utils import BaseOutput _a : Optional[int] = "scheduler_config.json" class...
56
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('''dataset_size''' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('''input_in_memory_max_size''' , ['''default''', 0, 100 * 2**20, 900 * 2**20] ) def a ( ...
97
0
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, floats_...
57
import unittest from knapsack import knapsack as k class lowercase__( unittest.TestCase ): """simple docstring""" def _lowercase ( self : Optional[int] ) -> str: lowercase_ = 0 lowercase_ = [0] lowercase_ = [0] lowercase_ ...
97
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inp...
58
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { 'vocab_file': 'vocab.json', 'tokenizer_config_file': 'tokenizer_config.json',...
97
0
import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accele...
59
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) class lowercase__( UpperCAmelCase ): """simple docstring""" a :List[str] = 'encoder-decoder' a :Any = Tr...
97
0
import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.processors import TemplateProcessing ...
60
from __future__ import annotations def a ( snake_case__: Optional[int] , snake_case__: Optional[int] , snake_case__: Any , snake_case__: Optional[int] ): # noqa: E741 '''simple docstring''' while r - l > 1: lowercase_ = (l + r) // 2 if v[m] >=...
97
0
from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import FlaxTimes...
61
__a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def a ( snake_case__: bytes ): '''simple docstring''' # Make sure the supplied data is a bytes-like object if not isinstance(snake_case__ , snake_case__ ): lowercase_ = F'''...
97
0
from sympy import diff, lambdify, symbols from sympy.functions import * # noqa: F403 def lowerCamelCase__ ( lowercase , lowercase , lowercase = "x" , lowercase = 10**-10 , lowercase = 1 , ): """simple docstring""" SCREAMING_SNAKE_CASE : List[Any] = sy...
62
from __future__ import annotations def a ( snake_case__: list[list[int]] ): '''simple docstring''' # preprocessing the first row for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in rang...
97
0
# 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 # # Unless...
63
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = '▁' __a = {'vocab_file':...
97
0
def A__ ( snake_case_ : int | float | str ): try: SCREAMING_SNAKE_CASE__: Optional[Any]= float(snake_case_ ) except ValueError: raise ValueError('''Please enter a valid number''' ) SCREAMING_SNAKE_CASE__: Tuple= decimal - int(snake_case_ ) if fractional_part == 0: return int(snake_...
64
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'facebook/wav2vec2-base-960h': 'https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json', # See al...
97
0
"""simple docstring""" from collections.abc import Callable class __lowercase : def __init__( self : Tuple ,A : Callable | None = None ): '''simple docstring''' # Stores actual heap items. UpperCAmelCase__ : list = ...
65
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 a ( snake_case__: Any ...
97
0
from ....configuration_utils import PretrainedConfig from ....utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { "Visual-Attention-Network/van-base": ( "https://huggingface.co/Visual-Attention-Network/van-base/blob/main/config.json" ), } clas...
66
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __a = logging.getLogger(__name__) _...
97
0
import argparse import OmegaConf import torch from diffusers import DDIMScheduler, LDMPipeline, UNetLDMModel, VQModel def SCREAMING_SNAKE_CASE__ ( snake_case__ :List[Any] , snake_case__ :Union[str, Any] , snake_case__ :Any ) -> Dict: _lowercase = Omega...
67
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py __a = 'src/transformers' __a = 'docs/source/en/tasks' ...
97
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __A = { "configuration_clap": [ "CLAP_PRETRAINED_MODEL_ARCHIVE_LIST", "ClapAudioConfig", "ClapConfig", "ClapTextConfig", ], "processing_clap": [...
68
from __future__ import annotations __a = 8.988E9 # units = N * m^s * C^-2 def a ( snake_case__: float , snake_case__: float , snake_case__: float , snake_case__: float ): '''simple docstring''' lowercase_ = abs(chargea * chargea ) if (forc...
97
0
'''simple docstring''' import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class SCREAMING_SNAKE_CASE__ ( _UpperCamelCase ): __SCREAMING_SNAKE_CASE = (KDPMaDiscreteScheduler,) __S...
69
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_...
97
0
def _SCREAMING_SNAKE_CASE ( lowercase : str , lowercase : bool = False ): '''simple docstring''' if not isinstance(lowercase , lowercase ): lowerCamelCase_ = f"""Expected string as input, found {type(lowercase )}""" ...
70
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_...
97
0
'''simple docstring''' import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing impo...
71
def a ( snake_case__: int ): '''simple docstring''' if not isinstance(snake_case__ , snake_case__ ): raise ValueError('''Input must be an integer''' ) if input_num <= 0: raise ValueError('''Input must be positive''' ) return sum( divisor for di...
97
0
'''simple docstring''' import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from ...
72
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict __a = namedtuple( '_TestCommandArgs', [ 'dataset', ...
97
0
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _snake_case ( A__ ): _lowercase : Dict = ['''image_processor''', '''tokenizer'''] _lowercase : Optional[Any] = '''AutoImageProcessor''' _lowercase : List[...
73
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def a ( snake_case__: List[Any] ): '''simple docstring''' if "cls_token" in name: lowercase_ = name.replace(...
97
0
import os def a__ ( ): """simple docstring""" __SCREAMING_SNAKE_CASE : Union[str, Any] = os.path.join(os.path.dirname(snake_case ) , '''num.txt''' ) with open(snake_case ) as file_hand: return str(sum(int(snake_case ) for line in file_hand ...
74
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_bar...
97
0
'''simple docstring''' import unittest from accelerate import debug_launcher from accelerate.test_utils import require_cpu, test_ops, test_script @require_cpu class lowerCamelCase_ ( unittest.TestCase ): def lowercase_ ( self : int ): ...
75
from __future__ import annotations from math import pi, sqrt def a ( snake_case__: float , snake_case__: float ): '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: rais...
97
0
"""simple docstring""" import warnings from ...utils import logging from .image_processing_layoutlmva import LayoutLMvaImageProcessor a_ = logging.get_logger(__name__) class UpperCAmelCase_ ( snake_case ): def __init__( self , *UpperCamelCase_ , ...
76
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'xlm-mlm-en-2048': 'https://huggingface.co/xlm-mlm-en-2048/re...
97
0
"""simple docstring""" from __future__ import annotations from collections.abc import Callable def _UpperCamelCase ( UpperCamelCase , UpperCamelCase , UpperCamelCase , UpperCamelCase = 100 , ) -> float: """simple docstring""" __UpperC...
77
import os # Precomputes a list of the 100 first triangular numbers __a = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def a ( ): '''simple docstring''' lowercase_ = os.path.dirname(os.path.realpath(snake_case__ ) ) lowercase_ = os.path.join(sna...
97
0
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from ..image_utils import load_image if is_torch_available()...
78
import pytest import datasets.config from datasets.utils.info_utils import is_small_dataset @pytest.mark.parametrize('''dataset_size''' , [None, 400 * 2**20, 600 * 2**20] ) @pytest.mark.parametrize('''input_in_memory_max_size''' , ['''default''', 0, 100 * 2**20, 900 * 2**20] ) def a ( ...
97
0
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .toke...
79
import unittest from knapsack import knapsack as k class lowercase__( unittest.TestCase ): """simple docstring""" def _lowercase ( self : Optional[int] ) -> str: lowercase_ = 0 lowercase_ = [0] lowercase_ = [0] lowercase_ ...
97
0
from ...configuration_utils import PretrainedConfig from ...utils import logging __UpperCamelCase : Optional[Any] = logging.get_logger(__name__) __UpperCamelCase : int = { """caidas/swin2sr-classicalsr-x2-64""": ( """https://huggingface.co/caidas/swin2sr-classicalsr-x2-64/r...
80
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = { 'vocab_file': 'vocab.json', 'tokenizer_config_file': 'tokenizer_config.json',...
97
0
import torch import torch.nn as nn from transformers.modeling_utils import ModuleUtilsMixin from transformers.models.ta.modeling_ta import TaBlock, TaConfig, TaLayerNorm from ...configuration_utils import ConfigMixin, register_to_config from ...models import ModelMixin class a (_lowerCAmelCase , ...
81
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) class lowercase__( UpperCAmelCase ): """simple docstring""" a :List[str] = 'encoder-decoder' a :Any = Tr...
97
0
"""simple docstring""" import unittest import numpy as np from transformers.file_utils import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_imag...
82
from __future__ import annotations def a ( snake_case__: Optional[int] , snake_case__: Optional[int] , snake_case__: Any , snake_case__: Optional[int] ): # noqa: E741 '''simple docstring''' while r - l > 1: lowercase_ = (l + r) // 2 if v[m] >=...
97
0
"""simple docstring""" import faiss # noqa: F401 # Here to have a nice missing dependency error message early on import numpy # noqa: F401 # Here to have a nice missing dependency error message early on import requests # noqa: F401 # Here to have a nice missing dependency error message early on import skle...
83
__a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def a ( snake_case__: bytes ): '''simple docstring''' # Make sure the supplied data is a bytes-like object if not isinstance(snake_case__ , snake_case__ ): lowercase_ = F'''...
97
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { '''facebook/data2vec-text-base''': '''https://huggi...
84
from __future__ import annotations def a ( snake_case__: list[list[int]] ): '''simple docstring''' # preprocessing the first row for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in rang...
97
0
def _a ( lowercase__ : int = 2_00 ): '''simple docstring''' SCREAMING_SNAKE_CASE__ : Dict = [1, 2, 5, 10, 20, 50, 1_00, 2_00] SCREAMING_SNAKE_CASE__ : int = [0] * (pence + 1) SCREAMING_SNAKE_CASE__ : Dict = 1 # base case: 1 way to...
85
import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __a = logging.get_logger(__name__) __a = '▁' __a = {'vocab_file':...
97
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __a :Optional[int] = { 'configuration_git': ['GIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GitConfig', 'GitVisionConfig'], 'processing_git': ['GitProcessor'], } try: i...
86
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'facebook/wav2vec2-base-960h': 'https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json', # See al...
97
0
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 from diffusers.utils import load_numpy, s...
87
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 a ( snake_case__: Any ...
97
0
"""simple docstring""" def _snake_case ( __snake_case : list ): """simple docstring""" 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""" ) ...
88
import argparse import logging import os import re import tensorflow as tf from transformers import ( AutoConfig, AutoTokenizer, DataCollatorForLanguageModeling, PushToHubCallback, TFAutoModelForMaskedLM, create_optimizer, ) __a = logging.getLogger(__name__) _...
97
0
def UpperCamelCase_( lowerCamelCase_ ) -> str: if number > 0: raise ValueError('input must be a negative integer' ) _lowercase : Any = len(bin(lowerCamelCase_ )[3:] ) _lowercase : List[Any] = bin(abs(lowerCamelCase_ ) - (1 << binar...
89
import argparse import os from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_task_guides.py __a = 'src/transformers' __a = 'docs/source/en/tasks' ...
97
0
'''simple docstring''' import argparse import torch from torch import nn from transformers import MBartConfig, MBartForConditionalGeneration def _snake_case ( A ) -> Any: lowerCAmelCase__ = [ '''encoder.version''', '''decoder.version''...
90
from __future__ import annotations __a = 8.988E9 # units = N * m^s * C^-2 def a ( snake_case__: float , snake_case__: float , snake_case__: float , snake_case__: float ): '''simple docstring''' lowercase_ = abs(chargea * chargea ) if (forc...
97
0
"""simple docstring""" import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowerCAmelCase_ ( unittest.TestCase ): '''simple docstring''' def _SCREAMING_SNAKE_CASE ( self : Tuple ) -> Dict: A = [ 'sa...
91
from __future__ import annotations import unittest from transformers import DebertaVaConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_...
97
0
'''simple docstring''' import unittest from transformers import BertGenerationTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_torch, slow from transformers.utils import cached_property from ...test_tokenization_common import TokenizerTesterMixin UpperCamelCase_ ...
92
import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, require_...
97
0
"""simple docstring""" def __A (_SCREAMING_SNAKE_CASE ) ->str: """simple docstring""" if isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ): raise TypeError('\'float\' object cannot be interpreted as an integer' ) if isinstance(_SCREAMING_SNAKE_CASE , _SCREAMING...
93
def a ( snake_case__: int ): '''simple docstring''' if not isinstance(snake_case__ , snake_case__ ): raise ValueError('''Input must be an integer''' ) if input_num <= 0: raise ValueError('''Input must be positive''' ) return sum( divisor for di...
97
0
'''simple docstring''' from __future__ import annotations import math from collections import Counter from string import ascii_lowercase def lowercase_ ( __A : str ) -> None: """simple docstring""" lowercase , lowercase : Any =analyze_text(__A ) l...
94
import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict __a = namedtuple( '_TestCommandArgs', [ 'dataset', ...
97
0
"""simple docstring""" import argparse import json import os import evaluate import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed ...
95
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def a ( snake_case__: List[Any] ): '''simple docstring''' if "cls_token" in name: lowercase_ = name.replace(...
97
0
"""simple docstring""" import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets __lowerCamelCase = datasets.logging.get_logger(__name__) __lowerCamelCase = '\\n@inproceedings{bleurt,\n title={BLEURT: Learning Ro...
96
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_bar...
97
0
'''simple docstring''' import platform from argparse import ArgumentParser import huggingface_hub from .. import __version__ as version from ..utils import is_accelerate_available, is_torch_available, is_transformers_available, is_xformers_available from . import BaseDiffusersCLICommand def a__ ...
98
from __future__ import annotations from math import pi, sqrt def a ( snake_case__: float , snake_case__: float ): '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be 0 or negative''' ) elif capacitance <= 0: rais...
97
0
def a (lowerCAmelCase__ ): # noqa: E741 __a = len(lowerCAmelCase__ ) __a = 0 __a = [0] * n __a = [False] * n __a = [False] * n def dfs(lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ): if parent == root: ...
99
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __a = logging.get_logger(__name__) __a = { 'xlm-mlm-en-2048': 'https://huggingface.co/xlm-mlm-en-2048/re...
97
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _A : str = { """configuration_albert""": ["""ALBERT_PRE...
100
import os # Precomputes a list of the 100 first triangular numbers __a = [int(0.5 * n * (n + 1)) for n in range(1, 1_0_1)] def a ( ): '''simple docstring''' lowercase_ = os.path.dirname(os.path.realpath(snake_case__ ) ) lowercase_ = os.path.join(sna...
97
0