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
lowerCamelCase : Optional[Any] =0 # The first color of the flag. lowerCamelCase : List[Any] =1 # The second color of the flag. lowerCamelCase : Dict =2 # The third color of the flag. lowerCamelCase : Optional[Any] =(red, white, blue) def SCREAMING...
189
import functools def lowerCamelCase__ ( _A , _A ): '''simple docstring''' if not isinstance(_A , _A ) or not all(isinstance(_A , _A ) for day in days ): raise ValueError("The parameter days should be a list of integers" ) ...
187
0
import argparse import struct import unittest class snake_case__ : """simple docstring""" def __init__( self , __lowercase ) -> None: """simple docstring""" a__ : Any = data # Initialize hash values a__ ...
360
from __future__ import annotations import requests _lowercase : Dict =set( "approved_at_utc approved_by author_flair_background_color\nauthor_flair_css_class author_flair_richtext author_flair_template_id author_fullname\nauthor_premium can_mod_post category clicked content_categories crea...
266
0
import importlib.metadata from typing import Union from packaging.version import Version, parse from .constants import STR_OPERATION_TO_FUNC lowerCamelCase = parse(importlib.metadata.version('''torch''')) def UpperCAmelCase__ ( _A : Union[str, Version] , _A : str , _A...
188
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 DetrConfig, DetrForObjectDetection, DetrForSegmentation, DetrImageProcessor, ResNetConfig from transformers.utils import logging logging.set_...
188
1
from __future__ import absolute_import, division, print_function, unicode_literals from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers import RobertaConfig from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.rober...
357
from ...utils import is_torch_available, is_transformers_available if is_transformers_available() and is_torch_available(): from .pipeline_vq_diffusion import LearnedClassifierFreeSamplingEmbeddings, VQDiffusionPipeline
218
0
"""simple docstring""" import argparse import torch from transformers import GPTaConfig, GPTaModel, load_tf_weights_in_gpta from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def lowercase__ ( _UpperCAmelCase , _UpperCAmelCase , ...
255
"""simple docstring""" import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMInverseScheduler, DDIMSchedule...
255
1
"""simple docstring""" __UpperCamelCase : Optional[Any] = { '''meter''': '''m''', '''kilometer''': '''km''', '''megametre''': '''Mm''', '''gigametre''': '''Gm''', '''terametre''': '''Tm''', '''petametre''': '''Pm''', '''exametre''': '''Em''', '''zettametre''': '''Zm...
355
"""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, Dict, Iterable, Li...
74
0
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 __lowercase = '''.''' if __name__ == "__main__": __lowercase = os.path.join(REPO_PATH, '''utils/documentation_tests.txt''') __lowerca...
43
import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __a : str = logging.get_logger(__name__) __a : int = { """microsoft/wavlm-base""": """https://huggingface.co/microsoft/wavlm-base/resolve/main/config.json""", # See all W...
210
0
'''simple docstring''' from math import factorial def A__ ( UpperCAmelCase_ = 1_0_0 ): return sum(int(UpperCAmelCase_ ) for x in str(factorial(UpperCAmelCase_ ) ) ) if __name__ == "__main__": print(solution(int(input('Enter the Number: ').strip())))
236
'''simple docstring''' from __future__ import annotations import numpy as np def A__ ( UpperCAmelCase_ ): _UpperCamelCase , _UpperCamelCase : Optional[int] = np.shape(UpperCAmelCase_ ) if rows != columns: _UpperCamelCase : Union[str, Any] ...
236
1
"""simple docstring""" import unittest from transformers import MobileBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configurati...
96
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) a_ = { 'con...
249
0
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusi...
367
from __future__ import annotations def UpperCAmelCase_ ( _A ): '''simple docstring''' SCREAMING_SNAKE_CASE__ = len(_A ) // 2 # choose the middle 3 elements SCREAMING_SNAKE_CASE__ = lst[m - 1 : m + 2] # if middle element is peak if three[1] > three[...
218
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...
50
'''simple docstring''' import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecu...
120
0
'''simple docstring''' import contextlib import csv import json import os import sqlitea import tarfile import textwrap import zipfile import pyarrow as pa import pyarrow.parquet as pq import pytest import datasets import datasets.config @pytest.fixture(scope='session' ...
354
'''simple docstring''' import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('''9.1.0'''): lowercase__ : Dict = { '''linear''': PIL.Image.Resampling.BILINE...
190
0
"""simple docstring""" import os import time import pytest from datasets.utils.filelock import FileLock, Timeout def a__ ( SCREAMING_SNAKE_CASE : Optional[int] ): '''simple docstring''' lowerCAmelCase : List[Any] = FileLock(str(tmpdir / "foo.lock" ) ...
108
"""simple docstring""" from __future__ import annotations import math class SCREAMING_SNAKE_CASE__ : """simple docstring""" def __init__( self , snake_case__ ): """simple docstring""" lowerCAmelCase : Any = size ...
108
1
from __future__ import annotations from typing import Any class __a ( __UpperCamelCase ): pass class __a : def __init__( self , lowerCAmelCase__ ) -> None: '''simple docstring''' lowercase__: Any = data ...
288
from typing import Dict from transformers import EvalPrediction, HfArgumentParser, TrainingArguments, is_torch_available from transformers.testing_utils import ( TestCasePlus, execute_subprocess_async, get_torch_dist_unique_port, require_torch_multi_gpu, require_torch_neuroncore, ) ...
288
1
"""simple docstring""" import unittest from transformers import DebertaVaConfig, is_torch_available from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common ...
167
"""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...
167
1
'''simple docstring''' def lowerCAmelCase__ ( lowerCamelCase : list[list] ): _A : Optional[Any] = current_set.copy() for row_index, row in enumerate(lowerCamelCase ): _A : Any = row[0] for column_index, column in enu...
227
'''simple docstring''' import unittest import numpy as np import torch from torch import nn from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import KandinskyVaa...
227
1
"""simple docstring""" import json from typing import Iterator, List, Union from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers from tokenizers.implementations.base_tokenizer import BaseTokenizer from tokenizers.models import Unigram from tokenizers.p...
78
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionAttendAndExcitePipeline, UNetaDConditionModel, ) from diffusers.utils import load_...
228
0
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore lowercase_ = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" lowercase_ = [file for file in filepaths if file...
224
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 lowercase_ = logging.get_logger(__name__) def __lowerCAmelCase ( SCREAMING_SNAKE_CASE_ ): lowercase__ = r"\w+[.]\d+" low...
224
1
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 import ...
277
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 a_ :Optional[Any] = logging.getLogger(__n...
277
1
'''simple docstring''' from typing import Dict, List, Optional from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _A : str =logging.get_logger(__name__) _A : str ={ "nielsr/canine-s": 2_048, } ...
365
'''simple docstring''' from __future__ import annotations from typing import Any class _lowercase ( _lowercase ): pass class _lowercase : def __init__( self: Optional[int] , UpperCamelCase__: Any ): l...
129
0
import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor snake_case : List[str] = logging.get_logger(__name__) class snake_case_ (lowerCAmelCase_ ): def __init__( self :Tuple ,*__snake_case :Optional[int] ,*...
240
import argparse import os import re import packaging.version _A : Optional[int] = 'examples/' _A : str = { 'examples': (re.compile(r'^check_min_version\("[^"]+"\)\s*$', re.MULTILINE), 'check_min_version("VERSION")\n'), 'init': (re.compile(r'^__version__\s+=\s+"([^"]+)"\s*$', re.MULT...
142
0
"""simple docstring""" import inspect import unittest from transformers import DecisionTransformerConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ...
100
"""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 = logging.get_logger(__name__) _a ...
100
1
"""simple docstring""" import torch from diffusers import DDPMParallelScheduler from .test_schedulers import SchedulerCommonTest class A__ ( _lowerCamelCase): A_ : Dict = (DDPMParallelScheduler,) def __lowerCamelCase ( self , **_SCREAMING_SNAKE_CASE ):...
86
'''simple docstring''' import argparse import torch from transformers import ( EncodecConfig, EncodecFeatureExtractor, EncodecModel, logging, ) # checkpoints downloaded from: # https://dl.fbaipublicfiles.com/encodec/v0/encodec_24khz-d7cc33bc.th # https://huggingface.co/f...
4
0
from __future__ import annotations lowercase_ = 8.988E9 # units = N * m^s * C^-2 def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : Any = abs(chargea * chargea ) if ...
194
def UpperCamelCase__ ( SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): __lowerCamelCase : Union[str, Any] = len(SCREAMING_SNAKE_CASE__ ) __lowerCamelCase : Any = [[False] * (required_sum + 1) for _ in range(arr_len + 1 )] # for each arr value, a sum of ...
194
1
"""simple docstring""" import warnings from ...utils import logging from .image_processing_clip import CLIPImageProcessor _snake_case = logging.get_logger(__name__) class UpperCamelCase ( snake_case_ ): def __init__( self : Any ...
294
"""simple docstring""" def lowerCAmelCase__ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ , ): '''simple docstring''' _a : Optional[Any] = [redshift, radiation_density, matter_...
294
1
"""simple docstring""" from __future__ import annotations from fractions import Fraction def lowerCAmelCase__ ( _UpperCamelCase : int , _UpperCamelCase : int ) -> bool: """simple docstring""" return ( num != den and num % 1_0...
362
"""simple docstring""" import argparse import math import traceback import dateutil.parser as date_parser import requests def lowerCAmelCase__ ( _UpperCamelCase : Any ) -> int: """simple docstring""" snake_case = {} snake_...
149
0
'''simple docstring''' __lowerCAmelCase = ''' # 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/hu...
89
"""simple docstring""" from typing import List, Optional, Tuple, Union import PIL import torch from torchvision import transforms from diffusers.pipeline_utils import DiffusionPipeline, ImagePipelineOutput from diffusers.schedulers import DDIMScheduler from diffusers.utils import randn_tensor lowercase__ ...
290
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 if is_sentencepie...
262
from math import cos, sin, sqrt, tau from audio_filters.iir_filter import IIRFilter def _lowercase ( _UpperCAmelCase , _UpperCAmelCase , _UpperCAmelCase = 1 / sqrt(2 ) ) -> IIRFilter: lowerCamelCase =tau * frequency / samplerate lowerCamelCase =sin(_UpperCAmelCase ) ...
262
1
"""simple docstring""" from bisect import bisect from itertools import accumulate def _snake_case ( lowerCamelCase__ : str , lowerCamelCase__ : Any , lowerCamelCase__ : int , lowerCamelCase__ : Union[str, Any] ) -> Optional[Any]: lowerCamelCase_ : ...
144
def __snake_case ( __UpperCamelCase : bytes ): """simple docstring""" return "".join([hex(__UpperCamelCase )[2:].zfill(2 ).upper() for byte in list(__UpperCamelCase )] ) def __snake_case ( __UpperCamelCase : str ): """simple docstring""" ...
312
0
from __future__ import annotations import requests def a( A : str ) -> dict: """simple docstring""" a = f'''https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty''' return requests.get(A ).json() def a( A : int = 10 ) -> list[dict]: ...
71
import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available, logging from .benchm...
71
1
"""simple docstring""" from math import factorial def _snake_case ( lowercase__ = 100 ): return sum(int(lowercase__ ) for x in str(factorial(lowercase__ ) ) ) if __name__ == "__main__": print(solution(int(input("""Enter the Number: """).strip())))
96
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available lowerCAmelCase_ = { 'configuration_mask2former': [ 'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'Mask2FormerConfig', ], } tr...
308
0
'''simple docstring''' from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class UpperCAmelCase_ ( __a ): ...
368
'''simple docstring''' import tempfile import unittest from transformers import AutoModelForSeqaSeqLM, AutoTokenizer from transformers.testing_utils import ( is_torch_available, require_optimum, require_torch, slow, ) if is_torch_available(): import torch @require_torch @requir...
43
0
"""simple docstring""" from math import pi def UpperCAmelCase__ (snake_case__ : int , snake_case__ : int ): """simple docstring""" return 2 * pi * radius * (angle / 3_60) if __name__ == "__main__": print(arc_length(90, 10))
64
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 = [] ...
10
0
from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent _snake_case = {"UserAgent": UserAgent().random} def lowerCAmelCase_ ( snake_case_ ): _A : Tuple = script.contents[0] _A ...
370
import argparse import json import math import os import time import traceback import zipfile from collections import Counter import requests def lowerCAmelCase_ ( snake_case_,snake_case_=None ): _A : Any = None if token is not None: _A : ...
343
0
"""simple docstring""" import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem __UpperCamelCase = importlib.util.find_spec('''s3fs''') is not None ...
113
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available SCREAMING_SNAKE_CASE__ = {"configuration_focalnet": ["FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "FocalNetConfig"]} try: ...
46
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase : Dict = logging.get_logger(__name__) lowerCAmelCase : Optional[Any] = { """facebook/s2t-small-librispeech-asr""": ( """https://huggingface.co/facebook...
356
import re from typing import Callable, List, Optional, Union import tensorflow as tf try: from tensorflow.keras.optimizers.legacy import Adam except ImportError: from tensorflow.keras.optimizers import Adam class __lowercase ( tf.keras.optimizers.schedules.LearningRateSchedule ): "...
127
0
import argparse import json import os import numpy as np import PIL import requests import tensorflow.keras.applications.efficientnet as efficientnet import torch from huggingface_hub import hf_hub_download from PIL import Image from tensorflow.keras.preprocessing import image from transformers import ( Effic...
227
import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import ConfusionMatrixDisplay from sklearn.model_selection import train_test_split from xgboost import XGBClassifier def a( A : dict ) -> tuple: """simple doc...
227
1
'''simple docstring''' import warnings from diffusers import StableDiffusionImgaImgPipeline # noqa F401 warnings.warn( 'The `image_to_image.py` script is outdated. Please use directly `from diffusers import' ' StableDiffusionImg2ImgPipeline` instead.' )
270
'''simple docstring''' from math import sqrt def __SCREAMING_SNAKE_CASE ( _SCREAMING_SNAKE_CASE ): _snake_case = 0 for i in range(1 , int(sqrt(_SCREAMING_SNAKE_CASE ) + 1 ) ): if n % i == 0 and i != sqrt(_SCREAMING_SNAKE_CASE ): to...
270
1
"""simple docstring""" import json import os import unittest from transformers.models.blenderbot_small.tokenization_blenderbot_small import ( VOCAB_FILES_NAMES, BlenderbotSmallTokenizer, ) from ...test_tokenization_common import TokenizerTesterMixin class __snake_case ( _lowercase...
72
import gc import random import unittest import numpy as np import torch from diffusers import ( DDIMScheduler, KandinskyVaaControlnetPipeline, KandinskyVaaPriorPipeline, UNetaDConditionModel, VQModel, ) from diffusers.utils import floats_tensor, load_image, load_numpy, slow, torch_device from ...
116
0
"""simple docstring""" import math from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import SchedulerMixin, SchedulerOutput class lowerCamelCase__ ( SCREAMING_SNAKE_C...
77
"""simple docstring""" from typing import List, Union from ..utils import ( add_end_docstrings, is_tf_available, is_torch_available, is_vision_available, logging, requires_backends, ) from .base import PIPELINE_INIT_ARGS, Pipeline if is_vision_available(): from PIL im...
77
1
import random import timeit from functools import wraps from typing import Callable, Optional from ..configuration_utils import PretrainedConfig from ..models.auto.modeling_tf_auto import TF_MODEL_MAPPING, TF_MODEL_WITH_LM_HEAD_MAPPING from ..utils import is_pyanvml_available, is_tf_available, logging from .benc...
142
import warnings from ...utils import logging from .image_processing_segformer import SegformerImageProcessor _A : str = logging.get_logger(__name__) class __SCREAMING_SNAKE_CASE ( lowerCAmelCase_ ): def __init__( self : Dict , *A : Any , **A : List[...
142
1
import importlib import shutil import threading import warnings from typing import List import fsspec import fsspec.asyn from . import compression from .hffilesystem import HfFileSystem __lowerCAmelCase = importlib.util.find_spec('''s3fs''') is not None if _has_safs: from .safilesystem imp...
364
import warnings from typing import Any, Dict, List, Optional, Union import numpy as np from ...audio_utils import mel_filter_bank, optimal_fft_length, spectrogram, window_function from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeatur...
288
0
import re import tempfile from pathlib import Path import pytest import yaml from datasets.utils.readme import ReadMe # @pytest.fixture # def example_yaml_structure(): lowercase__ =yaml.safe_load( '\\nname: ""\nallow_empty: false\nallow_empty_text: true\nsubsections:\n - name: "Dataset Card for X" # Fi...
216
import unittest from transformers import AlbertTokenizer, AlbertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin _a = get_tests_dir('''fixtures/spiece.model'''...
39
0
'''simple docstring''' snake_case_ : dict[str, float] = { "km/h": 1.0, "m/s": 3.6, "mph": 1.60_93_44, "knot": 1.8_52, } snake_case_ : dict[str, float] = { "km/h": 1.0, "m/s": 0.2_77_77_77_78, "mph": 0.6_21_37_11_92, "knot": 0.5_39_95_68_03, } def A__ ( ...
236
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class lowercase__ ( lowercase ): @staticmethod @abstractmethod def UpperCamelCase_ ( lowerCamelCase__ : ArgumentParser ): '''simple docstring''' raise...
236
1
"""simple docstring""" import argparse import json import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import AutoImageProcessor, SwinConfig, SwinForImageClassification def _snake_case ( l...
96
"""simple docstring""" 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) lowercase__ = logging.getLogg...
96
1
'''simple docstring''' from __future__ import annotations import inspect import unittest import numpy as np from transformers import ResNetConfig from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import cached_property, is_tf_available, is_vision_available from ...t...
18
'''simple docstring''' import logging import os import sys from dataclasses import dataclass, field from typing import Optional import evaluate import numpy as np import torch from datasets import load_dataset from PIL import Image from torchvision.transforms import ( CenterCrop, Compose, Normalize, ...
18
1
'''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 import logging l...
265
'''simple docstring''' import inspect from typing import Callable, List, Optional, Union import torch from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer from diffusers import DiffusionPipeline from diffusers.models import AutoencoderKL, UNetaDConditionModel from diffusers.pipelines.stab...
265
1
def lowerCamelCase_ ( _a : List[str] ): '''simple docstring''' UpperCAmelCase_ : Optional[Any] = len(_a ) while cur > 1: # Find the maximum number in arr UpperCAmelCase_ : Tuple = arr.index(max(arr[0:cur] ) ) # R...
368
from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging UpperCamelCase_ = logging.get_logger(__name__) UpperCamelCase_ = { '''junnyu/roformer_chinese_small''': '''https://...
59
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging __SCREAMING_SNAKE_CASE :Optional[Any] = logging.get_logger(__name...
22
from __future__ import annotations def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ ): snake_case_ = len(SCREAMING_SNAKE_CASE__ ) # We need to create solution object to save path. snake_case_ = [[0 for _ in range(SCREAMING_SNAKE_CASE__ )] for _ in range(SCREAM...
8
0
'''simple docstring''' def a__ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , ) -> float: UpperCAmelCase__ : Tuple = [redshift, radiation_density, matter_density, dark_energy] if any(p < 0 for p in parameters ): ...
299
'''simple docstring''' from collections.abc import Iterable from typing import Any class lowerCamelCase_ : def __init__( self : List[Any] , _A : int | None = None ): '''simple docstring''' UpperCAmelCase__ : List[A...
299
1
import math def A_ ( snake_case : Any ) -> int: '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even numbers, all m...
328
from __future__ import annotations from collections.abc import Callable from typing import Generic, TypeVar A__ = TypeVar("""T""") A__ = TypeVar("""U""") class __lowerCAmelCase ( Generic[T, U] ): def __init__( self , _snake_case , _snake_ca...
82
0
import unittest import numpy as np import torch from diffusers import VersatileDiffusionImageVariationPipeline from diffusers.utils.testing_utils import load_image, require_torch_gpu, slow, torch_device __snake_case :Any = False class _A ( unittest.TestCase ): pass @slow @requir...
131
from __future__ import annotations import collections import tempfile import unittest import numpy as np from transformers.testing_utils import require_tf, require_vision, slow from transformers.utils import is_tf_available, is_vision_available from ...test_modeling_tf_common import floats_tensor, ids_tensor, r...
131
1
"""simple docstring""" import math import tensorflow as tf from packaging import version def a_ ( _lowerCAmelCase : Dict ): '''simple docstring''' lowercase__ : int = tf.convert_to_tensor(_lowerCAmelCase ) lowercase__ : List[str] = 0.5 * (1.0...
77
"""simple docstring""" _UpperCamelCase : Union[str, Any] = 8.3_1_4_4_5_9_8 def a_ ( _lowerCAmelCase : float , _lowerCAmelCase : float ): '''simple docstring''' if temperature < 0: raise Exception('Temperature cannot be less than 0 K' ) ...
77
1
"""simple docstring""" from typing import List, Optional, Union import torch from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDPMScheduler from ...utils import ( i...
40
"""simple docstring""" from timeit import timeit UpperCAmelCase__ = { 'MALAYALAM': True, 'String': False, 'rotor': True, 'level': True, 'A': True, 'BB': True, 'ABC': False, 'amanaplanacanalpanama': True, # "a man a plan a canal panama" } # Ensure our test d...
40
1
import argparse import json import os import re import torch from transformers import BloomConfig, BloomModel from transformers.file_utils import CONFIG_NAME, WEIGHTS_NAME from transformers.utils import logging logging.set_verbosity_info() __UpperCamelCase : Dict = [ ...
228
import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixi...
228
1
from __future__ import annotations import unittest from transformers import XGLMConfig, XGLMTokenizer, is_tf_available from transformers.testing_utils import require_tf, slow from ...test_configuration_common import ConfigTester from ...test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tens...
273
from ..utils import DummyObject, requires_backends class _SCREAMING_SNAKE_CASE ( metaclass=__SCREAMING_SNAKE_CASE ): '''simple docstring''' lowercase_ = ["torch", "torchsde"] def __init__(self : Union[str, Any] , *UpperCAmelCase_ : Dict , **UpperCAmelCas...
273
1
'''simple docstring''' def __magic_name__( lowerCamelCase, lowerCamelCase): if a < 0 or b < 0: raise ValueError('''the value of both inputs must be positive''') __lowerCAmelCase = str(bin(a__))[2:] # remove the leading "0b" __lowerCAmelCase = str...
174
# flake8: noqa # Lint as: python3 A : Optional[Any] = [ 'VerificationMode', 'Version', 'disable_progress_bar', 'enable_progress_bar', 'is_progress_bar_enabled', 'experimental', ] from .info_utils import VerificationMode from .logging import disable_progress_bar, enable_progress_bar, is_...
6
0
'''simple docstring''' import argparse from diffusers.pipelines.stable_diffusion.convert_from_ckpt import download_controlnet_from_original_ckpt if __name__ == "__main__": __UpperCamelCase = argparse.ArgumentParser() parser.add_argument( "--checkpoint_path", default=No...
361
'''simple docstring''' import os import numpy import onnx def _a ( _lowerCamelCase , _lowerCamelCase ) -> Any: """simple docstring""" __snake_case : Optional[int] = a.name __snake_case : Dict = ...
13
0
'''simple docstring''' import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel _SCREAMING_SNAKE_CASE = False _SCREAMING_SNAKE_CASE = True _SCREAMING_SNAKE_CASE = False ...
158
"""simple docstring""" from ..utils import DummyObject, requires_backends class SCREAMING_SNAKE_CASE ( metaclass=a_ ): """simple docstring""" lowercase__ = ["speech"] def __init__( self : Tuple ,*lowercase_ : Tuple ,**lowercase_ ...
106
0
"""simple docstring""" import shutil import tempfile import unittest import numpy as np import pytest from transformers.testing_utils import require_vision from transformers.utils import is_vision_available if is_vision_available(): from PIL import Image from transfor...
357
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices lowercase__ : Optional[int] = logging.get_logger(__name__) ...
289
0
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..auto.configuration_auto import CONFIG_MAPPING _UpperCamelCase: List[str] = logging.get_logger(__name__) class a__ ( SCREAMING_SNAKE_CASE__ ...
255
"""simple docstring""" from __future__ import annotations import unittest from transformers import is_tf_available from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow if is_tf_available(): import tensorflow as tf from transformers...
255
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_sentencepiece_available, is_tf_available, is_tokenizers_available, is_torch_available, ) A_ = { '''con...
351
"""simple docstring""" from collections.abc import Generator from math import sin def UpperCAmelCase__ (snake_case__ : bytes ): """simple docstring""" if len(snake_case__ ) != 32: raise ValueError("""Input must be of length 32""" ) _snake_case : Optional[int] ...
132
0
import os import pytest from datasets import ( get_dataset_config_info, get_dataset_config_names, get_dataset_infos, get_dataset_split_names, inspect_dataset, inspect_metric, ) _lowercase: Dict = pytest.mark.integration @pytest.mark.parametrize("path" , ["paws", "csv"]...
227
_lowercase: Dict = [ (1000, "M"), (900, "CM"), (500, "D"), (400, "CD"), (100, "C"), (90, "XC"), (50, "L"), (40, "XL"), (10, "X"), (9, "IX"), (5, "V"), (4, "IV"), (1, "I"), ] def a( A : str ) -> int: """simple docs...
227
1
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 if is_se...
329
from __future__ import annotations def __snake_case ( __UpperCamelCase : int = 4 ): """simple docstring""" A_ = abs(__UpperCamelCase ) or 4 return [[1 + x + y * row_size for x in range(__UpperCamelCase )] for y in range(__UpperCamelCase )] def ...
329
1
import argparse import json from dataclasses import dataclass, field from functools import partial from pathlib import Path from typing import Callable, Dict, List, Tuple import timm import torch import torch.nn as nn from classy_vision.models.regnet import RegNet, RegNetParams, RegNetYaagf, RegNetYaagf, RegNetYaa...
302
from __future__ import annotations import typing from collections.abc import Iterable import numpy as np a : Dict = typing.Union[Iterable[float], Iterable[int], np.ndarray] # noqa: UP007 a : Any = typing.Union[np.floataa, int, float] # noqa: UP007 def ...
114
0
import gc import random import tempfile import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, ControlNetModel, DDIMScheduler, StableDiffusionControlNetImgaImgPipeline, U...
368
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_CAUSAL_LM_MAPPING, TextGenerationPipeline, logging, pipeline, ) from transformers.testing_utils import ( CaptureLogger, is_pipeline_test, require_accelerate, require_tf, ...
155
0
def UpperCamelCase ( __lowerCamelCase : int ): snake_case : Tuple = [] if len(_lowerCAmelCase ) == 1: return [nums.copy()] for _ in range(len(_lowerCAmelCase ) ): snake_case : int = nums.pop(0 ) ...
59
from typing import Any, Dict, Optional import torch import torch.nn.functional as F from torch import nn from ..utils import maybe_allow_in_graph from .activations import get_activation from .attention_processor import Attention from .embeddings import CombinedTimestepLabelEmbeddings @maybe_allow_in_graph c...
116
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available lowercase = {} try: if not is_sentencepiece_available(): raise OptionalDependencyNotAvailable() except OptionalDependencyNotAvailable: pass else: lowe...
361
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowercase = { """configuration_nezha""": ["""NEZHA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """NezhaConfig"""], } try: if not is_torch_available(): ...
35
0
'''simple docstring''' import inspect from typing import Optional, Union import numpy as np import PIL import torch from torch.nn import functional as F from torchvision import transforms from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer from diffusers import ( ...
55
'''simple docstring''' import math def __snake_case ( UpperCAmelCase_ : float , UpperCAmelCase_ : float ): return math.pow(UpperCAmelCase_ , 2 ) - a def __snake_case ( UpperCAmelCase_ : float ): return 2 * x d...
55
1
def _lowerCamelCase( lowercase__ , lowercase__ ) -> str: '''simple docstring''' __lowercase= 0 __lowercase= len(lowercase__ ) - 1 while left <= right: # avoid divided by 0 during interpolation if sorted_collection[left] == sorted_collection[right]: ...
304
def _lowerCamelCase( lowercase__ = 1_0_0_0 ) -> int: '''simple docstring''' __lowercase= 2**power __lowercase= str(lowercase__ ) __lowercase= list(lowercase__ ) __lowercase= 0 for i in list_num: sum_of_num += int(lowercase__ ) return sum_o...
304
1
"""simple docstring""" import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home _a = HUGGINGFACE_HUB_CACHE _a = 'config.json' _a = 'diffusion_pytorch_model.bin' _a = 'diffusion_flax_model.msgpack' _a = 'model.on...
61
"""simple docstring""" def _snake_case ( lowerCamelCase__ : str ) -> str: if not all(char in "01" for char in bin_string ): raise ValueError("Non-binary value was passed to the function" ) if not bin_string: raise ValueError("Empty string was passed t...
144
0
"""simple docstring""" def lowerCamelCase_ (UpperCamelCase__ : int , UpperCamelCase__ : int , UpperCamelCase__ : int ): _UpperCAmelCase : Optional[Any] = (num_of_terms / 2) * (2 * first_term + (num_of_terms - 1) * common_diff) # formula for sum of series re...
350
"""simple docstring""" import os import unittest from transformers.models.transfo_xl.tokenization_transfo_xl import VOCAB_FILES_NAMES, TransfoXLTokenizer from ...test_tokenization_common import TokenizerTesterMixin class _UpperCAmelCase ( a ,unittest.TestCase ): '''simple docstring'''...
68
0
'''simple docstring''' from ..utils import DummyObject, requires_backends class _a ( metaclass=__snake_case ): __a : Tuple = ["flax"] def __init__( self : str , *lowercase : int , **lowercase : List[str] ): '''simple docstring'''...
34
import flax.linen as nn import jax.numpy as jnp from .attention_flax import FlaxTransformeraDModel from .resnet_flax import FlaxDownsampleaD, FlaxResnetBlockaD, FlaxUpsampleaD class _snake_case ( nn.Module ): '''simple docstring''' A__ : int A__ : int A__ : ...
345
0
'''simple docstring''' from random import randint, random def _lowerCamelCase ( lowercase : int , lowercase : int , lowercase : int , lowercase : bool = False , lowercase : bool = False , lowercase : int =...
346
'''simple docstring''' import argparse import logging import os import sys import numpy as np import onnxruntime import torch from bart_onnx.generation_onnx import BARTBeamSearchGenerator from bart_onnx.reduce_onnx_size import remove_dup_initializers import transformers from transformers import BartForCo...
346
1
'''simple docstring''' import random from typing import Any def a__ ( a__ ): """simple docstring""" for _ in range(len(a__ ) ): __SCREAMING_SNAKE_CASE = random.randint(0 , len(a__ ) - 1 ) __SCREAMING_SNAKE_CASE = ...
267
'''simple docstring''' from itertools import count def a__ ( a__ = 50 ): """simple docstring""" __SCREAMING_SNAKE_CASE = [1] * min_block_length for n in count(a__ ): fill_count_functions.append(1 ) for block_length in range(a__ ...
267
1
'''simple docstring''' import copy from ...configuration_utils import PretrainedConfig from ...utils import logging from ..bit import BitConfig __lowercase: List[Any] = logging.get_logger(__name__) __lowercase: str = { '''Intel/dpt-large''': '''https://huggingface....
357
'''simple docstring''' import json import os import unittest from transformers import CLIPTokenizer, CLIPTokenizerFast from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES from transformers.testing_utils import require_ftfy, require_tokenizers from ...test_tokenization_common impo...
31
0
'''simple docstring''' import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, S...
344
'''simple docstring''' from functools import lru_cache def UpperCAmelCase__ ( UpperCAmelCase__ ) -> set: A_ = 2 A_ = set() while i * i <= n: if n % i: i += 1 else: n //= i ...
162
0
import argparse import torch from transformers import OpenAIGPTConfig, OpenAIGPTModel, load_tf_weights_in_openai_gpt from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging logging.set_verbosity_info() def __lowerCamelCase ( __magic_name__ : List[str] , __magic_name__ : Any ...
42
def __lowerCamelCase ( __magic_name__ : int ): if not isinstance(__magic_name__ , __magic_name__ ): a__: List[str] =F"Input value of [number={number}] must be an integer" raise TypeError(__magic_name__ ) if number < 1: a__: ...
42
1
'''simple docstring''' import multiprocessing import os from typing import BinaryIO, Optional, Union import fsspec from .. import Dataset, Features, NamedSplit, config from ..formatting import query_table from ..packaged_modules.json.json import Json from ..utils import logging from ..utils.typing import Nest...
271
'''simple docstring''' import os from huggingface_hub.constants import HUGGINGFACE_HUB_CACHE, hf_cache_home __lowerCAmelCase = HUGGINGFACE_HUB_CACHE __lowerCAmelCase = """config.json""" __lowerCAmelCase = """diffusion_pytorch_model.bin""" __lowerCAmelCase = """di...
271
1
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase :Dict = logging.get_logger(__name__) lowerCAmelCase :str = { '''asapp/sew-d-tiny-100k''': '''https://huggingface.co/asapp/sew-...
275
'''simple docstring''' lowerCAmelCase :Union[str, Any] = ''' # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers...
275
1
"""simple docstring""" import argparse import os import re import packaging.version __A : List[str] = '''examples/''' __A : int = { '''examples''': (re.compile(R'''^check_min_version\("[^"]+"\)\s*$''', re.MULTILINE), '''check_min_version("VERSION")\n'''), ...
33
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = { """configuration_electra""": ["""ELECTRA_PRETRAINED_CONFIG_ARCHIVE_MAP"...
303
0
import pickle import numpy as np from matplotlib import pyplot as plt class _snake_case : '''simple docstring''' def __init__( self: str ,lowerCamelCase_: Optional[Any] ,lowerCamelCase_: Tuple ,lowerCamelCase_: Tuple ,lowerCamelCase_:...
59
import math import os from copy import deepcopy import datasets import evaluate import torch import transformers from datasets import load_dataset from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer from accelerate import Accelerator from accelerate.t...
59
1
"""simple docstring""" import unittest import numpy as np import torch from diffusers import KarrasVePipeline, KarrasVeScheduler, UNetaDModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class _lowerCamelCase (...
153
"""simple docstring""" import time from dataclasses import dataclass from multiprocessing import Pool from unittest import TestCase from unittest.mock import patch import multiprocess import numpy as np import pytest from datasets.utils.py_utils import ( NestedDataStructure, asdict, iflatmap_un...
153
1
"""simple docstring""" import math from typing import Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import randn_tensor from .scheduling_utils import SchedulerMixin class SCREAMING_SNAKE_CASE_ ( __a , __a ): """simple docstring""" ...
359
"""simple docstring""" import pickle import shutil import tempfile import unittest from transformers import SPIECE_UNDERLINE, XGLMTokenizer, XGLMTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import cached_property from...
255
0
'''simple docstring''' from __future__ import annotations class lowercase_ : """simple docstring""" def __init__( self : Optional[int] ,lowercase__ : str ,lowercase__ : str ): __lowercase , __lowercase = text, pattern __lowercase , __lowercas...
104
'''simple docstring''' SCREAMING_SNAKE_CASE__ = 8.31_44_62 # Unit - J mol-1 K-1 def lowercase__ ( __UpperCamelCase , __UpperCamelCase , __UpperCamelCase )-> float: if moles < 0 or kelvin < 0 or volume < 0: raise ValueError("""Invalid in...
321
0
from dataclasses import dataclass from typing import Optional import numpy as np import torch import torch.nn as nn from ..utils import BaseOutput, is_torch_version, randn_tensor from .attention_processor import SpatialNorm from .unet_ad_blocks import UNetMidBlockaD, get_down_block, get_up_block @dataclass class ...
134
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
1
from math import factorial def __snake_case ( _lowerCAmelCase : int = 100 ) -> int: return sum(int(_lowerCAmelCase ) for x in str(factorial(_lowerCAmelCase ) ) ) if __name__ == "__main__": print(solution(int(input('''Enter the Number: ''').strip())))
300
from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def __snake_case ( _lowerCAmelCase : str , _lowerCAmelCase : float | Decimal , _lowerCAmelCase : float = 10**-10 ) -> float: A_ : Dict ...
300
1
# using dfs for finding eulerian path traversal def lowerCAmelCase__ ( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_=None ) -> Any: lowerCAmelCase__ : int = (path or []) + [u] for v in graph[u]: if visi...
307
import gc import unittest import numpy as np import torch from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNetaDModel from diffusers.utils import slow, torch_device from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps from ..pipeline_params import U...
307
1
'''simple docstring''' def lowerCAmelCase_ ( snake_case_ : float ) -> float: '''simple docstring''' return 10 - x * x def lowerCAmelCase_ ( snake_case_ : float , snake_case_ : float ) -> float: '''simple docstring''' ...
1
'''simple docstring''' from copy import deepcopy import torch import torch.nn.functional as F from torch.optim import AdamW from torch.optim.lr_scheduler import LambdaLR from torch.utils.data import DataLoader from accelerate.accelerator import Accelerator from accelerate.state import GradientState from accelera...
1
1
import datasets from .evaluate import evaluate UpperCamelCase = '\\n@article{hendrycks2021cuad,\n title={CUAD: An Expert-Annotated NLP Dataset for Legal Contract Review},\n author={Dan Hendrycks and Collin Burns and Anya Chen and Spencer Ball},\n journal={arXiv preprint arXiv...
221
import os import tempfile import unittest from pathlib import Path from transformers import AutoConfig, is_torch_available from transformers.testing_utils import require_torch, torch_device if is_torch_available(): from transformers import PyTorchBenchmark, PyTorchBenchmarkArguments ...
221
1
from typing import List from .keymap import KEYMAP, get_character def lowercase ( SCREAMING_SNAKE_CASE__ : str ) -> List[Any]: def decorator(SCREAMING_SNAKE_CASE__ : Optional[int] ): _snake_case : List[Any] = getattr(snake_case__ , """handle_key""" , ...
317
"""simple docstring""" import os import zipfile import requests from get_ci_error_statistics import download_artifact, get_artifacts_links def UpperCAmelCase__ (snake_case__ : Optional[int] , snake_case__ : Any=7 ): """simple docstring""" _snake_case...
64
0
'''simple docstring''' from math import factorial def SCREAMING_SNAKE_CASE__ ( __A = 100 ) -> Optional[int]: return sum(int(__A ) for x in str(factorial(__A ) ) ) if __name__ == "__main__": print(solution(int(input("Enter the Number: ").strip())))
359
'''simple docstring''' import hashlib import unittest from typing import Dict import numpy as np from transformers import ( MODEL_FOR_MASK_GENERATION_MAPPING, TF_MODEL_FOR_MASK_GENERATION_MAPPING, is_vision_available, pipeline, ) from transformers.pipelines import MaskGenerationPipeline from t...
160
0
"""simple docstring""" import datasets _lowercase = '''\ @InProceedings{conneau2018xnli, author = "Conneau, Alexis and Rinott, Ruty and Lample, Guillaume and Williams, Adina and Bowman, Samuel R. and Schwenk, Holger ...
74
import os import sys import warnings from dataclasses import dataclass, field from io import BytesIO from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import numpy as np import pyarrow as pa from .. import config from ..download.streaming_download_manager import xopen from ..table impor...
119
0
def UpperCamelCase ( _A ): """simple docstring""" return "".join([hex(_A )[2:].zfill(2 ).upper() for byte in list(_A )] ) def UpperCamelCase ( _A ): """simple docstring""" if (len(_A ) % 2) != 0: raise ValueError( ...
138
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 ) __magic_n...
138
1
"""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 ...
25
"""simple docstring""" def lowercase_ ( _snake_case ): if a < 0: raise ValueError("""Input value must be a positive integer""" ) elif isinstance(_snake_case ,_snake_case ): raise TypeError("""Input value must be a 'int' type""" ) ...
25
1
def _lowerCAmelCase ( __lowerCAmelCase ) -> Dict: """simple docstring""" if not numbers: return 0 if not isinstance(UpperCamelCase__ , (list, tuple) ) or not all( isinstance(UpperCamelCase__ , UpperCamelCase__ ) for number in numbers ): raise Value...
351
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.''' )
44
0
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a_ = { """configuration_poolformer""": [ """POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """PoolFormerConfig""", """...
179
"""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 ...
179
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available, ) _SCREAMING_SNAKE_CASE = {"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP"...
354
'''simple docstring''' from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _SCREAMING_SNAKE_CASE = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Fo...
217
0
"""simple docstring""" import string def lowercase ( lowerCAmelCase__ : List[str] ) -> int: for key in range(len(string.ascii_uppercase ) ): __a = "" for symbol in message: if symbol in string.ascii_uppercase: __a ...
45
'''simple docstring''' def lowercase ( __magic_name__ ): '''simple docstring''' if number < 0: raise ValueError("number must not be negative" ) return number & (number - 1) == 0 if __name__ == "__main__": import doctest doctest.testmod()
311
0
"""simple docstring""" import os import pytest from attr import dataclass _lowercase : int = 'us-east-1' # defaults region @dataclass class _UpperCAmelCase : a__ : str a__ : Optional[Any] = "arn:aws:iam::558105141721:role/sagemaker_execution_role" ...
86
"""simple docstring""" import collections import inspect import unittest from typing import Dict, List, Tuple from transformers import MaskFormerSwinConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device from transformers.utils import is_torch_available ...
86
1