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
from sklearn.metrics import matthews_corrcoef import datasets __lowerCAmelCase : Union[str, Any] = '\nCompute the Matthews correlation coefficient (MCC)\n\nThe Matthews correlation coefficient is used in machine learning as a\nmeasure of the quality of binary and multiclass classifications. ...
88
"""simple docstring""" def A__ ( UpperCamelCase ): A = generate_pascal_triangle(UpperCamelCase ) for row_idx in range(UpperCamelCase ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=" " ...
292
0
"""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 A: Dict = logging.get_logger(__name__) A: Optional[in...
76
"""simple docstring""" def _snake_case ( UpperCamelCase : int , UpperCamelCase : int ): return number | (1 << position) def _snake_case ( UpperCamelCase : int , UpperCamelCase : int ): return number & ~(1 << position) def _snake_case ...
76
1
'''simple docstring''' from . import ( albert, align, altclip, audio_spectrogram_transformer, auto, autoformer, bark, bart, barthez, bartpho, beit, bert, bert_generation, bert_japanese, bertweet, big_bird, bigbird_pegasus, biogpt, bit, ...
2
'''simple docstring''' import os import re import warnings from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokenization_ta import Ta...
2
1
"""simple docstring""" import math def lowerCamelCase__ ( __snake_case, __snake_case ) -> Tuple: """simple docstring""" if 0 not in (x, y): # We use the relation x^y = y*log10(x), where 10 is the base. return y * math.logaa(__s...
100
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) _a = { """configuration_trocr""": ["""TROCR_PRETRAINED_CONF...
100
1
def lowercase( UpperCamelCase_ ) -> int: '''simple docstring''' if not isinstance(UpperCamelCase_ , UpperCamelCase_ ): UpperCamelCase = f"""Input value of [number={number}] must be an integer""" raise TypeError(UpperCamelCase_ ) if number < 1: UpperCamelCase ...
343
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface i...
343
1
import os # Precomputes a list of the 100 first triangular numbers __A : Any = [int(0.5 * n * (n + 1)) for n in range(1, 101)] def SCREAMING_SNAKE_CASE__ ( ) -> Optional[int]: '''simple docstring''' lowerCAmelCase : str = os.path.dirname(os.path.re...
323
import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTImageProcessor, ViTMSNConfig, ViTMSNModel from transformers.image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD torch.set_grad_enabled(False) def ...
323
1
import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert imp...
307
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 __SCREAMING_SNAKE_CASE( a_ ...
307
1
'''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, ...
370
'''simple docstring''' from __future__ import annotations import math def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase, _UpperCAmelCase ): if depth < 0: raise ValueError("Depth cannot be less than 0" ) if not scores: raise ValueErro...
37
0
def _lowercase ( UpperCamelCase_ ) -> int: '''simple docstring''' SCREAMING_SNAKE_CASE__ = hex_num.strip() if not hex_num: raise ValueError('No value was passed to the function' ) SCREAMING_SNAKE_CASE__ = hex_num[0] == '-' if is_negativ...
176
import os from typing import List, Optional, Union from ...tokenization_utils import PreTrainedTokenizer from ...tokenization_utils_base import AddedToken from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = {"""vocab_file""": """vocab.txt"""} __snake_case ...
176
1
from typing import Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if is_torch_available(): from ..models.auto.modelin...
371
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import logging if TYPE_CHECKING:...
235
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 transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.s...
315
"""simple docstring""" from manim import * class lowercase_ ( __lowerCAmelCase ): '''simple docstring''' def lowerCAmelCase_ ( self : Dict ): _A = Rectangle(height=0.5 , width=0.5 ) _A = Rectangle(height=0.46 , ...
315
1
'''simple docstring''' import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import...
364
'''simple docstring''' import cmath import math def _snake_case ( _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : float , _SCREAMING_SNAKE_CASE : float ) -> complex: ...
187
0
'''simple docstring''' from __future__ import annotations def lowerCamelCase__ ( _A , _A , _A , _A ): a : Union[str, Any] = [] a , a : Optional[Any] = input_list[low:mid], input_list[mid : high + 1] while left and right: result.appe...
297
'''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...
297
1
from sklearn.metrics import recall_score import datasets __UpperCAmelCase : Optional[Any] = "\nRecall is the fraction of the positive examples that were correctly labeled by the model as positive. It can be computed with the equation:\nRecall = TP / (TP + FN)\nWhere TP is the true positives and FN ...
363
import collections import os import re from pathlib import Path __UpperCAmelCase : List[str] = "src/transformers" # Matches is_xxx_available() __UpperCAmelCase : int = re.compile(r"is\_([a-z_]*)_available()") # Catches a one-line _import_struct = {xxx} __UpperCAmelCase : Optional[int...
315
0
from __future__ import annotations from decimal import Decimal from numpy import array def lowerCamelCase__ ( _a): SCREAMING_SNAKE_CASE : Union[str, Any] = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works for 2x2 matrices if ...
76
a_ = 8.314_4598 def lowerCamelCase__ ( _a , _a): if temperature < 0: raise Exception("Temperature cannot be less than 0 K") if molar_mass <= 0: raise Exception("Molar mass cannot be less than or equal to 0 kg/mol") else: return (3 * UNIVERSAL_GAS_CONSTANT * temperature / molar_ma...
76
1
import os # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_doctest_list.py A : Optional[int] = '''.''' if __name__ == "__main__": A : str = os.path.join(REPO_PATH, '''utils/documentation_tests.txt''...
276
import itertools import os import random import tempfile import unittest import numpy as np from datasets import load_dataset from transformers import is_speech_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transforme...
276
1
"""simple docstring""" import os import sys import unittest __magic_name__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_o...
100
"""simple docstring""" from collections import defaultdict def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = first_str.lower().strip() __SCREAMING_SNAKE_CASE = second_str.lower().strip() # Remove whitespace __SCREAMING_SNAKE_CA...
100
1
def __snake_case ( _UpperCAmelCase ): __a = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def __snake_case ( _UpperCAmelCase ): __a = [chr(i + 65 ) for...
131
import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging __snake_case :Dict = logging.get_logger(__name__...
131
1
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch...
266
"""simple docstring""" def lowerCAmelCase ( __UpperCamelCase ): """simple docstring""" __A = current_set.copy() for row_index, row in enumerate(__UpperCamelCase ): __A = row[0] for column_index, column in enumerate(__UpperCamelCase ): if magnitude == 0:...
266
1
"""simple docstring""" from __future__ import annotations def __a ( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE = None , _SCREAMING_SNAKE_CASE = None , _SCREAMING_SNAKE_CASE = False , ) ->Dict: a__: Optional[int] = cipher_alphabet or [chr(_lowercase...
359
"""simple docstring""" import argparse import math import traceback import dateutil.parser as date_parser import requests def __a ( _SCREAMING_SNAKE_CASE ) ->Tuple: a__: Tuple = {} a__: Tuple = job['started_at'] a__: int = ...
203
0
"""simple docstring""" import sys def a__ ( SCREAMING_SNAKE_CASE : Optional[Any] ): '''simple docstring''' lowerCAmelCase : Union[str, Any] = len(SCREAMING_SNAKE_CASE ) lowerCAmelCase : Any = [[0 for x in range(SCREAMING_SNAKE_CASE...
108
'''simple docstring''' import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): import torch ...
37
0
"""simple docstring""" import re def _snake_case ( lowerCamelCase__ : str ) -> bool: lowerCamelCase_ : Tuple =re.compile(r"^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$" ) if match := re.search(lowerCamelCase__ , lowerCamelCase__ ): return mat...
209
"""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...
209
1
'''simple docstring''' import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( Auto...
79
'''simple docstring''' from __future__ import annotations def A_ ( snake_case , snake_case , snake_case , ): if (stress, tangential_force, area).count(0 ) != 1: raise ValueError("You cannot supply more or less than 2 values" ) elif stress < 0...
139
0
import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from transformers.utils import W...
367
import qiskit def lowerCamelCase_ ( lowerCAmelCase: int = 2 )-> qiskit.result.counts.Counts: _snake_case : Dict = qubits # Using Aer's simulator _snake_case : List[str] = qiskit.Aer.get_backend('aer_simulator' ) # Creating a Quantum Circuit acting...
260
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) __lowerCamelCase : Union[str, Any] = { '''configuration_deberta''': ['''DEBERTA_PRETRAINED_CONFIG_ARCHIV...
219
def __SCREAMING_SNAKE_CASE ( __UpperCamelCase : int , __UpperCamelCase : int ) -> str: """simple docstring""" if a < 0 or b < 0: raise ValueError("""the value of both inputs must be positive""" ) SCREAMING_SNAKE_CASE__ = str(bin...
219
1
# 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 # # Unless required by ...
352
def lowerCamelCase_ ( _a : int = 50 ): '''simple docstring''' UpperCAmelCase_ : Dict = [1] * (length + 1) for row_length in range(length + 1 ): for tile_length in range(2 , 5 ): for tile_start in range(row_length - tile_length + 1 ...
59
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available snake_case_ = { """configuration_instructblip""": [ """INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""", """InstructBlipConf...
78
def _a ( SCREAMING_SNAKE_CASE : int ) -> bool: """simple docstring""" if not isinstance(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): __lowerCAmelCase: List[Any] = f'''Input value of [number={number}] must be an integer''' raise TypeError(SCREAMING_SNAKE_CA...
322
0
import json import os import unittest from transformers import OpenAIGPTTokenizer, OpenAIGPTTokenizerFast from transformers.models.openai.tokenization_openai import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_spacy, require_tokenizers from ...test_tokenization_common import Token...
367
import inspect import unittest from transformers import ConvNextVaConfig from transformers.models.auto import get_values from transformers.models.auto.modeling_auto import MODEL_FOR_BACKBONE_MAPPING_NAMES, MODEL_MAPPING_NAMES from transformers.testing_utils import require_torch, require_vision, slow, torch...
146
0
'''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 ...
276
'''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.multicontrolnet import MultiControlNetModel # noqa: F40...
276
1
"""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...
168
"""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...
168
1
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase = logging.get_logger(__name__) lowerCamelCase = { '''sayakpaul/vit-msn-base''': '''https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json''', # See all ViT MSN models at h...
131
def lowerCamelCase_ ( _a ): """simple docstring""" lowerCAmelCase__ : Optional[Any] = '''''' for ch in key: if ch == " " or ch not in key_no_dups and ch.isalpha(): key_no_dups += ch return key_no_dups def lowerCamelC...
131
1
def __lowercase ( __lowerCAmelCase : str ): return " ".join( ''.join(word[::-1] ) if len(__lowerCAmelCase ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_lon...
366
import argparse from pathlib import Path import requests import torch from PIL import Image from transformers import ( RobertaTokenizer, TrOCRConfig, TrOCRForCausalLM, TrOCRProcessor, VisionEncoderDecoderModel, ViTConfig, ViTImageProcessor, ViTModel, ) from transformers.utils import...
109
0
"""simple docstring""" from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...onnx.utils import compute_effective_axis_dimension from ...utils import loggi...
109
"""simple docstring""" import datasets from .evaluate import evaluate A: Optional[Any] = "\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={arXiv p...
109
1
def UpperCAmelCase_ (_lowerCAmelCase : list[list[int]] , _lowerCAmelCase : int , _lowerCAmelCase : int , _lowerCAmelCase : set ): __UpperCamelCase , __UpperCamelCase : Tuple = len(_a ), len(grid[0] ) if ( min(_...
361
from math import sqrt def UpperCAmelCase_ (_lowerCAmelCase : int = 1_00_00_00 ): __UpperCamelCase : int = 0 __UpperCamelCase : int = 0 __UpperCamelCase : int while num_cuboids <= limit: max_cuboid_size += 1 for sum_shortest_si...
171
0
import timeit import numpy as np import datasets from datasets.arrow_writer import ArrowWriter from datasets.features.features import _ArrayXD def _a ( SCREAMING_SNAKE_CASE_ : Any ): def wrapper(*SCREAMING_SNAKE_CASE_ : Optional[Any] , **SCREAMING_SNAKE_CASE...
92
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 ( SCREAMING_SNAKE_CASE_ ...
92
1
from itertools import count def SCREAMING_SNAKE_CASE ( __lowerCAmelCase = 50 ) -> int: UpperCamelCase__ : Dict = [1] * min_block_length for n in count(__lowerCAmelCase ): fill_count_functions.append(1 ) for b...
196
def SCREAMING_SNAKE_CASE ( __lowerCAmelCase ) -> int: assert isinstance(__lowerCAmelCase , __lowerCAmelCase ), f'The input value of [n={number}] is not an integer' if number == 1: return 2 elif number < 1: UpperCamelCase__ : Li...
196
1
import collections import os from typing import List, Optional, Tuple from transformers.utils import is_jieba_available, requires_backends if is_jieba_available(): import jieba from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a__ = logging.get_logger(__na...
235
import math from typing import Dict, Iterable, List, Optional, Tuple, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import normalize, rescale, resize, to_channel_dimension_format from ...image_utils import ( IMAG...
235
1
def SCREAMING_SNAKE_CASE ( _UpperCAmelCase ) -> list[int]: lowerCamelCase__ : Union[str, Any] = [0 for i in range(len(_UpperCAmelCase ) )] # initialize interval's left pointer and right pointer lowerCamelCase__ , lowerCamelCase__ : Optional[int] = 0, 0 ...
45
import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _UpperCAmelCase : Any = logging.get_logger(__name__) _UpperCAmelCase : Optional[int] = { """vocab_file""": """vo...
45
1
'''simple docstring''' import argparse import dataclasses import json import logging import os import shutil from typing import List, Optional import datasets from accelerate import Accelerator from datasets import load_dataset from finetuning import finetune from tqdm.auto import tqdm import transformers from...
237
import pytest from datasets import inspect_metric, list_metrics, load_metric @pytest.fixture def UpperCamelCase ( __lowerCamelCase : Optional[int] ): monkeypatch.setattr("datasets.utils.deprecation_utils._emitted_deprecation_warnings" , set() ) @pytest.fixture def ...
59
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) lowerCAmelCase_ = {"configuration_fnet": ["FNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "F...
357
def lowerCamelCase_ ( _UpperCamelCase ) -> int: """simple docstring""" if not isinstance(_UpperCamelCase , _UpperCamelCase ): raise ValueError('''multiplicative_persistence() only accepts integral values''' ) if num < 0: raise ValueError('''multipl...
279
0
import gc import tempfile import unittest import numpy as np import torch from diffusers import VersatileDiffusionPipeline from diffusers.utils.testing_utils import load_image, nightly, require_torch_gpu, torch_device lowercase_ : Union[str, Any] = False class __lowerCAmelCase ( unittes...
133
def __SCREAMING_SNAKE_CASE ( snake_case_ = 1000 ): '''simple docstring''' _UpperCAmelCase = 2**power _UpperCAmelCase = 0 while n: _UpperCAmelCase , _UpperCAmelCase = r + n % 10, n // 10 return r if _...
133
1
"""simple docstring""" import uuid from typing import Any, Dict, List, Optional, Union from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf if is_torch_available(): impo...
353
import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxruntime as ort _UpperC...
192
0
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, ids_tensor, ran...
13
from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _snake_case ( _snake_case ): SCREAMING_SNAKE_CASE__ = 'ClapFeatureExtractor' SCREAMING_SNAKE_CASE__ = ('RobertaTokenizer', 'RobertaTokenizerFast') def __init__( ...
94
0
from typing import Optional, Union import torch from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...modeling_outputs import BaseModelOutputWithPoolingAndNoAttention, ImageClassifierOutputWithNoAttention from ...modeling_utils import PreTrain...
105
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGeneration as ProphetN...
105
1
'''simple docstring''' from __future__ import annotations from typing import Any def lowerCamelCase (_SCREAMING_SNAKE_CASE : list ): if not postfix_notation: return 0 __a : Optional[Any] = {'+', '-', '*', '/'} __a : list[Any] = []...
27
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ ( lowerCAmelCase__ :list[int] ) -> int: '''simple docstring''' if not nums: return 0 lowercase = nums[0] lowercase = 0 for nu...
197
0
import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter __A = True ...
364
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets, # U and V such that every edge (u, v) either connects a vertex from U to V or a vertex # from V to U. In other words, for every edge (u, v), either u belongs to U and v to V, # or u belongs to V and v to U. We can also ...
348
0
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar UpperCAmelCase__ : Union[str, Any] = TypeVar('T') class UpperCAmelCase ( Generic[T] ): '''simple docstring''' __UpperCamelCase : deque[T] # Cache store of ke...
121
from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase__ : Optional[Any] = logging.get_logger(__name__) UpperCAmelCase__ : Any = { 'huggingface/informer-tourism-monthly': ( 'https://huggi...
121
1
'''simple docstring''' import pickle import numpy as np from matplotlib import pyplot as plt class A__ : """simple docstring""" def __init__( self : Optional[int] , lowerCAmelCase__ : int , lowerCAmelCase__ : List[Any] , lowerCAmelCase__ ...
352
'''simple docstring''' from datetime import datetime import matplotlib.pyplot as plt import torch def __UpperCAmelCase ( a_: str ): for param in module.parameters(): _UpperCAmelCase : Any = False def __UpperCAmelCase ( ): _UpperCAmelCa...
17
0
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTConfig, DeiTForImageClassificationWithTeacher, DeiTImageProcessor from transformers.utils import logging lo...
196
__lowerCAmelCase = range(2, 20 + 1) __lowerCAmelCase = [10**k for k in range(ks[-1] + 1)] __lowerCAmelCase = {} def snake_case_ ( snake_case , snake_case , snake_case , snake_case ) -> Optional[int]: lowercase__: ...
196
1
'''simple docstring''' import heapq as hq import math from collections.abc import Iterator class UpperCAmelCase__ : """simple docstring""" def __init__( self : List[Any] ,_a : Optional[int] ): '''simple docstring''' _a : str = str(id_...
5
'''simple docstring''' import argparse import gc import json import os import re import torch from huggingface_hub import hf_hub_download from transformers import AutoModelForCausalLM, AutoTokenizer, PreTrainedTokenizerFast, RwkvConfig from transformers.modeling_utils import WEIGHTS_INDEX_NAME, shard_checkpoi...
5
1
"""simple docstring""" from copy import deepcopy class __lowerCAmelCase : '''simple docstring''' def __init__( self , _a = None , _a = None ): if arr is None and size is not None: __a = size __a = [0] * size eli...
45
"""simple docstring""" def lowercase ( lowerCAmelCase__ : int , lowerCAmelCase__ : list ) -> List[Any]: _enforce_args(lowerCAmelCase__ , lowerCAmelCase__ ) if n == 0: return 0 __a = float('''-inf''' ) for i in range(1 , n ...
45
1
'''simple docstring''' from __future__ import annotations import inspect import unittest import numpy as np from transformers import DeiTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_av...
370
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import Padd...
334
0
"""simple docstring""" import math import random def _lowerCAmelCase ( lowercase_ , lowercase_ = False ): if deriv: return value * (1 - value) return 1 / (1 + math.exp(-value )) # Initial Value snake_case_ = 0.02 def _lowerCAmelCase ...
78
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer lowerCAmelCase__ = logging.get_logger(__name__) lowerCAmelCase__ ...
130
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow if is_torch_available(): import torch from transformers import XLMRobertaModel @require_sentencepiece @require_tokenizers @requ...
361
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class a_ ( _snake_case ): UpperCamelCase__ : Optiona...
344
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule __A = {"""tokenization_wav2vec2_phoneme""": ["""Wav2Vec2PhonemeCTCTokenizer"""]} if TYPE_CHECKING: from .tokenization_wavaveca_phoneme import WavaVecaPhonemeCTCTokenizer else: import sys __A ...
293
"""simple docstring""" from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class _lowerCAmelCase ( yaml.SafeLoader ): """simple docstring""" def snake_case ( self , __UpperCAmelCase ): ...
293
1
from math import asin, atan, cos, radians, sin, sqrt, tan _SCREAMING_SNAKE_CASE : Optional[int] = 6378137.0 _SCREAMING_SNAKE_CASE : Dict = 6356752.314245 _SCREAMING_SNAKE_CASE : Optional[int] = 6_37_81_37 def UpperCAmelCase__ (UpperCamelCase_ ...
213
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 _SCREAMING_SNAKE_CASE : List[str] = logging.get_logger(__name__) _SC...
213
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging __a: Any = logging.get_logger(__name__) __a: Optional[int] = { """alibaba-damo/mgp-str-base""": """https://huggingface.co/alibaba-damo/mgp-str-base/resolve/main/config.json""", } clas...
198
'''simple docstring''' import requests __a: str = """https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=""" def __UpperCamelCase ( UpperCAmelCase ): # fetching a list of articles in json format lowercase__ : Optional[Any] = requests.get(_NEWS_API + bbc_news_api_ke...
198
1
import argparse import logging import os import time import timeit import datasets import numpy as np import pycuda.autoinit # noqa: F401 import pycuda.driver as cuda import tensorrt as trt import torch from absl import logging as absl_logging from accelerate import Accelerator from datasets impor...
351
from math import ceil def __UpperCAmelCase ( __a : int = 1_001 ) -> int: """simple docstring""" _a : Dict = 1 for i in range(1 ,int(ceil(n / 2.0 ) ) ): _a : int = 2 * i + 1 _a : ...
15
0
def a__ ( _UpperCamelCase : float ,_UpperCamelCase : float ,_UpperCamelCase : int ): if principal <= 0: raise Exception('''Principal borrowed must be > 0''' ) if rate_per_annum < 0: raise Exception('''Rate of interest must be >= 0''' ) ...
330
import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration a_ = [ # tf -> hf ("""/""", """."""), ("""layer_""", """layers."""), ("""kernel""", """weight"""), ...
330
1
def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' return "".join([hex(UpperCamelCase__ )[2:].zfill(2 ).upper() for byte in list(UpperCamelCase__ )] ) def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' ...
356
import requests _UpperCAmelCase : Union[str, Any] = """https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=""" def __lowerCamelCase ( UpperCamelCase__ ): '''simple docstring''' snake_case_ = requests.get(_NEWS_API + bbc_news_api_key ...
200
0
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=__lowerCAmelCase ) class lowercase_ ( __lowerCAmelCase ): '''simple ...
315
"""simple docstring""" from math import sqrt def _A ( UpperCamelCase_ : int) -> int: '''simple docstring''' __lowercase = 0 for i in range(1, int(sqrt(UpperCamelCase_) + 1)): if n % i == 0 and i != sqrt(UpperCamelCase_): total += i + n // i eli...
17
0
'''simple docstring''' import warnings from ..trainer import Trainer from ..utils import logging __snake_case : int = logging.get_logger(__name__) class __UpperCAmelCase ( lowerCamelCase__ ): '''simple docstring''' def __init__( self , _S...
353
'''simple docstring''' import inspect import unittest from transformers import DPTConfig from transformers.file_utils import is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_vision, slow, torch_device from ...test...
18
0
import heapq as hq import math from collections.abc import Iterator class lowerCamelCase__ : def __init__(self , UpperCAmelCase ) -> Any: _lowercase =str(id_ ) _lowercase =None _lowercase =None _lowercase ...
5
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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProcessor, ) from transfor...
5
1
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 lowercase : Optional[int] = namedtuple( "_TestCommandArgs", [ ...
171
def UpperCAmelCase_ (_lowerCAmelCase : int = 1_00 ): __UpperCamelCase : Tuple = n * (n + 1) * (2 * n + 1) / 6 __UpperCamelCase : List[str] = (n * (n + 1) / 2) ** 2 return int(square_of_sum - sum_of_squares ) if __name__ == "__main__": print(F"""{s...
171
1
UpperCAmelCase__ = [0, 2, 4, 6, 8] UpperCAmelCase__ = [1, 3, 5, 7, 9] def A ( _UpperCAmelCase : int , _UpperCAmelCase : int , _UpperCAmelCase : list[int] , _UpperCAmelCase : int ) -> int: '''simple docstring''' if remaini...
339
import os import sys import unittest UpperCAmelCase__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_dummies # noqa: E402 from check_dummies import create_dummy_files, create_dummy_object, find_backend, re...
339
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import _LazyModule A_ : List[Any] ={"""tokenization_bertweet""": ["""BertweetTokenizer"""]} if TYPE_CHECKING: from .tokenization_bertweet import BertweetTokenizer else: import sys A_ : Any ...
80
"""simple docstring""" from math import factorial def SCREAMING_SNAKE_CASE_ ( snake_case : int = 20 )-> int: _lowerCamelCase = 2 * n # middle entry of odd rows starting at row 3 is the solution for n = 1, # 2, 3,... _lowerCamelCase = n // 2 return i...
80
1
from __future__ import annotations def UpperCamelCase( __UpperCamelCase : Union[str, Any] ,__UpperCamelCase : Any ): if len(__lowerCAmelCase ) == 0: return False lowerCAmelCase_ : List[str] = len(__lowerCAmelCase ) // 2 if a_list[midpoint] == item: return True i...
103
'''simple docstring''' def __lowerCAmelCase (): return [list(range(1_000 - i , -1_000 - i , -1 ) ) for i in range(1_000 )] lowerCamelCase__ = generate_large_matrix() lowerCamelCase__ = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [...
234
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ = {'''configuration_vit_msn''': ['''VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''ViTMSNConfig''']} try: if not is_torch_available(): raise Option...
352
import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import ConfigTester from ...test...
121
0
def UpperCamelCase__ ( A__ ) -> list[list]: snake_case__ : Union[str, Any] = current_set.copy() for row_index, row in enumerate(A__ ): snake_case__ : Any = row[0] for column_index, column in enumerate(A__ ): if magn...
143
from __future__ import annotations import inspect import unittest from transformers import ViTConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...test_configuration_common import ConfigTes...
143
1
import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def lowercase__ ( __snake_case : Optional[Any] ...
356
from __future__ import annotations def lowercase__ ( __snake_case : list[int] , __snake_case : int ): '''simple docstring''' if len(__snake_case ) == 0: return False UpperCAmelCase_ : Optional[int] = len(__snake...
145
0
import re def lowerCamelCase__ ( snake_case_ : str ) -> list: return [char.split() for char in re.split(R'''[^ a-z A-Z 0-9 \s]''' , str_ )] def lowerCamelCase__ ( snake_case_ : str ) -> str: __snake_case ...
24
# Copyright 2021 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 # # Unless required by app...
15
0
"""simple docstring""" from math import atan, cos, radians, sin, tan from .haversine_distance import haversine_distance UpperCAmelCase : List[str] = 637_8137.0 UpperCAmelCase : List[str] = 635_6752.31_4245 UpperCAmelCase : Any = 637_8137 def _SCREAMING_SNAK...
359
"""simple docstring""" import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.utils.iterators ...
313
0
# 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 # # U...
39
from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( is_accelerate_available, is_acc...
178
0
import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import ( is_pipel...
292
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class _lowerCAmelCase( UpperCAm...
292
1
"""simple docstring""" import logging import os from dataclasses import dataclass, field from functools import partial from pathlib import Path from tempfile import TemporaryDirectory from typing import List, Optional import faiss import torch from datasets import Features, Sequence, Value, load_dataset from transf...
69
from math import factorial, radians def _snake_case ( lowerCAmelCase : float , lowerCAmelCase : int = 1_8 , lowerCAmelCase : int = 1_0 ): """simple docstring""" SCREAMING_SNAKE_CASE_ : List[str] = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) ...
18
0
"""simple docstring""" from math import factorial, radians def _UpperCamelCase (a__ :float , a__ :int = 18 , a__ :int = 10 ): """simple docstring""" UpperCamelCase__ = angle_in_degrees - ((angle_in_degrees // 360.0) * 360.0) ...
356
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_available(): from ...
87
0
'''simple docstring''' import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from ...
346
'''simple docstring''' from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL import Image ...
346
1
import os import shutil import sys import tempfile import unittest from pathlib import Path import pytest import transformers from transformers import ( BERT_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, AutoTokenizer, BertConfig, BertTokenizer, BertTokenizerFast, ...
115
from jiwer import compute_measures import datasets SCREAMING_SNAKE_CASE_:str = """\ @inproceedings{inproceedings, author = {Morris, Andrew and Maier, Viktoria and Green, Phil}, year = {2004}, month = {01}, pages = {}, title = {From WER and RIL to MER and WIL: improved evaluation meas...
115
1
'''simple docstring''' import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowercase_ ( unittest.TestCase ): def __a ( self ): UpperCamelCase__ = [ "safety_checker/pytorch_model.bin", ...
80
'''simple docstring''' import multiprocessing from typing import TYPE_CHECKING, Optional, Union from .. import Dataset, Features, config from ..formatting import query_table from ..packaged_modules.sql.sql import Sql from ..utils import logging from .abc import AbstractDatasetInputStream if TYPE_CHECKING: ...
80
1
'''simple docstring''' import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available ...
366
'''simple docstring''' def _snake_case ( _SCREAMING_SNAKE_CASE : list ) -> list: """simple docstring""" if len(_SCREAMING_SNAKE_CASE ) < 2: return collection def circle_sort_util(_SCREAMING_SNAKE_CASE : list , _SCREAMING_SNAKE_CASE ...
187
0
"""simple docstring""" import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class _...
17
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar UpperCAmelCase__ : Union[str, Any] = TypeVar('T') class UpperCAmelCase ( Generic[T] ): '''simple docstring''' __UpperCamelCase : deque[T] # Cache store of ke...
121
0
def _UpperCamelCase ( UpperCamelCase_ : str ) -> str: """simple docstring""" return " ".join(input_str.split()[::-1] ) if __name__ == "__main__": import doctest doctest.testmod()
122
import qiskit def _UpperCamelCase ( UpperCamelCase_ : int , UpperCamelCase_ : int ) -> qiskit.result.counts.Counts: """simple docstring""" lowerCAmelCase__ = qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acti...
122
1
def A ( a_ ) -> List[str]: __UpperCamelCase : Any =0 __UpperCamelCase : Union[str, Any] =len(__snake_case ) for i in range(n - 1 ): for j in range(i + 1 ,__snake_case ): if arr[...
71
'''simple docstring''' 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 toke...
190
0
import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, s...
78
import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __snake_case = logging.get_logger(__name__) __snake_case = {'''vocab_file''': '''vocab.json'''} __snake_case = { '''vocab_file''': { ...
78
1
'''simple docstring''' import numpy as np from sklearn.datasets import fetch_california_housing from sklearn.metrics import mean_absolute_error, mean_squared_error from sklearn.model_selection import train_test_split from xgboost import XGBRegressor def __lowerCamelCase ( A__ ...
28
"""simple docstring""" # Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger fro...
96
0
'''simple docstring''' import argparse import pathlib import fairseq import torch from fairseq.models.roberta import RobertaModel as FairseqRobertaModel from fairseq.modules import TransformerSentenceEncoderLayer from packaging import version from transformers import XLMRobertaConfig, XLMRobertaXLForMaske...
369
'''simple docstring''' # Lint as: python3 import dataclasses import re from dataclasses import dataclass from functools import total_ordering from typing import Optional, Union __UpperCamelCase = re.compile(R"^(?P<major>\d+)" R"\.(?P<minor>\d+)" R"\.(?P<patch>\d+)$") ...
13
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : Optional[int]= logging.get_logger(__name__) _a : Optional[Any]= { "...
172
from __future__ import annotations import copy import inspect import json import math import os import tempfile import unittest from importlib import import_module import numpy as np from transformers import ViTMAEConfig from transformers.file_utils import cached_property, is_tf_available, is_vision_available from t...
343
0
import json import os import shutil import tempfile import unittest import numpy as np import pytest from transformers import BertTokenizer, BertTokenizerFast from transformers.models.bert.tokenization_bert import VOCAB_FILES_NAMES from transformers.testing_utils import require_vision from transformers.utils imp...
210
import importlib import json import os import sys import tempfile import unittest from pathlib import Path import transformers import transformers.models.auto from transformers.models.auto.configuration_auto import CONFIG_MAPPING, AutoConfig from transformers.models.bert.configuration_bert import BertConfig from ...
210
1
'''simple docstring''' from copy import deepcopy from typing import Optional, Union import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, is_tf_available, is_torch_available if is_torch_available(): import...
56
import math from typing import Any, Callable, List, Optional, Tuple, Union import numpy as np import torch from ...models import TaFilmDecoder from ...schedulers import DDPMScheduler from ...utils import is_onnx_available, logging, randn_tensor if is_onnx_available(): from ..onnx_utils imp...
201
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available UpperCAmelCase = { '''configuration_jukebox''': [ '''JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''JukeboxConfig''', '''JukeboxPriorConfig'''...
367
"""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 ( MobileViTConfig, MobileViTForImageClassification, MobileViTForSemanticSegmentation, MobileViTImageProce...
54
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) _SCREAMING_SNAKE_CASE : Optional[int] = { '''configuration_gpt_bigcode''': ['''GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTBigCodeConfig'''], } try: ...
314
import os import re from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging _SCREAMING_SNAKE_CASE : Any = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : str = { '''vocab_file''': '''vo...
314
1
import math from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { """facebook/data2vec-base-960h""": """https://huggingface.co/facebook/data2vec-audio-base-960h/resolve/main/config.json""", # See all...
267
import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils import GenerationTesterMixin from ...test_modeling_common ...
267
1
"""simple docstring""" # Copyright 2022 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
105
import itertools from dataclasses import dataclass from typing import Optional import pandas as pd import pyarrow as pa import datasets from datasets.table import table_cast @dataclass class snake_case__ (datasets.BuilderConfig ): """simple docstring""" _...
170
0
'''simple docstring''' from scipy.stats import pearsonr, spearmanr from sklearn.metrics import fa_score, matthews_corrcoef import datasets lowerCAmelCase__ : int = "\\n@inproceedings{wang2019glue,\n title={{GLUE}: A Multi-Task Benchmark and Analysis Platform for Natural Language Understanding},\...
354
'''simple docstring''' from __future__ import annotations import collections import pprint from pathlib import Path def __UpperCamelCase ( _UpperCAmelCase ): return "".join(sorted(_UpperCAmelCase ) ) def __UpperCamelCase ( _UpperCAmelCase ): return word_by_signature[signatu...
37
0
"""simple docstring""" import argparse from collections import OrderedDict from pathlib import Path import requests import torch from PIL import Image from transformers import GLPNConfig, GLPNForDepthEstimation, GLPNImageProcessor from transformers.utils import logging logging.set_verbosity_info() UpperCamel...
243
"""simple docstring""" import os from glob import glob import imageio import torch import torchvision import wandb from img_processing import custom_to_pil, loop_post_process, preprocess, preprocess_vqgan from loaders import load_vqgan from PIL import Image from torch import nn from transformers import CLIPMod...
243
1
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowercase__ ( unittest.TestCase ): def UpperCamelCase_ ( self : Any ): '''simple docstring''' _UpperCamelCase : Tuple = [ 'safe...
365
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) snake_case_ : Optional[Any] = { 'configurati...
236
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available snake_case_ = { """configuration_xlm""": ["""XLM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLMConfig""", """XLMOnnxConfig"""], ...
78
"""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 convert_to_rgb, normalize, rescale, resize, to_channel_dimension_format from ...image_utils ...
78
1
"""simple docstring""" def UpperCamelCase_ ( lowerCAmelCase__ : str = 400_0000 ) -> Union[str, Any]: """simple docstring""" lowerCAmelCase_ : int = [] lowerCAmelCase_ ,lowerCAmelCase_ : Any = 0, 1 while b <= n:...
359
"""simple docstring""" import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets lowercase__ : Tuple = datasets.logging.get_logger(__name__) lowercase__ : List[Any] = """\ @inproceedings{bleurt, titl...
289
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_avail...
86
from collections.abc import Callable class __lowercase : """simple docstring""" def __init__( self : Tuple , lowerCAmelCase__ : Callable | None = None): # Stores actual heap items. SCREAMING_SNAKE_CASE_: list = [] # Stores indexes of each i...
13
0
import unittest from typing import Tuple import torch from diffusers.utils import floats_tensor, randn_tensor, torch_all_close, torch_device from diffusers.utils.testing_utils import require_torch @require_torch class __magic_name__ : @property def __a ( self ) -> int: return ...
362
def A(): return [list(range(1000 - i , -1000 - i , -1 ) ) for i in range(1000 )] lowerCamelCase__ = generate_large_matrix() lowerCamelCase__ = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]], [[3, 2], [1, 0]], [[7, 7, 6]], [[7...
22
0