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 unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch from transformers.utils import is_torch_available ...
13
'''simple docstring''' import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( ConditionalDetrConfig, ConditionalDetrForObjectDetection, Condition...
1
0
from ...configuration_utils import PretrainedConfig from ...utils import logging _SCREAMING_SNAKE_CASE : Optional[int] = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE : int = {"ctrl": "https://huggingface.co/ctrl/resolve/main/config.json"} class A__ ( __low...
357
from __future__ import annotations from collections.abc import Generator import requests from bsa import BeautifulSoup _SCREAMING_SNAKE_CASE : str = "https://www.indeed.co.in/jobs?q=mobile+app+development&l=" def UpperCAmelCase__ (UpperCamelCase_ = "mumbai" ): ...
213
0
"""simple docstring""" from datetime import datetime import matplotlib.pyplot as plt import torch def UpperCAmelCase__ ( _UpperCAmelCase ): """simple docstring""" for param in module.parameters(): A_ : List[str] = False def UpperCAmelCase__ ...
286
"""simple docstring""" import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging lowerCamelCase_ : Tuple = logging.get_logger(__name__) def UpperCAmelCase__ ( _UpperCAmelCase ...
286
1
import os import unittest from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer from ...test_tokenization_common import TokenizerTesterMixin class lowercase__ ( lowercase , unittest.TestCase ): lowercase__ = PhobertTokenizer ...
363
'''simple docstring''' from __future__ import annotations import time from collections.abc import Sequence from random import randint from matplotlib import pyplot as plt def A__ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ ): if not arr: return None, None, 0 ...
236
0
from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificati...
328
'''simple docstring''' import json import os import tempfile from transformers.testing_utils import check_json_file_has_correct_format class lowerCAmelCase__ : lowerCAmelCase_ = None def _snake_case ( self ): """simple docst...
93
0
"""simple docstring""" def _lowerCAmelCase ( lowerCAmelCase ): '''simple docstring''' if not isinstance(_A , _A ): raise ValueError("""Input series is not valid, valid series - [2, 4, 6]""" ) if len(_A ) == 0: raise ValueErro...
358
"""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...
248
0
import random import unittest import numpy as np from diffusers import ( DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionImgaImgPipeline, PNDMScheduler, ) from diffusers.utils import floats_tensor from diffusers...
36
'''simple docstring''' import unittest import numpy as np from transformers import BertConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask if is...
223
0
def lowerCamelCase_ ( UpperCamelCase__ : str , UpperCamelCase__ : int ) -> list: """simple docstring""" __lowerCamelCase = word.split() def justify(UpperCamelCase__ : list , UpperCamelCase__ : int , UpperCamelCase__ ...
348
from collections import OrderedDict from typing import TYPE_CHECKING, Any, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig, OnnxSeqaSeqConfigWithPast from ...utils import logging if TYPE_CHECKING: from ...feature_extraction_utils imp...
348
1
"""simple docstring""" import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": lowercase__ = argparse.ArgumentParser() parser.add_ar...
96
import tempfile import torch from diffusers import ( DEISMultistepScheduler, DPMSolverMultistepScheduler, DPMSolverSinglestepScheduler, UniPCMultistepScheduler, ) from .test_schedulers import SchedulerCommonTest class A ( _UpperCAmelCase ): """simple...
7
0
"""simple docstring""" def __lowercase ( snake_case_ : list[list[float]] ) ->Tuple: '''simple docstring''' __A : List[Any] = [] for data in source_data: for i, el in enumerate(SCREAMING_SNAKE_CASE_ ): if len(SCREAMING_SN...
364
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available a_ = { """configuration_bloom""": ["""BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """BloomConfig""", """BloomOnnxConfig"""], } try: ...
291
0
from typing import List, Optional, Union from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowercase__ ...
182
def A ( _lowercase , _lowercase , _lowercase ): return round(float(moles / volume ) * nfactor ) def A ( _lowercase , _lowercase , _lowercase ): return round(float((moles * 0.0821 * temperature) / (volume) ) ) def A ( _lowercase , _lowerc...
182
1
import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils import cached...
353
from __future__ import annotations import queue class a_ : '''simple docstring''' def __init__( self , lowercase_ ) -> List[Any]: '''simple docstring''' lowerCAmelCase_ = data ...
14
0
'''simple docstring''' import requests from bsa import BeautifulSoup def snake_case_ ( _lowerCAmelCase : str = "https://www.worldometers.info/coronavirus" ) -> dict: UpperCAmelCase : str = BeautifulSoup(requests.get(_lowerCAmelCase ).text , ...
23
"""simple docstring""" from __future__ import annotations import math def lowerCamelCase__ ( _lowerCamelCase : int ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 ...
183
0
import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImageProcessor from diffusers.pipelin...
368
from ....utils import logging A : List[str] = logging.get_logger(__name__) class lowerCamelCase (SCREAMING_SNAKE_CASE__ ): """simple docstring""" def __init__( self : List[str] , __magic_name__ : Optional[Any] , __magic_name__ : Any=None ...
305
0
"""simple docstring""" def _UpperCAmelCase ( __lowerCamelCase : Union[str, Any]=2_81_23 ) -> List[str]: _snake_case = [1] * (limit + 1) for i in range(2 , int(limit**0.5 ) + 1 ): sum_divs[i * i] += i for k in range(i + 1 , limit // i + 1 ):...
288
"""simple docstring""" def _UpperCAmelCase ( __lowerCamelCase : int = 1_00_00_00 ) -> int: _snake_case = limit + 1 _snake_case = [0] * limit for first_term in range(1 , __lowerCamelCase ): for n in range(__lowerCamelCase , __lowerC...
288
1
"""simple docstring""" def __lowerCAmelCase ( a__ , a__ ) -> Any: if not len(SCREAMING_SNAKE_CASE__ ) == len(SCREAMING_SNAKE_CASE__ ) == 3: raise ValueError('''Please enter a valid equation.''' ) if equationa[0] == equationa[1] == equationa[0] == equationa[1] == 0: ...
366
import logging from transformers.configuration_utils import PretrainedConfig A : Union[str, Any] = logging.getLogger(__name__) class __A( a ): snake_case_ = '''masked_bert''' def __init__( self , _snake_case=30_522 , _snake_case=768 , ...
33
0
"""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 # ...
106
"""simple docstring""" import argparse import logging import os from datetime import datetime import numpy as np import torch from torch import nn from torch.utils.data import DataLoader, RandomSampler, TensorDataset from tqdm import tqdm from transformers import GPTaLMHeadModel __UpperCamelCase : int ...
106
1
'''simple docstring''' import os import re import warnings from shutil import copyfile from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer if TYPE_CHECKING: from ...tokenization_utils_base import TextInput f...
156
'''simple docstring''' import pyarrow.parquet as pq import pytest from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config from datasets.features.image import Image from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size from ....
156
1
'''simple docstring''' import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if n...
53
def A ( lowercase ) -> list: '''simple docstring''' UpperCamelCase = len(lowercase ) for i in range(1 , lowercase ): UpperCamelCase = collection[i] UpperCamelCase = 0 UpperCamelCase = i - 1 while low <= high: UpperCamelCase = (low + hig...
222
0
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging _a = logging.get_logger(__name__) _a = { """microsoft/biogpt""": """https://huggingface.co/microsoft/biogpt/resolve/main/config.json""", # See all BioGPT mo...
100
"""simple docstring""" import warnings from diffusers import StableDiffusionInpaintPipeline as StableDiffusionInpaintPipeline # noqa F401 warnings.warn( """The `inpainting.py` script is outdated. Please use directly `from diffusers import""" """ StableDiffusionInpaintPipeline` instead.""...
100
1
"""simple docstring""" from abc import ABC, abstractmethod from typing import List, Optional class a ( lowerCAmelCase_ ): def __init__( self : List[str] ): # test for the above condition self.test() def lowerCAmelCase_ ( self : Optional[int] ): ...
289
"""simple docstring""" from __future__ import annotations def __UpperCAmelCase ( lowercase ,lowercase ): """simple docstring""" _UpperCAmelCase = get_failure_array(lowercase ) # 2) Step through text searching for pattern _UpperCAmelCase , _UpperCAmelCase ...
289
1
"""simple docstring""" 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 = """.""" if __name__ == "__main__": __A = os.path.join(REPO_PATH, '''utils/documentation_tests.txt''') __A ...
351
"""simple docstring""" from ...configuration_utils import PretrainedConfig class _snake_case ( a__ ): snake_case__ = "bert-generation" def __init__( self : Optional[int] , UpperCAmelCase : Dict=50358 , UpperCAmelCase : int=1024 , U...
64
0
import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging ...
24
"""simple docstring""" import unittest from transformers import MODEL_FOR_ZERO_SHOT_OBJECT_DETECTION_MAPPING, is_vision_available, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines...
213
0
"""simple docstring""" from abc import ABC, abstractmethod from typing import List, Optional class A__ ( _lowerCamelCase): def __init__( self ): # test for the above condition self.test() def __lowerCamelCase ( self ): __lowerCAmelCase : int ...
182
"""simple docstring""" import gc import random import unittest import numpy as np import torch from PIL import Image from diffusers import ( DDIMScheduler, KandinskyVaaInpaintPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, lo...
182
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) UpperCamelCase = { "configuration_convnext": ["CONVNEXT_PRETRAINED_CONFIG...
319
from typing import TYPE_CHECKING from ....utils import _LazyModule _UpperCAmelCase : Dict = {"tokenization_tapex": ["TapexTokenizer"]} if TYPE_CHECKING: from .tokenization_tapex import TapexTokenizer else: import sys _UpperCAmelCase : Optional[Any] = _LazyModule(__name__, globals()["...
236
0
# Copyright 2021 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
356
from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class __magic_name__ ( nn.Module ): """simple docstring""" def __init__( self :int , snake_case :int = 16 , snake_case :int = 88...
70
0
from ...utils import ( OptionalDependencyNotAvailable, is_flax_available, is_torch_available, is_transformers_available, ) try: if not (is_transformers_available() and is_torch_available()): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailabl...
90
def _UpperCAmelCase ( ): '''simple docstring''' return [ a * b * (1_0_0_0 - a - b) for a in range(1 , 9_9_9) for b in range(a__ , 9_9_9) if (a * a + b * b == (1_0_0_0 - a - b) ** 2) ][0] if __name__ == "__main__": print(F"""{solution() = }""")
248
0
'''simple docstring''' import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_...
5
'''simple docstring''' import inspect import unittest from transformers import ViTMSNConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_common import ...
5
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available UpperCamelCase__ : int = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'...
344
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCamelCase__ : int = {...
344
1
'''simple docstring''' import inspect import re from hashlib import shaaaa from typing import Dict, List from .arrow import arrow from .audiofolder import audiofolder from .csv import csv from .imagefolder import imagefolder from .json import json from .pandas import pandas from .parquet import par...
31
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __lowercase: Dict = { "configuration_time_series_transformer": [ "TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "Ti...
31
1
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig UpperCAmelCase : List[str] = { """albert-base-v1""": """https://huggingface.co/albert-base-v1/resolve/main/config.json""", """albe...
95
"""simple docstring""" def a__ ( snake_case__ ) -> bool: lowerCamelCase = (1 + 24 * n) ** 0.5 return ((1 + root) / 6) % 1 == 0 def a__ ( snake_case__ = 50_00 ) -> int: lowerCamelCase = [(i * (3 * i - 1)) // 2 for i in range(1 , sna...
291
0
'''simple docstring''' from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class lowerCAmelCase__ ( UpperCAmelCase__ ): ...
322
'''simple docstring''' import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version lowerCamelCase__ = version.parse(importlib_metadata.version('nltk')) if NLTK_VERSION >= version.Version('3.6.4'): from nltk ...
322
1
import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): from .tokeniz...
48
import collections from typing import List, Optional, Union from ...tokenization_utils_base import BatchEncoding from ...utils import TensorType, add_end_docstrings, add_start_docstrings, logging from ..bert.tokenization_bert_fast import BertTokenizerFast from .tokenization_dpr import DPRContextEncoderTokenizer, ...
14
0
"""simple docstring""" from __future__ import annotations from fractions import Fraction from math import gcd, sqrt def _snake_case ( _snake_case : int ) -> bool: '''simple docstring''' _A = int(number**0.5 ) return number == sq * sq ...
271
"""simple docstring""" def _snake_case ( _snake_case : str ) -> str: '''simple docstring''' _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 d...
271
1
from dataclasses import dataclass from typing import List, Optional, Union import numpy as np import PIL import torch from transformers import CLIPImageProcessor, CLIPVisionModel from ...models import PriorTransformer from ...pipelines import DiffusionPipeline from ...schedulers import HeunDiscreteScheduler from ......
19
A : Union[str, Any] = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} A : List[Any] = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def UpperCamelCase ( __magic_name__ : dict[int, list[int]] , __magic_name__ : int , __magic_name__ ...
305
0
'''simple docstring''' import json import os from dataclasses import dataclass from functools import partial from typing import Callable import flax.linen as nn import jax import jax.numpy as jnp import joblib import optax import wandb from flax import jax_utils, struct, traverse_util from flax.serialization import ...
361
'''simple docstring''' def _lowerCAmelCase ( _UpperCamelCase : float , _UpperCamelCase : float ) -> float: """simple docstring""" if mass < 0: raise ValueError('The mass of a body cannot be negative' ) return 0.5 * mass * abs(_UpperCamelCase ...
114
0
"""simple docstring""" import argparse import glob import logging import os from argparse import Namespace from importlib import import_module import numpy as np import torch from lightning_base import BaseTransformer, add_generic_args, generic_train from seqeval.metrics import accuracy_score, fa_score, precis...
60
"""simple docstring""" def lowercase ( __snake_case : int ): if not isinstance(__snake_case , __snake_case ): raise ValueError('''Input must be an integer''' ) if input_num <= 0: raise ValueError('''Input must be positive''' ) return sum( divisor for di...
33
0
from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging lowercase__ =logging.get_logger(__name__) lowercase__ ={ """nielsr/canine-s""": 2048, } # Unicode defines 1,114,112 total “codepoints” lowercase__ ...
360
import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backbone_common import BackboneTester...
90
0
def UpperCAmelCase_ ( __lowerCAmelCase ) -> str: if number > 0: raise ValueError('''input must be a negative integer''' ) __lowercase : Optional[int] = len(bin(__lowerCAmelCase )[3:] ) __lowercase : int = bin(abs(__lowerCAmelCase ) - (1 << binary_num...
156
import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Audio, ClassLabel, Features from .base import TaskTemplate @dataclass(frozen=lowerCAmelCase_ ) class __lowerCAmelCase ( lowerCAmelCase_ ): """simple docstring""" ...
156
1
import argparse import hashlib # hashlib is only used inside the Test class import struct class __A : """simple docstring""" def __init__( self , lowerCamelCase__ ): """simple docstring""" __UpperCamelCase : List[str] =data __UpperC...
355
from ...configuration_utils import PretrainedConfig from ...utils import logging A_ :Any = logging.get_logger(__name__) A_ :List[Any] = { '''edbeeching/decision-transformer-gym-hopper-medium''': ( '''https://huggingface.co/edbeeching/decision-transformer-gym-ho...
245
0
"""simple docstring""" def _lowerCAmelCase ( UpperCamelCase_ = 5000_0000 ): __SCREAMING_SNAKE_CASE = set() __SCREAMING_SNAKE_CASE = int((limit - 24) ** (1 / 2) ) __SCREAMING_SNAKE_CASE = set(range(3 , prime_square_limit + 1 , 2 ) ) primes.a...
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
"""simple docstring""" import math from collections.abc import Iterator from itertools import takewhile def a__ ( lowerCAmelCase ) -> bool: if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Neg...
357
"""simple docstring""" import os import tempfile from functools import partial from unittest import TestCase from unittest.mock import patch import datasets import datasets.config from .utils import require_beam class lowerCamelCase ( datasets.BeamBasedBuilder ): '''simple docstring''' def ...
166
0
import sys import turtle def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE , )...
43
"""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, ) if ...
64
0
import json import os import unittest from transformers import MgpstrTokenizer from transformers.models.mgp_str.tokenization_mgp_str import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers class lo...
363
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, ) if is_onnx_available(): import onnxruntime as ort...
343
0
def A ( ): return [list(range(1_000 - i , -1_000 - i , -1 ) ) for i in range(1_000 )] __UpperCamelCase : Any = generate_large_matrix() __UpperCamelCase : Union[str, Any] = ( [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3...
182
def A ( _lowercase , _lowercase , _lowercase ): return round(float(moles / volume ) * nfactor ) def A ( _lowercase , _lowercase , _lowercase ): return round(float((moles * 0.0821 * temperature) / (volume) ) ) def A ( _lowercase , _lowerc...
182
1
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 im...
352
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 a (_lowerCAmelCase ): """simple docstring""" ...
134
0
import argparse import os import shutil from pathlib import Path import onnx import torch from packaging import version from torch.onnx import export from diffusers import OnnxRuntimeModel, OnnxStableDiffusionPipeline, StableDiffusionPipeline SCREAMING_SNAKE_CASE__ : Dict = vers...
48
'''simple docstring''' import unittest from transformers import is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device if is_torch_available(): from transformers import AutoModelForSeqaSeqLM, AutoTok...
70
0
def __UpperCamelCase () -> int: return [ a * b * (1000 - a - b) for a in range(1 , 999 ) for b in range(_SCREAMING_SNAKE_CASE , 999 ) if (a * a + b * b == (1000 - a - b) ** 2) ][0] if __name__ == "__main__": print(f'''{solution() = ...
269
from typing import Callable, Optional from .. import Features from ..packaged_modules.generator.generator import Generator from .abc import AbstractDatasetInputStream class SCREAMING_SNAKE_CASE (UpperCAmelCase ): def __init__( self : List[str] , a : Call...
269
1
import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XLMRobertaTokenizer, XLMRobertaTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from ...test_token...
5
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available UpperCAmelCase__ = { '''configuration_xlm''': ['''XLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XLMConfig''', '''XLMOnnxConfig'''], '''tokenization_xlm''': ['''XLMToke...
5
1
import copy import re class lowerCAmelCase : '''simple docstring''' SCREAMING_SNAKE_CASE_ : List[Any] = """hp""" SCREAMING_SNAKE_CASE_ : List[str] = {} SCREAMING_SNAKE_CASE_ : Tuple = None @classm...
360
"""simple docstring""" class lowerCAmelCase : '''simple docstring''' def __init__( self , lowerCAmelCase__ ) -> None: SCREAMING_SNAKE_CASE = size SCREAMING_SNAKE_CASE = [0] * size SCREAMING_SNAKE_CAS...
38
0
'''simple docstring''' import unittest import numpy as np import torch from diffusers import ScoreSdeVePipeline, ScoreSdeVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class lowerCamelCase_ (unittest.TestC...
31
'''simple docstring''' import copy from typing import Any, Dict, List, Optional, Union import numpy as np import torch from ...audio_utils import mel_filter_bank, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFea...
31
1
'''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 impor...
354
'''simple docstring''' from typing import TYPE_CHECKING from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowercase__ = {"configuration_van": ["VAN_PRETRAINED_CONFIG_ARCHIVE_MAP", "VanConfig"]} try: if not is_torch_available(): ...
280
0
from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class A_ ( snake_case__ ): def __init__( self : Tuple ...
322
from .testing import ( are_the_same_tensors, execute_subprocess_async, require_bnb, require_cpu, require_cuda, require_huggingface_suite, require_mps, require_multi_gpu, require_multi_xpu, require_safetensors, require_single_gpu, require_single_xpu, r...
322
1
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __lowerCAmelCase ( ) -> List[str]: __a = ArgumentParser( description=( '''PyTorch TPU distributed train...
369
from pathlib import Path import cva import numpy as np from matplotlib import pyplot as plt def __lowerCAmelCase ( a__ , a__ , a__ , a__ , a__ ) -> np.ndarray: __a = cva.getAffineTransform(a__ , a__ ) return cva.warpAffine(a__ , a__ ...
33
0
'''simple docstring''' import unittest from transformers import MPNetConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask...
271
'''simple docstring''' import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class UpperCAmelCase__ ( lowercase__ ): """simple docstring""" __UpperC...
271
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, t...
17
'''simple docstring''' import baseaa def __UpperCAmelCase ( a_: str ): return baseaa.baaencode(string.encode("utf-8" ) ) def __UpperCAmelCase ( a_: bytes ): return baseaa.baadecode(a_ ).decode("utf-8" ) if __name__ == "__main__": ...
17
1
"""simple docstring""" from typing import List import datasets from datasets.tasks import AudioClassification from ..folder_based_builder import folder_based_builder _lowercase = datasets.utils.logging.get_logger(__name__) class lowerCAmelCase_ ( folder_based_builder.FolderBasedBuilderCon...
74
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils i...
114
0
import requests __a = 'https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey=' def lowerCamelCase__ ( _lowercase ): '''simple docstring''' UpperCAmelCase_ : List[str] = requests.get(_NEWS_API + bbc_news_api_key ).json() # each ...
235
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) f...
235
1
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, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import load_image if ...
30
import argparse import shutil from pathlib import Path from tqdm import tqdm from transformers import AutoTokenizer def lowerCamelCase_ ( UpperCamelCase__ : List[Any] , UpperCamelCase__ : Optional[int] , UpperCamelCase__ : str , UpperCamelCa...
90
0
'''simple docstring''' def _A ( A__ ): """simple docstring""" __lowercase = int(A__ ) if n_element < 1: __lowercase = ValueError('''a should be a positive number''' ) raise my_error __lowercase = [1] __lowercase , __lowercase , __lowerc...
371
'''simple docstring''' lowerCAmelCase__ = { "joule": 1.0, "kilojoule": 1000, "megajoule": 100_0000, "gigajoule": 10_0000_0000, "wattsecond": 1.0, "watthour": 3600, "kilowatthour": 360_0000, "newtonmeter": 1.0, "calorie_nutr": 4186.8, "kilocalorie_nutr": 418_6800...
52
0
from __future__ import annotations def lowerCAmelCase__ ( lowerCamelCase_ : Dict): '''simple docstring''' if not nums: return 0 lowerCAmelCase__ : Optional[Any] = nums[0] lowerCAmelCase__ : List[Any] = 0 for num in nums[1:]: ...
129
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging UpperCAmelCase__ ...
245
0
"""simple docstring""" from queue import Queue from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from ..models.auto import AutoTokenizer class __A : """simple docstring""" def SCREAMING_SNAKE_CASE ( self , __A ...
358
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING lowerCamelCase_ : int = logging.get_logger(__name__) class __A ( _SCREAMING_...
215
0
import unittest from parameterized import parameterized from transformers import AutoTokenizer, GPTNeoXConfig, is_torch_available, set_seed from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common imp...
219
'''simple docstring''' from __future__ import annotations def _A ( _lowerCAmelCase ): """simple docstring""" __lowercase =[True] * limit __lowercase =False __lowercase =False __lowercase =True for i in range(3 , int(...
166
0
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __UpperCamelCase : Union[str, Any] = (720, 1_280) # Height, Width __UpperCamelCase : Any = (0.4, 0.6) # if height or width lower than this scale, drop it. __Upp...
347
import glob import os import random from string import ascii_lowercase, digits import cva import numpy as np # Parrameters __UpperCamelCase : Union[str, Any] = (720, 1_280) # Height, Width __UpperCamelCase : Any = (0.4, 0.6) # if height or width lower than this scale, drop it. __Upp...
347
1
"""simple docstring""" def _snake_case ( _snake_case : Optional[int] = 10_00 ) -> int: '''simple docstring''' _A = 3 _A = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a ...
315
import inspect import unittest import numpy as np from transformers import ViTConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor if is_flax_available()...
343
0
from typing import List, Optional, Tuple, Union import torch from ...utils import logging, randn_tensor from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline _A : Optional[int] = logging.get_logger(__name__) # pylint: disable=invalid-name class __SCREAMING_SNAKE_CASE ( lo...
363
import argparse import os import jax as jnp import numpy as onp import torch import torch.nn as nn from music_spectrogram_diffusion import inference from tax import checkpoints from diffusers import DDPMScheduler, OnnxRuntimeModel, SpectrogramDiffusionPipeline from diffusers.pipelines.spectrogram_diffusion impo...
265
0
'''simple docstring''' import os from shutil import copyfile from typing import List, Optional, Tuple from ...tokenization_utils import AddedToken from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, logging if is_sentencepiece_available(): ...
323
'''simple docstring''' from __future__ import annotations from collections.abc import MutableSequence class lowerCamelCase : '''simple docstring''' def __init__( self : List[str] , lowerCAmelCase_ : int , lowerCAmelCase_ : MutableSequence[float] ) ->...
134
0
from __future__ import annotations import math def _SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): A_ : Tuple = u for i in range(1 , SCREAMING_SNAKE_CASE ): A_ : List[Any] = temp * (u - i) return temp def _SCREAMING_SNAKE_CASE ...
65
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 torch if is_tf_available()...
65
1
"""simple docstring""" import numpy as np from PIL import Image def _lowercase ( __snake_case ,__snake_case ,__snake_case ) -> np.ndarray: __lowerCAmelCase : Optional[int] = np.array(__snake_case ) if arr.shape[0] != arr.shape[1]: ra...
269
"""simple docstring""" from typing import TYPE_CHECKING from ..utils import _LazyModule __snake_case : Optional[int] = { 'config': [ 'EXTERNAL_DATA_FORMAT_SIZE_LIMIT', 'OnnxConfig', 'OnnxConfigWithPast', 'OnnxSeq2SeqConfigWithPast', ...
269
1
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from typing import Optional import numpy as np import torch from datasets import load_dataset from torchvision.transforms import Compose, Lambda, Normalize, RandomHorizontalFlip, RandomResizedCrop, ToTensor imp...
360
def a( ) -> str: """simple docstring""" a = 0 for i in range(1 , 1001 ): total += i**i return str(A )[-10:] if __name__ == "__main__": print(solution())
71
0
import gc import random import unittest import numpy as np import torch from transformers import CLIPImageProcessor, CLIPVisionConfig, CLIPVisionModel from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEImgaImgPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils impo...
124
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_CHECKIN...
38
0
'''simple docstring''' import os def _SCREAMING_SNAKE_CASE ( UpperCamelCase ): """simple docstring""" lowerCAmelCase__ : List[str] = len(grid[0] ) lowerCAmelCase__ : int = len(UpperCamelCase ) lowerCAmelCase__ : Optional[int] ...
184
'''simple docstring''' from __future__ import annotations # This is the precision for this function which can be altered. # It is recommended for users to keep this number greater than or equal to 10. _lowerCAmelCase = 10 def _SCREAMING_SNAKE_CASE ( UpperCamelCase , UpperCamelCase...
184
1
'''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_checkp...
85
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 UpperCAmelCase : Any = logging.get_logger(__name__) def _...
280
0
"""simple docstring""" import unittest from transformers import GPTNeoXJapaneseConfig, is_torch_available from transformers.models.gpt_neox_japanese.tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuratio...
366
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) snake_case__ : int = {'''configuration_plbart''': ['''PLBART_PRETRAIN...
314
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import _LazyModule __a = {'processing_wav2vec2_with_lm': ['Wav2Vec2ProcessorWithLM']} if TYPE_CHECKING: from .processing_wavaveca_with_lm import WavaVecaProcessorWithLM else: import sys __a = _Lazy...
145
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configuration...
145
1
import fire from utils import calculate_rouge, save_json def lowerCamelCase__ (_UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase=None , **_UpperCAmelCase): SCREAMING_SNAKE_CASE = [x.strip() for x in open(_UpperCAmelCase).readlines()] SCREAMING_SNAKE_CASE ...
327
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
327
1
import requests from bsa import BeautifulSoup def lowerCAmelCase_ (lowerCAmelCase__: str = "https://www.worldometers.info/coronavirus" ): """simple docstring""" UpperCAmelCase_: Dict = BeautifulSoup(requests.get(lowerCAmelCase__ ).text , ...
147
import math from typing import Callable, List, Optional, Union import numpy as np import PIL import torch from PIL import Image from transformers import CLIPTextModel, CLIPTokenizer from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stable_diffusion.pipeline_st...
147
1
def UpperCamelCase_( snake_case__: int , snake_case__: list ) -> Union[str, Any]: _enforce_args(snake_case__ , snake_case__ ) if n == 0: return 0 UpperCAmelCase__ = float('-inf' ) for i in range(1 , n + 1 ): UpperCAmelCase__ = max...
335
import copy import os import cva import numpy as np from matplotlib import pyplot as plt class lowercase : '''simple docstring''' def __init__(self ) -> str: """simple docstring""" UpperCAmelCase__ = '' UpperCAmelCase__ = ...
335
1
import os from pathlib import Path def lowerCAmelCase ( )-> List[Any]: from torch.utils.cpp_extension import load lowerCAmelCase_ : Dict = Path(_lowercase ).resolve().parent.parent.parent / """kernels""" / """deformable_detr""" lowerCAmelCase_ : List[str...
262
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a : Optional[int] = { """configuration_git""": ["""GIT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GitConfig""", """GitVisionConfig"""], """processing_git...
265
0
'''simple docstring''' import numpy as np import torch from torch.utils.data import Dataset from utils import logger class UpperCamelCase__ ( SCREAMING_SNAKE_CASE_ ): """simple docstring""" def __init__( self , snake_case__ , snake_case__ ): ''...
353
'''simple docstring''' import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, MBartaaTokenizer, MBartaaTokenizerFast, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepie...
25
0
"""simple docstring""" from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
60
import collections import gzip import os import urllib import numpy from tensorflow.python.framework import dtypes, random_seed from tensorflow.python.platform import gfile from tensorflow.python.util.deprecation import deprecated _SCREAMING_SNAKE_CASE : Optional[int] = collections.namedtuple('''_Datase...
314
0
import numpy as np from nltk.translate import meteor_score import datasets from datasets.config import importlib_metadata, version __UpperCAmelCase : Optional[Any] = version.parse(importlib_metadata.version("nltk")) if NLTK_VERSION >= version.Version("3.6.4"): from nltk import word_tokeni...
293
from __future__ import annotations import numpy as np def A__ ( SCREAMING_SNAKE_CASE__) -> List[str]: return np.maximum(0 , SCREAMING_SNAKE_CASE__) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
293
1
import fire from utils import calculate_rouge, save_json def SCREAMING_SNAKE_CASE__ ( __a , __a , __a=None , **__a ): snake_case_ : Optional[Any] = [x.strip() for x in open(__a ).readlines()] snake_case_ : str = [x.strip(...
327
from collections import namedtuple import requests from lxml import html # type: ignore _SCREAMING_SNAKE_CASE = namedtuple("""covid_data""", """cases deaths recovered""") def SCREAMING_SNAKE_CASE__ ( __a = "https://www.worldometers.info/coronavirus/" ): snake_case_ ...
327
1
import os from argparse import ArgumentParser, Namespace from ..data import SingleSentenceClassificationProcessor as Processor from ..pipelines import TextClassificationPipeline from ..utils import is_tf_available, is_torch_available, logging from . import BaseTransformersCLICommand if not is_tf_available() and n...
353
from __future__ import annotations def UpperCamelCase_( lowerCamelCase_ ) -> int: _lowercase : Union[str, Any] = len(lowerCamelCase_ ) // 2 # choose the middle 3 elements _lowercase : Any = lst[m - 1 : m + 2] # if middle element is peak if three[1] >...
84
0
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : int , UpperCAmelCase_ : list ): _enforce_args(UpperCAmelCase_ , UpperCAmelCase_ ) if n == 0: return 0 A__ = float("""-inf""" ) for i in range(1 , n + 1 ): ...
335
"""simple docstring""" from collections import defaultdict from pathlib import Path import pandas as pd from rouge_cli import calculate_rouge_path from utils import calculate_rouge SCREAMING_SNAKE_CASE_ : int = [ 'Prosecutor: "No videos were used in the crash investigation" ...
335
1
import argparse import math import traceback import dateutil.parser as date_parser import requests def snake_case (__lowercase ) -> Tuple: '''simple docstring''' _snake_case : Any = {} _snake_case : Union[str, Any] = job["started_at"] _snake_ca...
369
import shutil import tempfile import unittest from transformers import ClapFeatureExtractor, ClapProcessor, RobertaTokenizer, RobertaTokenizerFast from transformers.testing_utils import require_sentencepiece, require_torchaudio from .test_feature_extraction_clap import floats_list @require_torchaudio @require_sent...
284
0
"""simple docstring""" 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 impor...
172
"""simple docstring""" import logging import os import sys from pathlib import Path from unittest.mock import patch from parameterized import parameterized from run_eval import run_generate from run_eval_search import run_search from transformers.testing_utils import CaptureStdout, TestCasePlus, ...
25
0
import unittest import torch from diffusers import DDIMScheduler, DDPMScheduler, UNetaDModel from diffusers.training_utils import set_seed from diffusers.utils.testing_utils import slow _UpperCAmelCase : Tuple = False class lowerCAmelCase ( unittest.TestCase ): def A_...
45
from collections import Counter from pathlib import Path from typing import Optional, Tuple import yaml class lowerCAmelCase ( yaml.SafeLoader ): def A_ ( self : List[str] , UpperCAmelCase : Dict ) -> Optional[Any]: lowerCamelCase__ : List[A...
45
1
"""simple docstring""" import argparse import json import os import torch from torch import nn from transformers import NllbMoeConfig, NllbMoeModel from transformers.modeling_utils import dtype_byte_size from transformers.utils import WEIGHTS_INDEX_NAME, WEIGHTS_NAME def __A (_SCREAMING_SNAKE_CASE ) ...
293
"""simple docstring""" from __future__ import annotations __A = 1.6_021e-19 # units = C def __A (_SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , ) ->tuple[str, float]: """simple docstring""" if (conductivity, electron_conc, mobility).co...
293
1
import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import ModelTesterMixin, ids...
44
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ...
44
1
"""simple docstring""" import argparse from ...utils.dataclasses import ( ComputeEnvironment, DistributedType, DynamoBackend, PrecisionType, SageMakerDistributedType, ) from ..menu import BulletMenu A : Tuple = [ "EAGER", "AOT_EAGER", "INDUCTOR", "NVFUSER", ...
57
"""simple docstring""" import gc import unittest from diffusers import FlaxDPMSolverMultistepScheduler, FlaxStableDiffusionPipeline from diffusers.utils import is_flax_available, slow from diffusers.utils.testing_utils import require_flax if is_flax_available(): import jax import jax...
84
0
def lowerCAmelCase__ ( a__ = 100 ) ->int: '''simple docstring''' _UpperCamelCase = 0 _UpperCamelCase = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_ints**2 - sum_of_squares if __name__ == "__main__": print(...
357
import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto import CONFIG_MAPPING lowerCamelCase__ = logging.get_logger(__name__) lowerCamelCase__ = { '''ut/deta''': '''https://huggingface.co/ut/deta/resolve/main/config.json''', } class _UpperC...
63
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __a = { 'configuration_bridgetower': [ 'BRIDGETOWER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BridgeTowerConfig', 'Br...
145
import os import pickle import unittest from transformers import AutoTokenizer from transformers.models.bert.tokenization_bert import BertTokenizer from transformers.models.bert_japanese.tokenization_bert_japanese import ( VOCAB_FILES_NAMES, BertJapaneseTokenizer, CharacterTokenizer, JumanppToken...
284
0
import json import os from functools import lru_cache from typing import List, Optional, Tuple import regex as re from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE : List[Any] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE : ...
350
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available, is_vision_available, ) SCREAMING_SNAKE_CASE : List[Any] = {"configuration_deit": ["DEIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "DeiTConfig", "DeiTOnnxC...
84
0
"""simple docstring""" import argparse import requests import torch from PIL import Image from transformers import CLIPProcessor, GroupViTConfig, GroupViTModel def lowercase ( lowerCAmelCase__ : int ) -> Optional[int]: # vision encoder if "img_encoder.pos_embed" ...
45
"""simple docstring""" lowercase_ = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] lowercase_ = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5] lowercase_ = { 0: "Sunday", 1: "Monday", 2: "Tuesday", 3: "Wednesday", 4: "Thursday", 5: "Friday", 6: "Saturday", } d...
45
1
def __lowerCamelCase ( UpperCAmelCase_ : int = 100 ): """simple docstring""" a :List[Any] = 0 a :List[Any] = 0 for i in range(1 , n + 1 ): sum_of_squares += i**2 sum_of_ints += i return sum_of_int...
281
# 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 a...
281
1
"""simple docstring""" import argparse import json import os import torch from transformers import LukeConfig, LukeModel, LukeTokenizer, RobertaTokenizer from transformers.tokenization_utils_base import AddedToken @torch.no_grad() def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Any ,_l...
44
"""simple docstring""" def SCREAMING_SNAKE_CASE ( _lowerCamelCase : Any ) -> List[Any]: # noqa: E741 _lowerCAmelCase : Optional[int] = len(_lowerCamelCase ) _lowerCAmelCase : str = 0 _lowerCAmelCase : Any = [0] * n ...
44
1
"""simple docstring""" import json from typing import List, Optional, Tuple from tokenizers import pre_tokenizers, processors from ...tokenization_utils_base import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bart impo...
321
"""simple docstring""" import unittest from pathlib import Path from tempfile import NamedTemporaryFile, TemporaryDirectory from transformers import BertConfig, BertTokenizerFast, FeatureExtractionPipeline from transformers.convert_graph_to_onnx import ( convert, ensure_valid_input, generate_identif...
321
1
'''simple docstring''' import argparse import os import re import packaging.version _lowerCAmelCase = 'examples/' _lowerCAmelCase = { 'examples': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init'...
298
'''simple docstring''' from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available from ...utils import OptionalDependencyNotAvailable lowerCAmelCase_ : int = {'configuration_gpt_neox': ['GPT_NEOX_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GPT...
63
0
import numpy as np from PIL import Image def __A ( _lowercase , _lowercase , _lowercase ): '''simple docstring''' _A = np.array(_lowercase ) if arr.shape[0] != arr.shape[1]: raise ValueError('''The input array is not a square matrix''' ) ...
75
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import ( DiffusionPipeline, UnCLIP...
75
1