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
import gc import unittest import torch from parameterized import parameterized from diffusers import AutoencoderKL from diffusers.utils import floats_tensor, load_hf_numpy, require_torch_gpu, slow, torch_all_close, torch_device from diffusers.utils.import_utils import is_xformers_available from diffusers.utils.tes...
199
import sys from .dependency_versions_table import deps from .utils.versions import require_version, require_version_core # define which module versions we always want to check at run time # (usually the ones defined in `install_requires` in setup.py) # # order specific notes: # - tqdm must be checked before token...
199
1
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.set_verbosity_info() lower...
118
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowerCAmelCase__ : List[str] ={ '''configuration_timesformer''': ['''TIMESFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''TimesformerConfig'''], } try: if not is_torch_available():...
118
1
'''simple docstring''' def __lowerCamelCase ( lowerCAmelCase_ ) -> list: for i in range(len(lowerCAmelCase_ ) - 1 , 0 , -1 ): _a : List[Any] = False for j in range(lowerCAmelCase_ , 0 , -1 ): if unsorted[j] < unsorted[j - 1...
89
import fire from transformers import AutoConfig, AutoModelForSeqaSeqLM, AutoTokenizer def lowerCAmelCase_ ( _lowercase : str , _lowercase : str , **_lowercase : Optional[Any]) -> Optional[int]: """simple docstring""" a__ : List[An...
170
0
"""simple docstring""" import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def lowercase ( _SCREAMING_SNAKE_CASE : An...
326
"""simple docstring""" import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Traine...
326
1
"""simple docstring""" import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging a :Any = logging.get_logger(__name__) a :List[Any] = { "BridgeTower/bridgetower-base": "https://huggingface.co/BridgeTower/bridgetower-...
132
"""simple docstring""" def _lowercase ( ) -> int: return [ a * b * (1000 - a - b) for a in range(1 , 999 ) for b in range(__lowerCAmelCase , 999 ) if (a * a + b * b == (1000 - a - b) ** 2) ][0] if __name__ == "__main__": ...
132
1
'''simple docstring''' import unittest from transformers import EsmConfig, is_torch_available from transformers.testing_utils import TestCasePlus, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attentio...
199
'''simple docstring''' import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn import transformers from ...
199
1
'''simple docstring''' def __lowerCamelCase ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ) -> int: _a , _a : int = len(lowerCAmelCase_ ), len(grid[0] ) if ( min(lowerCAmelCase_ , lowerCAmelCase_...
89
'''simple docstring''' import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_r...
89
1
import json import os import tempfile import transformers import datasets from utils import generate_example_dataset, get_duration __a = 50_00_00 __a , __a = os.path.split(__file__) __a = os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json''')) @get...
173
import argparse import torch from torch import nn from transformers import MaMaaaConfig, MaMaaaForConditionalGeneration def __lowercase ( _UpperCamelCase ) ->Tuple: """simple docstring""" lowercase : List[str] = [ '''encoder.version''', ...
173
1
import os import numpy import onnx def __lowercase ( lowerCamelCase : Optional[Any] , lowerCamelCase : Union[str, Any] ): UpperCamelCase_ : List[Any] = a.name UpperCamelCase_ : Optional[int] = b.name UpperCamelCase_ : Any = '' UpperCamelCas...
175
"""simple docstring""" def __UpperCAmelCase ( ) -> int: '''simple docstring''' return [ a * b * (10_00 - a - b) for a in range(1 , 9_99 ) for b in range(UpperCAmelCase_ , 9_99 ) if (a * a + b * b == (10_00 - a - b) ** 2) ][0] ...
172
0
"""simple docstring""" import re def __SCREAMING_SNAKE_CASE ( A_ ): lowerCAmelCase__ : Dict = re.compile( r'''^(?:0|94|\+94|0{2}94)''' r'''7(0|1|2|4|5|6|7|8)''' r'''(-| |)''' r'''\d{7}$''' ) return bool(re.search(A_ , A_ ) ) if __name__ == "__m...
357
"""simple docstring""" from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('''>=''', '''4.25.0''')): ra...
74
0
from __future__ import annotations import unittest import numpy as np from transformers import BlipTextConfig from transformers.testing_utils import require_tf, slow from transformers.utils import is_tf_available from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelT...
192
import enum import os from hashlib import shaaaa from typing import Optional from .. import config from .logging import get_logger a_ : List[Any] = get_logger(__name__) class _snake_case ( enum.Enum ): _lowercase : Any = '''all_checks''' _lowercase ...
137
0
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, require_tf,...
42
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 __UpperCAmelCase = logging.get_logger(__name__) _...
42
1
"""simple docstring""" 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 t...
191
"""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/LI...
191
1
"""simple docstring""" import contextlib from multiprocessing import Pool, RLock from tqdm.auto import tqdm from ..utils import experimental, logging A: Dict = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ : __lowerCAmelCase : List[Any] = None @experime...
368
"""simple docstring""" import baseaa def _snake_case ( UpperCamelCase : str ): return baseaa.aaaencode(string.encode("""utf-8""" ) ) def _snake_case ( UpperCamelCase : bytes ): return baseaa.aaadecode(UpperCamelCase ).decode("""utf-8""" ) i...
76
0
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class lowerCamelCase (SCREAMING_SNAKE_CASE__ ): """simple docstr...
118
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline A : Tuple = datasets.utils.logging.get_logger(__nam...
118
1
from __future__ import annotations import os from typing import Any import requests lowerCamelCase__ = """https://api.github.com""" # https://docs.github.com/en/free-pro-team@latest/rest/reference/users#get-the-authenticated-user lowerCamelCase__ = BASE_URL + """/user""" # https://githu...
351
import json import os from datetime import date from pathlib import Path from tabulate import DataRow, TableFormat, tabulate lowerCamelCase__ = TableFormat( lineabove=None, linebelowheader=None, linebetweenrows=None, linebelow=None, headerrow=DataRow("""""", """|""", """|"""...
307
0
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def lowerCAmelCase__( lowercase : Dict ) -> str: # picklable for multip...
326
import pytest from datasets.parallel import ParallelBackendConfig, parallel_backend from datasets.utils.py_utils import map_nested from .utils import require_dill_gt_0_3_2, require_joblibspark, require_not_windows def lowerCAmelCase__( lowercase : Dict ) -> str: # picklable for multip...
326
1
def a( A : int = 1000 ) -> int: """simple docstring""" a , a = 1, 1 a = 2 while True: a = 0 a = fa + fa a , a = fa, f index += 1 for _ in str(__snake_case ): ...
356
import os def a( ) -> List[str]: """simple docstring""" with open(os.path.dirname(A ) + "/grid.txt" ) as f: a = [] # noqa: E741 for _ in range(20 ): l.append([int(A ) for x in f.readline().split()] ) a = 0 # ...
71
0
import qiskit def a_ ( SCREAMING_SNAKE_CASE__ : int , SCREAMING_SNAKE_CASE__ : int ): '''simple docstring''' _lowerCamelCase : Optional[Any] =qiskit.Aer.get_backend('aer_simulator' ) # Create a Quantum Circuit acting on the q register ...
199
import doctest import logging import os import unittest from pathlib import Path from typing import List, Union import transformers from transformers.testing_utils import require_tf, require_torch, slow lowerCamelCase = logging.getLogger() @unittest.skip('Temporarily disable the doc tests.' ...
199
1
"""simple docstring""" import operator as op def _snake_case ( UpperCamelCase : Dict ): UpperCAmelCase : Optional[Any] = [] UpperCAmelCase : int = lambda UpperCamelCase , UpperCamelCase : int(x / y ) # noqa: E731 integer division operation UpperC...
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""" import inspect import unittest from transformers import MobileViTVaConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available fro...
173
"""simple docstring""" # Lint as: python3 import itertools import os import re _UpperCAmelCase = re.compile(r"""([A-Z]+)([A-Z][a-z])""") _UpperCAmelCase = re.compile(r"""([a-z\d])([A-Z])""") _UpperCAmelCase = re.compile(r"""(?<!_)_(?!_)""") _UpperCAmelCase = re.compile(r"""(_{2,})""") _...
173
1
"""simple docstring""" def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ) -> bool: '''simple docstring''' if p < 2: raise ValueError('p should not be less than 2!' ) elif p == 2: return True lowerCAmelCase : Optional[Any] = 4 lowerCAmel...
366
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, PreTrainedTokenizerBase, TensorType __A ...
323
0
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 = namedtuple( '''_TestCommandArgs''', [ '''dataset''', ...
43
"""simple docstring""" class lowerCAmelCase_ : '''simple docstring''' def __init__( self : int ,A_ : int ) -> Union[str, Any]: A = n A = [None] * self.n A = 0 # index of the first element A = ...
74
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 from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_feature...
369
"""simple docstring""" from typing import Optional, Tuple, Union import flax import flax.linen as nn import jax import jax.numpy as jnp from flax.core.frozen_dict import FrozenDict from ..configuration_utils import ConfigMixin, flax_register_to_config from ..utils import BaseOutput from .embeddings_flax import...
144
0
'''simple docstring''' import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class __UpperCAmelCase ( unittest.TestCase ): def lowerCamelCase ( self ): ...
42
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowercase : Tuple = { "configuration_xlm": ["XLM_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLMConfig", "XLMOnnxConfig"], "tokenization...
42
1
from scipy.stats import pearsonr import datasets lowerCAmelCase : Dict = """ Pearson correlation coefficient and p-value for testing non-correlation. The Pearson correlation coefficient measures the linear relationship between two datasets. The calculation of the p-value relies on the assump...
127
def A_ ( _UpperCAmelCase , _UpperCAmelCase ): if density <= 0: raise ValueError("Impossible fluid density" ) if bulk_modulus <= 0: raise ValueError("Impossible bulk modulus" ) return (bulk_modulus / density) ** 0.5 if __name__ == "__main__": ...
127
1
"""simple docstring""" import comet # From: unbabel-comet import torch import datasets snake_case__ : Tuple = datasets.logging.get_logger(__name__) snake_case__ : Any = '''\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and La...
60
from datetime import datetime as dt import os from github import Github a_ = [ 'good first issue', 'good second issue', 'good difficult issue', 'feature request', 'new model', 'wip', ] def lowerCamelCase__ ( ): SCREAMING_SNAKE_CASE : int = Github(os.en...
76
0
import os def lowerCAmelCase__ ( ) ->Any: '''simple docstring''' with open(os.path.dirname(a__ ) + "/grid.txt" ) as f: _UpperCamelCase = [] # noqa: E741 for _ in range(20 ): l.append([int(a__ ) for x in f.readline().split()] ) _UpperCamelCase ...
63
import math class _UpperCAmelCase : '''simple docstring''' def __UpperCAmelCase ( self : Dict , lowercase_ : list[list[float]] , lowercase_ : list[int]) -> int: """simple docstring""" _UpperCamelCase = 0.0 _UpperCamelCase ...
63
1
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_backbone_commo...
257
from heapq import heappop, heappush import numpy as np def __lowercase ( a__ , a__ , a__ , a__ , ) -> tuple[float | int, list[tuple[int, int]]]: __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE = grid.shape __SCREAMING_SNAKE_CASE ...
257
1
"""simple docstring""" 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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import (...
365
"""simple docstring""" from math import isqrt def __UpperCAmelCase ( snake_case_ : int ) -> list[int]: """simple docstring""" _lowerCAmelCase = [True] * max_number for i in range(2 , isqrt(max_number - 1 ) + 1 ): if is_prime[i]: ...
317
0
'''simple docstring''' from maths.prime_factors import prime_factors def a_ ( lowerCamelCase : int ): if not isinstance(lowerCamelCase , lowerCamelCase ): lowerCAmelCase = f'''Input value of [number={number}] must be an integer''' raise TypeError(lowerCam...
4
A_ :Optional[int] = ''' # Installazione di Transformers ! pip install transformers datasets # Per installare dalla fonte invece dell\'ultima versione rilasciata, commenta il comando sopra e # rimuovi la modalità commento al comando seguente. # ! pip install git+https://github.com/huggingf...
71
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _a : Dict = {"""configuration_glpn""": ["""GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GLPNConfig"""]} try: if not is_vision_available...
365
'''simple docstring''' 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 _a : List[str] = """▁""" _a : Optional[int] = {"""vocab_file""...
46
0
from __future__ import annotations def lowerCamelCase__ ( _a , _a): SCREAMING_SNAKE_CASE : Tuple = get_failure_array(_a) # 2) Step through text searching for pattern SCREAMING_SNAKE_CASE ,SCREAMING_SNAKE_CASE : Union[str, Any] = 0, 0 # index into text, patte...
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
'''simple docstring''' def a_ ( lowerCamelCase : list[int] ): if not nums: # Makes sure that the list is not empty raise ValueError('List is empty' ) lowerCAmelCase = sum(lowerCamelCase ) / len(lowerCamelCase ) # Calculate the average return sum(...
363
'''simple docstring''' from abc import ABC, abstractmethod from typing import List, Optional class UpperCAmelCase_ ( __lowercase ): def __init__( self : Tuple ) -> Tuple: # test for the above condition self.test() def __UpperC...
55
0
def __A ( __lowerCamelCase ) -> Optional[Any]: a = current_set.copy() for row_index, row in enumerate(lowerCamelCase_ ): a = row[0] for column_index, column in enumerate(lowerCamelCase_ ): if magnitude == 0: a = column ...
228
'''simple docstring''' from __future__ import annotations __UpperCAmelCase = { """A""": ["""B""", """C""", """E"""], """B""": ["""A""", """D""", """E"""], """C""": ["""A""", """F""", """G"""], """D""": ["""B"""], """E""": ["""A""", """B""", """D"""], """F""": ["""C"""], "...
323
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 A__ : Dict = logging.get_logger(__name__) A__ : Any = { 'google/mob...
361
"""simple docstring""" def _snake_case ( lowerCamelCase__ : Optional[Any] ) -> Optional[int]: if not head: return True # split the list to two parts lowerCamelCase_ , lowerCamelCase_ : Union[str, Any] =head.next, head w...
209
0
"""simple docstring""" from ...processing_utils import ProcessorMixin class snake_case_( a__ ): __UpperCamelCase = '''SpeechT5FeatureExtractor''' __UpperCamelCase = '''SpeechT5Tokenizer''' def __init__( self : List[str] , UpperCamelCase_ : Tuple ...
60
"""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 A__ : Optional[Any] = logging...
144
0
'''simple docstring''' def snake_case_ ( lowerCAmelCase_ )-> str: '''simple docstring''' _UpperCAmelCase : Optional[Any] = 1 _UpperCAmelCase : Dict = 2 while i * i <= n: _UpperCAmelCase : Any = ...
352
'''simple docstring''' import warnings from pathlib import Path from typing import List, Tuple, Union import fire from torch import nn from transformers import AutoModelForSeqaSeqLM, AutoTokenizer, PreTrainedModel from transformers.utils import logging A_ : Dict = logging.get_logger(__...
349
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE : Optional[Any] = { "configuration_x_clip": [ "XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "XCLIPConfig", "XCLIPTextConfig", ...
127
def UpperCAmelCase__ (UpperCamelCase_ ,UpperCamelCase_ ): """simple docstring""" snake_case = [1] for i in range(2 ,UpperCamelCase_ ): factorials.append(factorials[-1] * i ) assert 0 <= k < factorials[-1] * n, "k out of bounds"...
127
1
"""simple docstring""" import argparse import collections import json import os import re import string import sys import numpy as np __SCREAMING_SNAKE_CASE =re.compile(r"\b(a|an|the)\b", re.UNICODE) __SCREAMING_SNAKE_CASE =None def lowercase__( ): lowercase_ : str ...
368
"""simple docstring""" import argparse import tensorflow as tf import torch from transformers import BertConfig, BertForMaskedLM from transformers.models.bert.modeling_bert import ( BertIntermediate, BertLayer, BertOutput, BertPooler, BertSelfAttention, BertSelfOutput, ) from transforme...
321
0
'''simple docstring''' import io import os import unicodedata from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowerCAmelCase_ : List[Any] = logging.get_logger(__name__) low...
63
'''simple docstring''' import warnings from typing import List import numpy as np from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding from ...utils import is_flax_available, is_tf_available, is_torch_available class __SCREAMING_SNAKE_CASE (lowerCamelCa...
63
1
"""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() SCR...
351
"""simple docstring""" import os import sys import unittest SCREAMING_SNAKE_CASE__ = 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, crea...
149
0
"""simple docstring""" import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class __A ( _SCREAMING_SNAKE_CASE ): """simple docstring""" __lowerCAmelCase = ["image_processor...
81
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_available(): ...
317
0
"""simple docstring""" import copy 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 from ..auto import CONFIG_MAPPING _a : An...
95
"""simple docstring""" import dataclasses import json import sys import types from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError from copy import copy from enum import Enum from inspect import isclass from pathlib import Path from typing import Any, Callable, D...
95
1
from __future__ import annotations def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): return [ord(SCREAMING_SNAKE_CASE ) - 96 for elem in plain] def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE ): return "".join(chr(elem + 96 ) for elem in encoded ) def _SCREAMING_SNAKE...
186
"""simple docstring""" import re import string import numpy as np import datasets SCREAMING_SNAKE_CASE__ = "\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n" SCREAMING_SNAKE_CASE__ = "\...
46
0
"""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, ) __A = { "configuration_owlvit": [ ...
2
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings __A = R"\n [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and\n can be used to control the model ...
2
1
import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask lowerCAmelCase_ = logging.getLogger(__name__) class __lowerCAmelCase ( _a ): def __init__(self , __magic_...
279
'''simple docstring''' import math import os import re import sys import unittest from pathlib import Path from typing import Tuple from unittest.mock import patch from parameterized import parameterized from transformers.testing_utils import ( CaptureStderr, ExtendSysPath, TestCase...
55
0
'''simple docstring''' import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.model...
13
'''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 fr...
13
1
"""simple docstring""" import argparse import json import os import fairseq import torch from torch import nn from transformers import ( SpeechaTextaConfig, SpeechaTextaForCausalLM, SpeechaTextaTokenizer, SpeechEncoderDecoderConfig, SpeechEncoderDecoderModel, WavaV...
64
from __future__ import annotations from random import random class __A : '''simple docstring''' def __init__( self , __lowerCAmelCase = None ): '''simple docstring''' lowerCamelCase__ = value lowerCamelCase__ = random() lowerCa...
209
0
'''simple docstring''' from __future__ import annotations def SCREAMING_SNAKE_CASE( __lowercase , __lowercase ) -> float: A: str = sorted(numsa + numsa ) A , A: List[str] = divmod(len(__lowercase ) , 2 ...
334
'''simple docstring''' from __future__ import annotations import numpy as np def SCREAMING_SNAKE_CASE( __lowercase ) -> Dict: return np.maximum(0 , __lowercase ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
334
1
from __future__ import annotations def lowerCamelCase__ ( snake_case_ : int = 4 ) -> list[list[int]]: __snake_case = abs(snake_case_ ) or 4 return [[1 + x + y * row_size for x in range(snake_case_ )] for y in range(snake_case_ )] ...
24
'''simple docstring''' from datetime import datetime import requests def _lowercase ( __A ): '''simple docstring''' __UpperCamelCase = """https://downloadgram.net/wp-json/wppress/video-downloader/video?url=""" __UpperCamelCase = requests.g...
349
0
from dataclasses import dataclass from typing import Dict, 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 .attention_processor import AttentionProcessor, AttnProce...
357
def SCREAMING_SNAKE_CASE_ ( __magic_name__ : int = 1000 ) -> int: """simple docstring""" return sum(e for e in range(3 , __magic_name__ ) if e % 3 == 0 or e % 5 == 0 ) if __name__ == "__main__": print(F'''{solution() = }''')
62
0
# limitations under the License. from typing import Optional, Tuple, Union import torch from diffusers import DiffusionPipeline, ImagePipelineOutput class a__ ( A__ ): def __init__( self : Dict,_A : List[Any],_A : Any ): """simple docst...
18
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = { 'configuration_xlm_roberta_xl': [ 'XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP', 'XLMRobertaXLCo...
321
0
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 SCREAMING_SNAKE_CASE__ ( unittest.TestCase ): '''simple docstring''' def ...
115
import inspect import unittest import torch import torch.nn as nn from accelerate.hooks import ( AlignDevicesHook, ModelHook, SequentialHook, add_hook_to_module, attach_align_device_hook, remove_hook_from_module, remove_hook_from_submodules, ) from accelerate.test_utils import require_...
115
1
'''simple docstring''' from typing import TYPE_CHECKING from ..utils import _LazyModule a__ : List[Any] = { '''config''': [ '''EXTERNAL_DATA_FORMAT_SIZE_LIMIT''', '''OnnxConfig''', '''OnnxConfigWithPast''', '''OnnxSeq2SeqConfigWithPast''', ...
349
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available A__: str = {'''configuration_yolos''': ['''YOLOS_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''YolosConfig''', '''YolosOnnxConfig''']} try: if not is_v...
149
0
import os import re import unicodedata from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import is_torch_available, logging if is_torch_available(): import torc...
359
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_ti...
103
0
import numpy class __lowerCAmelCase : def __init__( self , lowerCAmelCase__ , lowerCAmelCase__ ) -> None: '''simple docstring''' a__ : int =input_array # Random initial weights a...
95
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_available...
95
1
"""simple docstring""" import os def lowercase__ ( _UpperCAmelCase ) -> int: '''simple docstring''' lowercase : Optional[Any] = len(grid[0] ) lowercase : Dict = len(a__ ) lowercase : int = ...
369
"""simple docstring""" _UpperCamelCase: Dict = 2_5_6 # Modulus to hash a string _UpperCamelCase: Union[str, Any] = 1_0_0_0_0_0_3 def lowercase__ ( _UpperCAmelCase , _UpperCAmelCase ) -> bool: '''simple docstring''...
53
0
'''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, ) lowerCamelCase : List[str] = { 'config...
2
'''simple docstring''' import dataclasses import re import string from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Tuple import numpy as np from . import residue_constants lowerCamelCase : str = Mapping[str, np.ndarray] lowerCamelCase : List[Any] = Mapping...
2
1
import numpy as np from cva import COLOR_BGR2GRAY, CV_8UC3, cvtColor, filteraD, imread, imshow, waitKey def SCREAMING_SNAKE_CASE__ ( lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ , lowerCamelCase__ ) -> np.n...
357
import unittest from pathlib import Path from tempfile import TemporaryDirectory from transformers import AutoConfig, TFGPTaLMHeadModel, is_keras_nlp_available, is_tf_available from transformers.models.gpta.tokenization_gpta import GPTaTokenizer from transformers.testing_utils import require_keras_nlp, requi...
113
0
import warnings from typing import Dict import numpy as np from ..utils import ExplicitEnum, add_end_docstrings, is_tf_available, is_torch_available from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline if is_tf_available(): from ..models.auto.modeling_tf_auto import TF_MODEL_FOR_SEQUENCE_CLASSIFICA...
13
def A_ ( _UpperCAmelCase , _UpperCAmelCase = False ): if not isinstance(_UpperCAmelCase , _UpperCAmelCase ): SCREAMING_SNAKE_CASE_: str = f"Expected string as input, found {type(_UpperCAmelCase )}" raise ValueError(_UpperCAmelCase ) if not isi...
13
1
from collections import defaultdict from math import ceil, sqrt def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase = 1_000_000, _UpperCAmelCase = 10 ) -> int: '''simple docstring''' lowerCAmelCase : defaultdict = defaultdict(_UpperCAmelCase ) for outer_width in rang...
323
from collections.abc import Sequence def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase ) -> float: '''simple docstring''' return sum(c * (x**i) for i, c in enumerate(_UpperCAmelCase ) ) def SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase, _UpperCAmelCase ) ...
323
1
"""simple docstring""" 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 _snake_case ( ...
109
import random import torch from huggingface_hub import HfApi from diffusers import UNetaDModel _lowerCamelCase : List[Any] = HfApi() _lowerCamelCase : Dict = {} # fmt: off _lowerCamelCase : List[Any] = torch.tensor([ -0.7_5_1_5, -1.6_8_8_3, 0.2_4_2_0, 0.0_3_0...
282
0
"""simple docstring""" from transformers import HfArgumentParser, TensorFlowBenchmark, TensorFlowBenchmarkArguments def _SCREAMING_SNAKE_CASE ( ) ->Optional[Any]: '''simple docstring''' a : int = HfArgumentParser(_lowercase ) a : ...
79
"""simple docstring""" from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=a__ ) class __UpperCamelCase ( a__ ): # `task` is not a ClassVar since we w...
79
1
UpperCAmelCase_ = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} UpperCAmelCase_ = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def lowerCamelCase__ ( A__ : dict[int, list[int]] , A__ : int , A__ : list[bool] ): '''simple do...
12
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A = {'configuration_sew': ['SEW_PRETRAINED_CONFIG_ARCHIVE_MAP', 'SEWConfig']} try: if not is_torch_available(): raise OptionalDependencyNotAvailable() except OptionalDepend...
62
0
lowerCamelCase : dict[tuple[int, int, int], int] ={} def SCREAMING_SNAKE_CASE ( __lowerCAmelCase , __lowerCAmelCase , __lowerCAmelCase ) -> int: # if we are absent twice, or late 3 consecutive days, # no further prize strings are possible ...
196
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 lowerCamelCase : Optional[Any] =False class ...
196
1
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def lowerCamelCase ( _UpperCamelCase : str , _UpperCamelCase : str , _UpperCamelCase : Optional[str] = None ) ->...
115
"""simple docstring""" import unittest from datasets import load_dataset from transformers import BloomTokenizerFast from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class lowerCamelCase__ ( A , ...
115
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = {"configuration_opt": ["OPT_PRETRAINED_CONFIG_ARCHIVE_MAP", "OPTConfig"]} ...
282
import random def _snake_case( SCREAMING_SNAKE_CASE__ : list , SCREAMING_SNAKE_CASE__ : str ) -> tuple: '''simple docstring''' A__ , A__ , A__ = [], [], [] for element in data: if element < pivot:...
282
1
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, ) lowercase_ = { '''configuration_owlvit''': [ '''OWLVI...
303
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import Hug...
103
0
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_...
355
import unittest from transformers import DonutProcessor __snake_case :List[str] = '''naver-clova-ix/donut-base''' class _A ( unittest.TestCase ): def _lowerCamelCase ( self : List[str]): '''simple docstring''' __a = DonutProces...
131
0
"""simple docstring""" from __future__ import annotations import random import unittest from transformers import TransfoXLConfig, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMi...
17
'''simple docstring''' import logging import torch from accelerate import Accelerator from arguments import EvaluationArguments from datasets import load_dataset from torch.utils.data import IterableDataset from torch.utils.data.dataloader import DataLoader from transformers import AutoModelForCausalLM, AutoTok...
53
0
from __future__ import annotations from random import choice def A ( _lowercase ): return choice(_a ) def A ( _lowercase , _lowercase ): SCREAMING_SNAKE_CASE : Tuple = random_pivot(_a ) # partition based on pivot # linea...
361
from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class lowercase__ ( UpperCamelCase_): Up...
258
0
'''simple docstring''' # Copyright (c) 2021-, NVIDIA CORPORATION. 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/lice...
4
"""simple docstring""" import argparse import json from pathlib import Path import torch import torchaudio from datasets import load_dataset from huggingface_hub import hf_hub_download from transformers import ASTConfig, ASTFeatureExtractor, ASTForAudioClassification from transformers.utils i...
113
0
'''simple docstring''' import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, PerceiverTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokeniza...
67
'''simple docstring''' import argparse 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 fro...
67
1
'''simple docstring''' from collections import defaultdict from math import ceil, sqrt def __A ( lowerCamelCase_ = 1_00_00_00 , lowerCamelCase_ = 10 ): """simple docstring""" SCREAMING_SNAKE_CASE : defaultdict = defaultdict(lowerCamelCase_ ) ...
323
'''simple docstring''' import unittest from diffusers import FlaxAutoencoderKL from diffusers.utils import is_flax_available from diffusers.utils.testing_utils import require_flax from .test_modeling_common_flax import FlaxModelTesterMixin if is_flax_available(): import jax @require_flax class ...
323
1
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, ...
62
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...im...
62
1
'''simple docstring''' import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class _UpperCAmelCase ( snake_case_ ): """simple docstring""" snake_case = '''Speech2TextFeatureExtractor''' snake_case = '''Speech...
79
'''simple docstring''' 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 timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from transformers import...
79
1
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version _lowerCamelCase : Union[str, Any] = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_toke...
354
from math import log from scipy.constants import Boltzmann, physical_constants _lowerCamelCase : Tuple = 3_0_0 # TEMPERATURE (unit = K) def a__ ( UpperCAmelCase : float , UpperCAmelCase : float , UpperCAmelCase : float , ) -> f...
99
0
import json import logging import os import sys from time import time from unittest.mock import patch from transformers.testing_utils import TestCasePlus, require_torch_tpu logging.basicConfig(level=logging.DEBUG) __lowerCAmelCase = logging.getLogger() def snake_case_ ...
196
from __future__ import annotations def snake_case_ ( snake_case , snake_case ) -> list[int]: lowercase__: List[str] = 0 lowercase__: Dict = len(snake_case ) - 1 while i < j: if nums[i] + nums[j] == target: ...
196
1
'''simple docstring''' import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# a_ : Optional[Any] = [ # (stable-diffusion, HF Diffusers) ("""time_embed.0.weight""", ""...
6
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_speech_available, is_torch_available, ) a_ : Any = { """configuration_trocr""": ["""TROCR_PRETRAINED_CONFIG_ARCHIVE...
6
1
import argparse import os import torch from diffusers import ( CMStochasticIterativeScheduler, ConsistencyModelPipeline, UNetaDModel, ) _lowerCamelCase : Any = { '''sample_size''': 32, '''in_channels''': 3, '''out_channels''': 3, '''layers_per_block''': 2, '''num_cl...
282
from __future__ import annotations from typing import Any class SCREAMING_SNAKE_CASE__ : '''simple docstring''' def __init__( self : Tuple , lowercase : int , lowercase : int , lowercase : float = 0 ): '''simple docstring''' _snake_case , _snake_case = row...
282
1
'''simple docstring''' from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : List[Any] = logging.get_logger(__name__) lowerCAmelCase__ : List[Any] = { "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/...
37
'''simple docstring''' from collections import UserDict from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available...
37
1
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 __lowerCAmelCase : """simple docstring""" ...
90
import os import time import warnings from dataclasses import dataclass, field from enum import Enum from typing import List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...tokenization_utils_base import PreTrainedTokenizerBase from ...utils i...
131
0
from __future__ import annotations import sys from collections import deque from typing import Generic, TypeVar SCREAMING_SNAKE_CASE : int = TypeVar("T") class _lowerCamelCase( Generic[T] ): lowercase_ : deque[T] # Cache store of keys lowercase_ : set[T] # R...
356
from collections import defaultdict def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Optional[Any] = 1 _lowercase : Union[str, Any] = True for v in tree[start]: if v not in visited: ret += dfs(lowerCamelCase_ ) if ret % 2 == ...
84
0
"""simple docstring""" def __UpperCAmelCase ( __lowerCamelCase , __lowerCamelCase ) -> str: if not isinstance(__lowerCamelCase , __lowerCamelCase ): raise ValueError('''iterations must be defined as integers''' ) if not isinstance(__lowerCamelC...
16
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase : List[str] = {'configuration_vit_msn': ['VIT_MSN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ViTMSNConfig']} try: if not is_torch_available(): raise OptionalD...
232
0
"""simple docstring""" from math import log from scipy.constants import Boltzmann, physical_constants __snake_case : List[Any] = 300 # TEMPERATURE (unit = K) def _lowercase ( __snake_case ,__snake_case ,__snake_case ,) -> float: if donor_conc ...
58
"""simple docstring""" import unittest import numpy as np from diffusers import OnnxStableDiffusionInpaintPipelineLegacy from diffusers.utils.testing_utils import ( is_onnx_available, load_image, load_numpy, nightly, require_onnxruntime, require_torch_gpu, ) ...
58
1
'''simple docstring''' from __future__ import annotations from random import random from typing import Generic, TypeVar __UpperCAmelCase =TypeVar("KT") __UpperCAmelCase =TypeVar("VT") class a__ ( Generic[KT, VT] ): def __init__( self : int , a : KT | str = "...
67
'''simple docstring''' import logging import os from .state import PartialState class a__ ( logging.LoggerAdapter ): @staticmethod def SCREAMING_SNAKE_CASE__ ( a : Optional[Any] ): """simple docstring""" __lowerCamelCase = PartialState() ...
67
1
"""simple docstring""" # Usage: # ./gen-card-allenai-wmt16.py import os from pathlib import Path def _lowerCAmelCase ( UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ , UpperCamelCase_ ): __SCREAMING_SNAKE_CASE = { """en""": """Machine learning is great, isn't it?...
255
"""simple docstring""" import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow __magic_name__ = False class SCREAMING_SNAKE_CASE_ ( unittest.TestCase ): "...
255
1
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class UpperCAmelCase__ ( A_ ): """simple...
62
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _A = { 'configuration_jukebox': [ 'JUKEBOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'JukeboxConfig', 'JukeboxPriorConfig', 'JukeboxVQVAEConfig', ], ...
62
1
from random import shuffle import tensorflow as tf from numpy import array def lowerCamelCase_ ( UpperCamelCase__ : Optional[Any] , UpperCamelCase__ : int ) -> Optional[Any]: """simple docstring""" __lowerCamelCase = int(UpperCamel...
348
import tempfile import unittest import numpy as np import transformers from transformers import GPTaTokenizer, GPTJConfig, is_flax_available, is_torch_available from transformers.testing_utils import is_pt_flax_cross_test, require_flax, tooslow from ...generation.test_flax_utils import FlaxGenerat...
348
1
'''simple docstring''' from math import loga def snake_case_ ( __SCREAMING_SNAKE_CASE : List[Any] ): """simple docstring""" if a < 0: raise ValueError('''Input value must be a positive integer''' ) elif isinstance(A__ , ...
93
def A_ ( A__ ) -> int: stooge(A__ , 0 , len(A__ ) - 1 ) return arr def A_ ( A__ , A__ , A__ ) -> List[Any]: if i >= h: return # If first element is smaller than the last then swap them if arr[i] > arr[h]: ...
99
0
import contextlib import copy import random from typing import Any, Dict, Iterable, Optional, Union import numpy as np import torch from .utils import deprecate, is_transformers_available if is_transformers_available(): import transformers def SCREAMING_SNAKE_CASE_ ( _...
120
def SCREAMING_SNAKE_CASE_ ( __A : int ) -> int: """simple docstring""" if n == 1 or not isinstance(__A , __A ): return 0 elif n == 2: return 1 else: a_ : int = [0, 1] for i in ra...
120
1
import argparse import os.path as osp import re import torch from safetensors.torch import load_file, save_file # =================# # UNet Conversion # # =================# A : Dict = [ # (stable-diffusion, HF Diffusers) ('time_embed.0.weight', 'time_embedding.linear_1.weight'), ('time_embed.0....
6
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A : Optional[int] = { 'configuration_whisper': ['WHISPER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Whisper...
6
1
from __future__ import annotations def _SCREAMING_SNAKE_CASE ( lowercase : list[int | str] ): '''simple docstring''' create_state_space_tree(lowercase , [] , 0 , [0 for i in range(len(lowercase ) )] ) def _S...
208
import argparse import collections import os import re import tempfile import pandas as pd from datasets import Dataset from huggingface_hub import hf_hub_download, upload_folder from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this ...
208
1
'''simple docstring''' import unittest from transformers import ( MODEL_FOR_OBJECT_DETECTION_MAPPING, AutoFeatureExtractor, AutoModelForObjectDetection, ObjectDetectionPipeline, is_vision_available, pipeline, ) from transformers.testing_utils import ( is_pipeline_test, nested_s...
37
'''simple docstring''' import os from bleurt import score # From: git+https://github.com/google-research/bleurt.git import datasets _lowerCAmelCase = datasets.logging.get_logger(__name__) _lowerCAmelCase = '''\ @inproceedings{bleurt, title={BLEURT: Learning Robust Metrics for Tex...
37
1
"""simple docstring""" import argparse import os from pathlib import Path import torch from bark.generation import _load_model as _bark_load_model from huggingface_hub import hf_hub_download from transformers import EncodecConfig, EncodecModel, set_seed from transformers.models.bark.configuration_bark impor...
358
"""simple docstring""" import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) class ...
296
0
import argparse import logging import pickle import random import time import numpy as np from transformers import BertTokenizer, GPTaTokenizer, RobertaTokenizer logging.basicConfig( format='''%(asctime)s - %(levelname)s - %(name)s - %(message)s''', datefmt='''%m/%d/%Y %H:%M:%S''', level=logging.INFO ) Uppe...
345
"""simple docstring""" 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, Trai...
84
0
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers from transformers im...
65
import argparse from pathlib import Path from transformers import AutoConfig, AutoTokenizer, RagConfig, RagSequenceForGeneration, RagTokenForGeneration def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAM...
65
1
'''simple docstring''' import logging import os from logging import ( CRITICAL, # NOQA DEBUG, # NOQA ERROR, # NOQA FATAL, # NOQA INFO, # NOQA NOTSET, # NOQA WARN, # NOQA WARNING, # NOQA ) from typing import Optional from tqdm import auto as tqdm_lib lowercase_ = { ...
58
'''simple docstring''' from __future__ import annotations import unittest from transformers import AutoTokenizer, PegasusConfig, is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_config...
58
1
'''simple docstring''' from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docst...
371
'''simple docstring''' from __future__ import annotations from typing import Any class UpperCAmelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' pass class UpperCAmelCase_ : '''simple docstring''' def __init__( self , _lowerca...
229
0