code
stringlengths
86
54.5k
code_codestyle
int64
0
371
style_context
stringlengths
87
49.2k
style_context_codestyle
int64
0
349
label
int64
0
1
def a__ ( A_ ): '''simple docstring''' __magic_name__ = 0 __magic_name__ = len(A_ ) for i in range(n - 1 ): for j in range(i + 1, A_ ): if arr[i] > arr[j]: num_inversions += 1 return num_inversions ...
88
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowerCamelCase_ : Any = logging.get_...
81
0
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { '''facebook/xlm-roberta-xl''': '''https://h...
211
from itertools import product from cva import COLOR_BGR2GRAY, cvtColor, imread, imshow, waitKey from numpy import dot, exp, mgrid, pi, ravel, square, uinta, zeros def lowerCamelCase_ ( _a , _a ): """simple docstring""" lowerCAmelCase__ : List[...
211
1
import os import pytest from transformers.dynamic_module_utils import get_imports lowerCAmelCase : str = """ import os """ lowerCAmelCase : Optional[Any] = """ def foo(): import os return False """ lowerCAmelCase : str = """ def foo(): def bar(): ...
13
"""simple docstring""" import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTes...
44
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 cl...
369
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : str = 0 __lowerCamelCase : Tuple = len(SCREAMING_SNAKE_CASE__ ) for i in range(n - 1 ): for j in range(i + 1 , SCREAMING_SNAKE_CASE__ ): if arr[i] > arr[j]: num_inversions +=...
194
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 _UpperCamelCase : str = logging.get_logger(__name__) _UpperCamelCas...
77
"""simple docstring""" import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class UpperCAmelCase_ : def __init__( self , a ) -> List[str]: if isinstance(a ...
77
1
"""simple docstring""" from __future__ import annotations from collections.abc import Iterable, Iterator from dataclasses import dataclass __A = (3, 9, -11, 0, 7, 5, 1, -1) __A = (4, 6, 2, 0, 8, 10, 3, -2) @dataclass class snake_case : SCREAMING...
108
"""simple docstring""" def a__ ( __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE ) -> int: return int((input_a, input_a).count(0 ) == 0 ) def a__ ( ) -> None: assert and_gate(0 , 0 ) == 0 assert and_gate(0 , 1 ) == 0 assert and_gate(1 , 0...
108
1
'''simple docstring''' import argparse import torch from transformers import YosoConfig, YosoForMaskedLM def UpperCamelCase__ ( lowerCAmelCase ): """simple docstring""" if "model" in orig_key: _lowerCAmelCase = orig_key....
70
"""simple docstring""" from unittest.mock import Mock, patch from file_transfer.send_file import send_file @patch("socket.socket" ) @patch("builtins.open" ) def _SCREAMING_SNAKE_CASE ( _lowercase : List[Any] , _lowercase : int ) ->str: ...
105
0
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFAutoModel, is_tensorflow_text_available, is_tf_available from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.testing_utils import require_tensorflow_text, require_t...
305
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowerCamelCase (SCREAMING_SNAKE_CASE__ ): ""...
305
1
"""simple docstring""" import re import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class lowercase ( __a ): _SCREAMING_SNAKE_CASE = ['''image_processor''', '''tokenizer'''] _SCREAMING_SNAKE_CASE = '''AutoImagePro...
46
from maths.prime_check import is_prime def snake_case_ ( lowerCAmelCase_ : int ): if not isinstance(lowerCAmelCase_ , lowerCAmelCase_ ): __lowercase : Dict = F"Input value of [number={number}] must be an integer" raise TypeError(lower...
233
0
'''simple docstring''' from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def A__ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ ): if not arr: return None, None, 0 ...
236
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, loggin...
236
1
from __future__ import annotations from collections import deque from collections.abc import Sequence from dataclasses import dataclass from typing import Any @dataclass class a__ : """simple docstring""" __lowerCamelCase = 42 __lowerCamelCase = None __lowerCamelCas...
68
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_base import BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import PaddingStrategy, logging from .tokenization_realm import Re...
301
0
def A_ ( A__ , A__ ) -> str: if not isinstance(A__ , A__ ): raise ValueError('iterations must be defined as integers' ) if not isinstance(A__ , A__ ) or not number >= 1: raise ValueError( 'starting number must be\n ...
225
import glob import os import random from string import ascii_lowercase, digits import cva lowercase : Optional[Any] = """""" lowercase : int = """""" lowercase : List[Any] = """""" lowercase : Optional[int] = 1 # (0 is vertical, 1 is horizontal) def...
225
1
'''simple docstring''' # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # ...
47
'''simple docstring''' class A__ : def __init__( self : Union[str, Any] , _a : int ) -> None: '''simple docstring''' _SCREAMING_SNAKE_CASE =size _SCREAMING_SNAKE_CASE =[0] * size _SCREAMING_SNAKE_CASE =[0] * ...
47
1
_UpperCamelCase: List[str] = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _UpperCamelCase: List[Any] = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] _UpperCamelCase: Any = { 0: 'Sunday', 1: 'Monday', 2: 'Tuesday', 3: 'Wednesday', 4: 'Thursday', ...
361
"""simple docstring""" from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, ...
53
0
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import KarrasVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class lowercase__( UpperCAmelCase ): """simple do...
30
"""simple docstring""" import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def lowerCAmelCase_ ( snake_case_ : Dict , snake_case_ : str , snake_case_ : str ,...
126
0
"""simple docstring""" import gc import unittest from diffusers import FlaxStableDiffusionInpaintPipeline from diffusers.utils import is_flax_available, load_image, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax.numpy as jnp from fl...
85
"""simple docstring""" # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE...
85
1
"""simple docstring""" import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassific...
165
"""simple docstring""" import copy from collections import OrderedDict from typing import Dict, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging from ..auto import CONFIG_MAPPING A_ : ...
165
1
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin, TensorType A_ : Tuple = logging.get_logge...
141
from __future__ import annotations def UpperCamelCase (lowercase_: list[int] , lowercase_: list[int] , lowercase_: int ) -> tuple[float, list[float]]: A__ : Tuple = list(range(len(lowercase_ ) ) ) A__ : Union[str, Any] = [v / w for v, w in zip(lo...
141
1
import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import parquet from .sql import sql # noqa F401 f...
262
def lowerCAmelCase ( lowerCAmelCase_ )-> set: lowerCAmelCase_ : Optional[int] = set() # edges = list of graph's edges lowerCAmelCase_ : List[str] = get_edges(lowerCAmelCase_ ) # While there are still elements in edges list, take an arbitrary ed...
262
1
"""simple docstring""" import argparse import math import traceback import dateutil.parser as date_parser import requests def snake_case (A_ :List[str] ): '''simple docstring''' a : str = {} a : str = job['started_at'] a : Tuple ...
186
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE, XLNetTokenizer, XLNetTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _UpperCamelCase : List...
186
1
"""simple docstring""" import os def UpperCAmelCase ( ) -> Union[str, Any]: with open(os.path.dirname(UpperCAmelCase ) + '/p022_names.txt' ) as file: snake_case_ = str(file.readlines()[0] ) snake_case_ = names.replace('"' ...
69
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_torch_available, ) lowerCAmelCase_ = { 'configuration_speecht5': [ 'SPEECHT5_PRETRAINED_C...
16
0
def _lowercase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ) -> List[str]: '''simple docstring''' if index == r: for j in range(UpperCamelCase_ ): print(data...
369
from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def _lowercase ( UpperCamelCase_ ) -> bool: '''simple docstring''' SCREAMING_SNAKE_CASE__ = int(number**0.5 ) return number == sq * sq def _lowercase ...
169
0
import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def __UpperCamelCase ( _lowerCAmelCase=None ...
116
import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE_:List[Any] = """▁""" SCREAMING_SNAKE_CASE_:int = {"""vo...
116
1
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class __lowerCamelCase ( unittest.TestCase ): """simple docstring""" def a ( self : List[Any] ) -> N...
221
import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class __lowerCamelCase ( UpperCamelCase__ ): """simple docstring""" snake_case__ = "Speech2TextFeatureExtractor" snake_case__ = "Speech2TextTokenizer" ...
221
1
import numpy as np import pandas as pd from sklearn.preprocessing import MinMaxScaler from tensorflow.keras.layers import LSTM, Dense from tensorflow.keras.models import Sequential if __name__ == "__main__": _snake_case = pd.read_csv("sample_data.csv", header=None) _snake_case = df.shape[:1][0] ...
36
import inspect import unittest from transformers import RegNetConfig, is_flax_available from transformers.testing_utils import require_flax, slow from transformers.utils import cached_property, is_vision_available from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxMode...
299
0
"""simple docstring""" from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable SCREAMING_SNAKE_CASE : Optional[Any] = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_...
24
"""simple docstring""" def lowercase ( ) ->int: """simple docstring""" return [ a * b * (1_000 - a - b) for a in range(1 , 999 ) for b in range(_snake_case , 999 ) if (a * a + b * b == (1_000 - a - b) ** 2) ][0] if __name__ == "__main__": p...
24
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCamelCase : str = { 'configuration_poolformer': [ 'POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'PoolFormerConfig', ...
258
'''simple docstring''' def __a ( UpperCAmelCase , UpperCAmelCase ) ->int: """simple docstring""" return int((input_a, input_a).count(1 ) != 0 ) def __a ( ) ->None: """simple docstring""" assert or_gate(0 , 0 ) == 0 assert or_gate(0 ...
258
1
import logging from transformers.configuration_utils import PretrainedConfig _snake_case = logging.getLogger(__name__) class lowercase ( lowerCAmelCase_ ): _a = 'masked_bert' def __init__( self , _a=3_0522 , _a=768 , _a=12 , _a=12 , _...
358
import inspect import unittest from transformers import ConvNextConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTesterMixin from ...t...
343
0
'''simple docstring''' import argparse import logging import os import datasets import tensorflow as tf from transformers import AutoTokenizer __UpperCAmelCase =logging.getLogger(__name__) def __lowerCAmelCase ( ) -> int: __lowerCamelCase = argparse.ArgumentParser( descri...
67
"""simple docstring""" # Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
109
0
import numpy as np import pandas as pd from sklearn.preprocessing import Normalizer from sklearn.svm import SVR from statsmodels.tsa.statespace.sarimax import SARIMAX def a__ ( UpperCAmelCase : list , UpperCAmelCase : list , UpperCAmelCase : list , UpperCAme...
99
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import ...
99
1
"""simple docstring""" import copy import inspect import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import TimesformerConfig from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, ...
78
"""simple docstring""" import requests snake_case_ = """""" # <-- Put your OpenWeatherMap appid here! snake_case_ = """https://api.openweathermap.org/data/2.5/""" def _lowerCAmelCase ( lowercase_ = "Chicago" , lowercase_ = APPID ): return requests.ge...
78
1
import copy from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils i...
250
from __future__ import annotations from math import pi, sqrt def _a ( lowerCamelCase: float , lowerCamelCase: float ) -> tuple: '''simple docstring''' if inductance <= 0: raise ValueError('''Inductance cannot be ...
250
1
import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizerBase def _SCREAMING_SN...
186
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging UpperCamelCase = logging.get_logger(__name__) UpperCamelCase = { """t5-small""": """https://huggingface.co/t5-small/resolve/main/config.json"...
186
1
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_camembert import ...
370
import importlib import torch import yaml from omegaconf import OmegaConf from taming.models.vqgan import VQModel def lowerCamelCase_ ( lowerCamelCase__ , lowerCamelCase__=False ): lowerCamelCase_ = OmegaConf.load(lowerCamelCase__ ) if display: print(yaml.dump(Omega...
47
0
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: from ...util...
15
'''simple docstring''' import json import pathlib import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision, slow from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, pre...
324
0
'''simple docstring''' import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from...
367
'''simple docstring''' import argparse import re from flax.traverse_util import flatten_dict, unflatten_dict from tax import checkpoints from transformers import SwitchTransformersConfig, SwitchTransformersForConditionalGeneration from transformers.modeling_flax_pytorch_utils import load_flax_weights_in...
280
0
'''simple docstring''' import os from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen, xsplitext from ..table imp...
200
'''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_inputs if is_torch_ava...
200
1
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class a_ ( snake_case_ ): '''simple docstring''' lowerCamelCase__ : Dict = ['image_processor', 'tokenizer'] lowerCamelCase__...
316
"""simple docstring""" from __future__ import annotations import queue class a_ : '''simple docstring''' def __init__(self, lowerCamelCase_ ): '''simple docstring''' lowerCamelCase__ : Union[str, Any] = data lowerCamelCase__ : ...
316
1
class _SCREAMING_SNAKE_CASE : '''simple docstring''' def __init__(self : Any , UpperCAmelCase_ : str = "" , UpperCAmelCase_ : bool = False) ->None: '''simple docstring''' lowerCamelCase__: dict[str, RadixNode] ={} # A node will be a leaf ...
10
'''simple docstring''' import argparse import os import re import packaging.version UpperCamelCase__: Union[str, Any] = "examples/" UpperCamelCase__: Optional[Any] = { "examples": (re.compile(r"^check_min_version\(\"[^\"]+\"\)\s*$", re.MULTILINE), "check_min_ve...
23
0
def __lowerCamelCase ( ): '''simple docstring''' for n in range(1 , 1000000 ): yield n * (n + 1) // 2 def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ = 1 snake_case_ ...
370
from math import sqrt def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ = 0 for i in range(1 , int(sqrt(UpperCamelCase__ ) + 1 ) ): if n % i == 0 and i != sqrt(UpperCamelCase__ ): ...
200
0
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : Dict = logging.get_logger(__name__) UpperCAmelCase__ : int = { """google/realm-cc-news-pretrained-embedder""": ( """https://huggingface.co/google/realm-cc-news-pretrai...
245
import os import pytest from attr import dataclass UpperCAmelCase__ : Optional[int] = """us-east-1""" # defaults region @dataclass class a__ : """simple docstring""" UpperCAmelCase__ : str UpperCAmelCase__ : Union[str, ...
245
1
"""simple docstring""" import json import os import pickle import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers import is_faiss_available from transformers.models.bart.configuration_bart import BartConfig from t...
359
"""simple docstring""" import os from collections.abc import Iterator def _SCREAMING_SNAKE_CASE (_UpperCAmelCase : str = "." ): for dir_path, dir_names, filenames in os.walk(_UpperCAmelCase ): lowerCAmelCase = [d for d in dir_names if d != 'scripts' and d[0] not in '._'] for filename in ...
309
0
"""simple docstring""" import fire from torch.utils.data import DataLoader from tqdm import tqdm from transformers import AutoTokenizer from utils import SeqaSeqDataset, pickle_save def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_=1024 , UpperCamelCase_=1024 ,...
100
"""simple docstring""" import os import sys from contextlib import contextmanager # Windows only if os.name == "nt": import ctypes import msvcrt # noqa class snake_case ( ctypes.Structure ): '''simple docstring''' A_ : List[str] = [("...
266
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCAmelCase = { '''configuration_x_clip''': [ '''XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XCLIPConfig''', '''XCLIPTextCo...
354
'''simple docstring''' import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_NAMES from ...utils import logging from ..auto import CONFIG_MAPPING _lowerCAmelCase = logging.get_logge...
184
0
"""simple docstring""" from typing import Dict, Optional import numpy as np import datasets SCREAMING_SNAKE_CASE__ = "\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground truth. For binar...
46
"""simple docstring""" # This is the module that test_patching.py uses to test patch_submodule() import os # noqa: this is just for tests import os as renamed_os # noqa: this is just for tests from os import path # noqa: this is just for tests from os import path as renamed_path # noqa: this is just for...
46
1
'''simple docstring''' import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def lowerCAmelCase_ ( snake_case_ : Optional[int] ) -> O...
371
'''simple docstring''' import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForConditiona...
106
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging A = logging.get_logger(__name__) A = { 'google/switch-base-8': 'https://huggingface.co/google/switch-base-8/blob/main/config.json', } class __lo...
160
'''simple docstring''' import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home lowercase__ : Union[str, Any] = HUGGINGFACE_HUB_CACHE lowercase__ : int = 'config.json' lowercase__ : Optional[int] = 'diffusion_pytorch_model.bin' lowe...
324
0
'''simple docstring''' import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def UpperCAmelCase_ (__a : BertModel , __a : str , __a : str ): """simple docstring""" _a : Optional[Any] = ...
363
'''simple docstring''' import argparse from collections import defaultdict import yaml __lowerCAmelCase = """docs/source/en/_toctree.yml""" def UpperCAmelCase_ (__a : str ): """simple docstring""" _a : Any = defaultdict(__a ) for doc in model_doc:...
5
0
'''simple docstring''' from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance __snake_case = 637_8137.0 __snake_case = 635_6752.31_4245 __snake_case = 6378137 def a ( __a , __a , __a , __a ) -> floa...
97
"""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 .vae import Decode...
135
0
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from timm import create_model from timm.data import resolve_data_config from timm.data.transforms_factory import create...
89
'''simple docstring''' from __future__ import annotations def UpperCamelCase_ ( A__ : int | float | str , A__ : int | float | str ): '''simple docstring''' if nth_term == "": return [""] lowerCAmelCase_ : str = i...
89
1
"""simple docstring""" from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class lowerCAmelCase_ : """simple docstring"""...
25
from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version(""">=""", """4.25.0""")): raise OptionalDependencyNotAvail...
262
0
'''simple docstring''' from typing import Dict, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to...
368
'''simple docstring''' from argparse import ArgumentParser from .add_new_model import AddNewModelCommand from .add_new_model_like import AddNewModelLikeCommand from .convert import ConvertCommand from .download import DownloadCommand from .env import EnvironmentCommand from .lfs import LfsCommands from .pt_to_tf ...
136
0
'''simple docstring''' from graphs.minimum_spanning_tree_kruskal import kruskal def _A ( ): """simple docstring""" __lowercase =9 __lowercase =[ [0, 1, 4], [0, 7, 8], [1, 2, 8], [7, 8, 7], [7, 6, 1], ...
166
'''simple docstring''' import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transformers import AutoProcessor, BlipaProc...
166
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available SCREAMING_SNAKE_CASE__ : str = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable:...
339
import unittest from transformers import is_flax_available from transformers.testing_utils import require_flax, require_sentencepiece, require_tokenizers, require_torch, slow if is_flax_available(): import optax from flax.training.common_utils import onehot from transformers import AutoTokenizer, Fl...
339
1
'''simple docstring''' import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _lowerCamelCase : Tuple = logging.get_logger(__name__) _lowerCamelCase : An...
28
'''simple docstring''' import math def lowerCamelCase ( UpperCAmelCase__ : int ) -> int: if not isinstance(UpperCAmelCase__ , UpperCAmelCase__ ): lowercase_ : List[Any] = F'''Input value of [number={number}] must be an integer''' ...
239
0
def A ( _UpperCAmelCase : list[int] , _UpperCAmelCase : list[int] ) -> tuple[float, float]: '''simple docstring''' # Check if the input is valid if not len(_UpperCAmelCase ) == len(_UpperCAmelCase ) == 3: raise ValueError('Please enter a...
360
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 UpperCAmelCase__ = "src/transformers" UpperCAmelCase__ = "docs/source/en/ta...
290
0
'''simple docstring''' from ....utils import logging a__ : Optional[Any] = logging.get_logger(__name__) class lowercase_ ( a__ ): def __init__( self , a , a=None , a=20_48 ): UpperCamelCase__ = config.__dict__ UpperC...
80
'''simple docstring''' from math import factorial, pi def _UpperCamelCase ( __A , __A = 30 ) -> float: '''simple docstring''' if not isinstance(__A , (int, float) ): raise ValueError("maclaurin_sin() requires either an int or float for t...
80
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 rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ...
280
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase__ = { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "tokenization_xlm"...
280
1
"""simple docstring""" from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def snake_case ( A__ ): return getitem, k def snake_case ( A__ ,A__ ): return setitem, k, v def snake_case ( A__ ): ...
268
"""simple docstring""" import inspect import tempfile import unittest from huggingface_hub import hf_hub_download from transformers import is_torch_available from transformers.testing_utils import is_flaky, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...t...
301
0
import os from math import logaa def lowerCamelCase__ ( A__ : str = "base_exp.txt" ): '''simple docstring''' __lowerCamelCase = 0 __lowerCamelCase = 0 for i, line in enumerate(open(os.path.join(os.path.dirname(A__ ) , A__ ) )...
29
import requests from bsa import BeautifulSoup def lowerCamelCase__ ( A__ : str = "https://www.worldometers.info/coronavirus" ): '''simple docstring''' __lowerCamelCase = BeautifulSoup(requests.get(A__ ).text , """html.parser""" ) __lowerCamelCase ...
29
1
"""simple docstring""" import unittest from diffusers.models.unet_ad_blocks import * # noqa F403 from diffusers.utils import torch_device from .test_unet_blocks_common import UNetBlockTesterMixin class snake_case ( __snake_case, unittest.TestCase ): SCREAMING_SNAKE_CASE_ ...
217
"""simple docstring""" from __future__ import annotations def a__ ( __SCREAMING_SNAKE_CASE ) -> bool: __lowerCAmelCase: Tuple = str(__SCREAMING_SNAKE_CASE ) return len(__SCREAMING_SNAKE_CASE ) == 9 and set(__SCREAMING_SNAKE_CASE ) == set("123456789" ) ...
217
1
"""simple docstring""" import html from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bsa_available, logging, requires_backends if is_bsa_available(): import bsa from bsa import BeautifulSoup __A = logging.get_logger(__name__) class _snake_case ...
64
"""simple docstring""" def lowercase_ ( _lowerCamelCase: int ) -> int: '''simple docstring''' if not isinstance(_lowerCamelCase , _lowerCamelCase ): raise TypeError("Input value must be an 'int' type" ) __lowerCamelCase : Dict = 0 ...
64
1
"""simple docstring""" import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration _a = 50_0000 _a , _a = os.path.split(__file__) _a = os.path.join(RESULTS_BASEPATH...
194
"""simple docstring""" # Logistic Regression from scratch # In[62]: # In[63]: # importing all the required libraries import numpy as np from matplotlib import pyplot as plt from sklearn import datasets def lowerCamelCase__ ( __snake_case ) -> Tuple: """simple ...
194
1
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __A ( A_ ): '''simple docstring''' lowerCAmelCase : List[Any] = ["image_processor", "tokeni...
302
"""simple docstring""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(...
302
1
import unittest from transformers import load_tool from .test_tools_common import ToolTesterMixin class UpperCAmelCase_ ( unittest.TestCase , _lowercase ): '''simple docstring''' def _A ( self ): '''simple docstring''' __SCREAMING_SN...
257
"""simple docstring""" import absl # noqa: F401 # Here to have a nice missing dependency error message early on import nltk # 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 six # n...
153
0
'''simple docstring''' def _a ( _lowercase : str , _lowercase : str ): '''simple docstring''' __UpperCAmelCase : int = len(_lowercase ) __UpperCAmelCase : int = len(_lowercase ) __UpperCAmelCas...
359
'''simple docstring''' from __future__ import annotations __UpperCAmelCase :Tuple = "Muhammad Umer Farooq" __UpperCAmelCase :Tuple = "MIT" __UpperCAmelCase :Union[str, Any] = "1.0.0" __UpperCAmelCase :Optional[int] = "Muhammad Umer F...
240
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) lowercase : List[Any] = { """configuration_vision_encoder_decoder""": ["""VisionEncoderDecoderConfig""", """Visio...
20
def A ( _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bulk_modulus / density) ** ...
36
0
'''simple docstring''' from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=_SCREAMING_SNAKE_CASE ) class a ( _SCREAMING_SNAKE_CASE ): # `task` is not a Cl...
104
'''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 AutoImageProcessor, ViTImageProcessor from transform...
104
1
"""simple docstring""" from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class _SCREAMING_SNAKE_CASE : def __lowerCAmelCase ( self , __A ) -> int: raise No...
84
'''simple docstring''' from collections import OrderedDict from typing import List, Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCa...
323
0
'''simple docstring''' # NOTE: This file is deprecated and will be removed in a future version. # It only exists so that temporarely `from diffusers.pipelines import DiffusionPipeline` works from ...utils import deprecate from ..controlnet.pipeline_flax_controlnet import FlaxStableDiffusionControlNetPipeline # n...
345
'''simple docstring''' import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class UpperCamelCase : """simple docstring""" def __init__( self : List[str] , Uppe...
345
1
def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' __UpperCamelCase :Tuple = [0 for i in range(len(SCREAMING_SNAKE_CASE ) )] # initialize interval's left pointer and right pointer __UpperCamelCase , __UpperCamelCase :str = 0, 0 for i in range(1 ...
43
def lowerCamelCase__ ( a ) -> bool: _A: Dict = [int(a ) for i in ip_va_address.split('''.''' ) if i.isdigit()] return len(a ) == 4 and all(0 <= int(a ) <= 2_54 for octet in octets ) if __name__ == "__main__": UpperCAmelCase__ : str = ...
121
0
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging a__ = logging.get_logger(__name__) a__ = {'''vocab_file''': '''spie...
15
from __future__ import annotations def __UpperCAmelCase ( __a : list ) -> float: """simple docstring""" if not nums: raise ValueError('''List is empty''' ) return sum(__a ) / len(__a ) if __name__ == "__main__": import do...
15
1
import json import logging import os import socket import git import numpy as np import torch logging.basicConfig( format="%(asctime)s - %(levelname)s - %(name)s - PID: %(process)d - %(message)s", datefmt="%m/%d/%Y %H:%M:%S", level=logging.INFO, ) _lowerCAmelCase : int = ...
218
from ... import PretrainedConfig _lowerCAmelCase : Any = { "sijunhe/nezha-cn-base": "https://huggingface.co/sijunhe/nezha-cn-base/resolve/main/config.json", } class __magic_name__ ( lowerCAmelCase_ ): SCREAMING_SNAKE_CASE = NEZHA_PRETRAINED_CONFIG_AR...
218
1
def UpperCamelCase__( UpperCamelCase__ : dict )->set: A__ = set() # edges = list of graph's edges A__ = get_edges(UpperCamelCase__ ) # While there are still elements in edges list, take an arbitrary edge # (from_node, to_node) and a...
39
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionTextToImagePipeline from diffusers.utils.testing_utils import nightly, require_torch_gpu, torch_device a__: Union[str, Any] = False class SCREAMING_SNAKE_CASE_...
39
1
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class __snake_case ( a ): def __init__( self : ...
51
from datetime import datetime import requests def A (__A : str ) -> bytes: """simple docstring""" UpperCAmelCase_ = '''https://downloadgram.net/wp-json/wppress/video-downloader/video?url=''' UpperCAmelCase_ = r...
51
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) f...
180
import argparse import pytorch_lightning as pl import torch from torch import nn from transformers import LongformerForQuestionAnswering, LongformerModel class a__ ( pl.LightningModule ): def __init__( self , A ) -> Optional[Any]: '''simple docstring''' ...
180
1
from dataclasses import dataclass, field from typing import Optional from transformers import AutoConfig, AutoImageProcessor, AutoTokenizer, FlaxVisionEncoderDecoderModel, HfArgumentParser @dataclass class _UpperCamelCase : """simple docstring""" __a : str = field( metadata={'...
210
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a : str = logging.get_logger(__name__) __a : int = { """microsoft/wavlm-base""": """https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json""", # See all W...
210
1
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging if TYPE_CHECKING: from ... import FeatureExtractionMixin...
370
"""simple docstring""" import enum import warnings from .. import MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING from ..utils import add_end_docstrings, is_tf_available from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf class _Up...
86
0
import argparse import json import os import tensorstore as ts import torch from flax import serialization from flax.traverse_util import flatten_dict, unflatten_dict from tensorflow.io import gfile from transformers.modeling_utils import dtype_byte_size from transformers.models.switch_transformers.convert_swit...
10
'''simple docstring''' def __lowerCAmelCase ( UpperCamelCase__ = 1_00_00_00 ) -> int: __lowerCamelCase = set(range(3 , UpperCamelCase__ , 2 ) ) primes.add(2 ) for p in range(3 , UpperCamelCase__ , 2 ): if p not in primes: continue pri...
67
0
'''simple docstring''' import argparse import struct import unittest class UpperCamelCase_ : """simple docstring""" def __init__( self : Any , _lowerCamelCase : bytes ): """simple docstring""" A_ : Dict = ...
361
'''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/...
4
0
from __future__ import annotations import requests lowerCAmelCase__ : Any = set( '''approved_at_utc approved_by author_flair_background_color author_flair_css_class author_flair_richtext author_flair_template_id author_fullname author_premium can_mod_post category clicked content_categories created_...
143
# 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 # # Unless required by a...
143
1
"""simple docstring""" import random import unittest import numpy as np import torch from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionUpscalePipeline, PNDMScheduler, ) from diffusers.utils imp...
203
"""simple docstring""" import math def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) ->Optional[int]: if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(_SCREAMING_SNAKE_CASE ) else: if x == 0: # 0 ...
203
1
import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import numpy as np import pytest from datasets.arrow_dataset import Dataset from datasets.search import ElasticSearchIndex, FaissIndex, MissingIndex from .utils import require_elasticsearch, require...
281
import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging snake_case : Dict = logging.get_logger(__name__) snake_case : Union[str, Any] = { "vocab_file": "vocab.txt", ...
281
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, convert_to_rgb, get_resize_output_image_size, normalize, resca...
363
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAndTextClassificatio...
248
0
"""simple docstring""" import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node __A = 4 __A = 3 class snake_case ( __sna...
217
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization...
217
1
"""simple docstring""" import math def lowercase__ ( _UpperCAmelCase ) -> int: '''simple docstring''' if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): lowercase : Optional[Any] = f'''Input value of [number={n...
357
"""simple docstring""" def lowercase__ ( _UpperCAmelCase ) -> list: '''simple docstring''' lowercase : Dict = len(_UpperCAmelCase ) for i in range(1 , _UpperCAmelCase ): lowercase : Union[str, Any] = ...
53
0
"""simple docstring""" _a : Tuple = 'Input must be a string of 8 numbers plus letter' _a : Optional[int] = 'TRWAGMYFPDXBNJZSQVHLCKE' def SCREAMING_SNAKE_CASE ( _lowerCamelCase : str ) -> bool: if not isinstance(_lowerCamelCase ,_lowerC...
44
"""simple docstring""" import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertE...
44
1
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_inputs if is...
352
import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion import Stabl...
265
0
import unittest from transformers import load_tool from transformers.utils import is_torch_available if is_torch_available(): import torch from transformers.testing_utils import require_torch from .test_tools_common import ToolTesterMixin @require_torch class __snake_case ( unittest.TestCase , A__ ...
20
'''simple docstring''' import os import shutil import tempfile import unittest import numpy as np from transformers import AutoTokenizer, BarkProcessor from transformers.testing_utils import require_torch, slow @require_torch class __UpperCAmelCase ( unittest.TestCase ): '''simple d...
258
0
def _lowerCAmelCase ( A__: int ): '''simple docstring''' return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def _lowerCAmelCase ( A__: int ): '''simple docstring''' UpperCAmelCase = 0 UpperCAmelCase ...
152
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def _lowerCAmelCase ( A__: str , A__: List[str] , A__: str ): '''simple docstring''...
152
1
from __future__ import annotations def _a ( UpperCAmelCase , UpperCAmelCase ) -> tuple[int, int]: """simple docstring""" if b == 0: return (1, 0) ((lowerCamelCase__) , (lowerCamelCase__)) : str = extended_euclid(UpperCAmelCase , a...
142
import os import textwrap import pyarrow as pa import pytest from datasets import ClassLabel, Features, Image from datasets.packaged_modules.csv.csv import Csv from ..utils import require_pil @pytest.fixture def _a ( UpperCAmelCase ) -> str: """simple docstring""" lower...
142
1
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, TensorFlowBenchmarkArguments ...
143
from __future__ import annotations import unittest from transformers import RoFormerConfig, 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_mas...
143
1
"""simple docstring""" from math import sqrt import numpy as np from sympy import symbols # Coefficient # Speed of light (m/s) __A : str = 299_792_458 # Symbols __A : Union[str, Any] = symbols('''ct x y z''') def lowercase ( __snake_case ...
33
from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxSeqaSeqConfigWithPast from ...utils import logging a : Tuple = logging.get_logger(__name__) a : Dict = { "t5-small": "https://huggingface.co/t5-small/resolve...
114
0
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a =logging.get_logger(__name__) a ={ """BAAI/AltCLIP""": """https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json""", # See all AltCLIP models at https://h...
358
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required ...
113
0
'''simple docstring''' import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.sp...
166
'''simple docstring''' from datetime import datetime import requests def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase ='https://downloadgram.net/wp-json/wppress/video-downloader/video?url=' __lowercase =requests.get(base_url + url ).json()...
166
1
"""simple docstring""" import os import unittest from transformers.models.cpmant.tokenization_cpmant import VOCAB_FILES_NAMES, CpmAntTokenizer from transformers.testing_utils import require_jieba, tooslow from ...test_tokenization_common import TokenizerTesterMixin @require...
289
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def UpperCamelCase_ ( lowerCAmelCase__ : int ) -> bool: """simple docstring""" lowerCAmelCase_ : int = int(num...
289
1
"""simple docstring""" from math import factorial _lowercase = {str(d): factorial(d) for d in range(10)} def _snake_case ( snake_case__ : int ): return sum(DIGIT_FACTORIAL[d] for d in str(snake_case__ ) ) def _snake_case ( ): A = 7 * factorial(9...
74
"""simple docstring""" import unittest import numpy as np from transformers import RobertaPreLayerNormConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is_flax...
242
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) _UpperCAmelCase : Tuple = {'configuration_reformer': ['REFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP'...
353
from __future__ import annotations import time import numpy as np _UpperCAmelCase = [8, 5, 9, 7] _UpperCAmelCase = [ [2, 0, 1, 1], [0, 1, 2, 1], [4, 0, 0, 3], [0, 2, 1, 0], [1, 0, 3, 0], ] _UpperCAmelCase = [ [3, 2, 1, 4], [0, 2,...
232
0
"""simple docstring""" def A_ ( _lowercase = 100 ): '''simple docstring''' snake_case_ :Dict = set() snake_case_ :Tuple = 0 snake_case_ :Optional[int] = n + 1 # maximum limit for a in range(2, _lowercase ): for b in range(2, _...
66
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 from accelerate import...
38
0
from importlib import import_module from .logging import get_logger lowerCamelCase__ = get_logger(__name__) class A__ : def __init__( self : Dict , a : Optional[Any] , a : Any=None ): '''simple docstring''' ...
356
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, OpenAIG...
307
0