code
stringlengths
82
53.2k
code_codestyle
int64
0
721
style_context
stringlengths
91
41.9k
style_context_codestyle
int64
0
699
label
int64
0
1
"""simple docstring""" import inspect from typing import Callable, List, Optional, Union import torch from transformers import ( CLIPImageProcessor, CLIPTextModel, CLIPTokenizer, WhisperForConditionalGeneration, WhisperProcessor, ) from diffusers import ( AutoencoderKL, DDIMSch...
34
"""simple docstring""" # tests directory-specific settings - this file is run automatically # by pytest before any tests are run import sys import warnings from os.path import abspath, dirname, join # allow having multiple repository checkouts and not needing to remember to rerun # 'pip install -e .[dev]...
34
1
import os from pathlib import Path from unittest.mock import patch import pytest import zstandard as zstd from datasets.download.download_config import DownloadConfig from datasets.utils.file_utils import ( OfflineModeIsEnabled, cached_path, fsspec_get, fsspec_head, ftp_get, ftp_head, ge...
467
def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: str , lowerCAmelCase: str ) -> int: if len(lowerCAmelCase ) != len(lowerCAmelCase ): raise ValueError("String lengths must match!" ) _UpperCAmelCase : List[Any] = 0 for chara, chara in zip(lowerCAmelCase , ...
467
1
# 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...
6
"""simple docstring""" from __future__ import annotations def A ( snake_case__ ): '''simple docstring''' for i in range(1 , len(matrix[0] ) ): matrix[0][i] += matrix[0][i - 1] # preprocessing the first column for i in range(1 , len(...
196
0
"""simple docstring""" class lowerCamelCase__ : def __init__( self ): UpperCAmelCase = 0 UpperCAmelCase = 0 UpperCAmelCase = {} def _UpperCamelCase ( self ,A ): if vertex not...
701
"""simple docstring""" from __future__ import annotations from typing import Any class lowerCamelCase__ : def __init__( self ,A = 6 ): UpperCAmelCase = None UpperCAmelCase = None self.create_linked_list(A ) ...
74
0
'''simple docstring''' snake_case_ = [ '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_...
421
'''simple docstring''' import os import re import shutil import sys import tempfile import unittest import black A_ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) sys.path.append(os.path.join(git_repo_path, "utils")) import check_copies # noqa: E402 # This is t...
270
0
def _A ( lowerCAmelCase_ : int , lowerCAmelCase_ : int ): """simple docstring""" return int((input_a, input_a).count(0 ) != 0 ) def _A ( ): """simple docstring""" assert nand_gate(0 , 0 ) == 1 assert n...
715
import tempfile import torch from diffusers import PNDMScheduler from .test_schedulers import SchedulerCommonTest class __lowerCamelCase ( UpperCamelCase__ ): """simple docstring""" snake_case__ = (PNDMScheduler,) snake_case__ = (("num_inf...
125
0
def snake_case (UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ , ) -> Optional[int]: UpperCamelCase_: Optional[int] = [redshift, radiation_density, matter_density, dark_ener...
57
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, r...
22
0
'''simple docstring''' import datasets from .nmt_bleu import compute_bleu # From: https://github.com/tensorflow/nmt/blob/master/nmt/scripts/bleu.py lowerCAmelCase_ : int = """\ @INPROCEEDINGS{Papineni02bleu:a, author = {Kishore Papineni and Salim Roukos and Todd Ward and Wei-jing Zhu}, ...
707
'''simple docstring''' 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 l...
204
0
def __magic_name__ ( SCREAMING_SNAKE_CASE ) -> int: _lowercase : Optional[Any] = 1 for i in range(1 , num + 1 ): fact *= i return fact def __magic_name__ ( SCREAMING_SNAKE_CASE ) -> int: _lowercase :...
66
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _a : Optional[Any] = logging.get_logger(__name__) _a : str = { "xlm-robe...
168
0
"""simple docstring""" import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, re...
42
"""simple docstring""" __lowerCamelCase :List[Any] = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []} __lowerCamelCase :Union[str, Any] = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]} def snake_case ( UpperCamelCase__ : dict[int, list[int]] , UpperCamelCase__ ...
42
1
'''simple docstring''' def a__ ( _SCREAMING_SNAKE_CASE : int ) -> int: """simple docstring""" UpperCAmelCase_ : Optional[Any] = len(_SCREAMING_SNAKE_CASE ) for i in range(length - 1 ): UpperCAmelCase_ : Any = i for k in rang...
71
'''simple docstring''' import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( Audio...
71
1
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, ) _snake_case = pytest.mark.integration @pytest.mark.parametrize("path" , ["paws", "csv"] ...
611
from ...configuration_utils import PretrainedConfig from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = { """uclanlp/visualbert-vqa""": """https://huggingface.co/uclanlp/visualbert-vqa/resolve/main/config.json""", """uclanlp/visualbert-vqa-pre""": """...
611
1
'''simple docstring''' import baseaa import io import json import os from copy import deepcopy from ..optimizer import AcceleratedOptimizer from ..scheduler import AcceleratedScheduler class a : """simple docstring""" def __init__( self : Union[str, Any] , s...
347
'''simple docstring''' from ..utils import DummyObject, requires_backends class a ( metaclass=SCREAMING_SNAKE_CASE ): """simple docstring""" __UpperCAmelCase = ["""transformers""", """torch""", """note_seq"""] def __init__( self : Dict...
347
1
import logging import re import pytorch_quantization import pytorch_quantization.nn as quant_nn import torch from pytorch_quantization import calib from pytorch_quantization.tensor_quant import QuantDescriptor UpperCamelCase_ = logging.getLogger(__name__) UpperCamelCase_ = 50 # max width of layer...
561
import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelera...
561
1
"""simple docstring""" import inspect import os import unittest import torch import accelerate from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_async, require_multi_gpu from accelerate.utils import patch_environment class lowercase__ ( unittest.T...
88
"""simple docstring""" from __future__ import annotations def UpperCAmelCase__ (snake_case__ : int ): """simple docstring""" _snake_case : int = str(snake_case__ ) return len(snake_case__ ) == 9 and set(snake_case__ ) == set("""123456789...
609
0
def __lowerCAmelCase ( _UpperCamelCase , _UpperCamelCase , _UpperCamelCase , _UpperCamelCase ) -> List[str]: '''simple docstring''' if height >= 1: move_tower(height - 1 , UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ) ...
720
import json from typing import TYPE_CHECKING, List, Optional, Tuple from tokenizers import pre_tokenizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging if TYPE_CHECKING: from transformers.pipelines.conversational import Conversation _lowercase...
242
0
'''simple docstring''' # Usage: # ./gen-card-facebook-wmt19.py import os from pathlib import Path def a_ ( _lowerCAmelCase ,_lowerCAmelCase ,_lowerCAmelCase ) -> Dict: __lowerCamelCase : Any = { 'en': 'Machine learning is great, isn\'t it?', 'ru':...
459
'''simple docstring''' import string def a_ ( _lowerCAmelCase ) -> str: __lowerCamelCase : Union[str, Any] = '' for i in sequence: __lowerCamelCase : Tuple = ord(_lowerCAmelCase ) if 65 <= extract <= 90: output += chr(155 - extract...
459
1
'''simple docstring''' import os import random import sys from . import cryptomath_module as cryptoMath # noqa: N812 from . import rabin_miller as rabinMiller # noqa: N812 def _UpperCamelCase ( ): '''simple docstring''' print("""Making key files...""" ...
701
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) __A ={ 'configuration_encodec': [ 'ENCODEC_PRETRAINED_CONFIG_ARCHIVE_MAP', 'EncodecConfig', ], 'feature_...
113
0
import sys from typing import Tuple import numpy as np import torch from PIL import Image from torch import nn from transformers.image_utils import PILImageResampling from utils import img_tensorize class lowerCamelCase : def __init__( self :List[str] , lowercase :Optional[i...
201
class a_ : def __init__( self , SCREAMING_SNAKE_CASE = "" , SCREAMING_SNAKE_CASE = False ) -> None: """simple docstring""" SCREAMING_SNAKE_CASE_ = {} # A node will be a leaf if the tree contains its word SCREAMING_SNAKE_CASE_ ...
205
0
"""simple docstring""" import datetime import platform import subprocess from typing import Optional, Tuple, Union import numpy as np def a_ ( _lowerCAmelCase : int , _lowerCAmelCase : Union[str, Any] ): '''simple docstring''' lowercase__ : Dict ...
718
"""simple docstring""" import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_ava...
645
0
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
86
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) UpperCAmelCase_ = { '''configuration_mega''': ['''MEGA_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MegaConfig''', '''MegaOnnxConfig'''], } try: if not is_torch_available...
271
0
'''simple docstring''' import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel UpperCAmelCase__ : Optional[Any] = False UpperCAmelCase__ : Union[str, Any] = True Upp...
711
from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, TensorType, logging ...
446
0
"""simple docstring""" import os from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging __magic_name__ = logging.get_logger(__name__) __magic_name__ = ...
129
"""simple docstring""" from typing import Optional from urllib.parse import quote import huggingface_hub as hfh from packaging import version def _A ( __lowercase , __lowercase , __lowercase = None ): """simple docstring""" if version.parse(hfh.__version__...
129
1
# Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
710
import os import tempfile import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from torch import nn from transformers import ( Adafactor, AdamW, get_constant_schedule, ...
326
0
import unittest from diffusers.pipelines.pipeline_utils import is_safetensors_compatible class lowerCAmelCase__ ( unittest.TestCase ): def __UpperCamelCase ( self : List[str] ) -> Any: A = [ 'safety_checker/pytorch_model...
106
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCamelCase : Optional[Any] = logging.get_logger(__name__) lowerCamelCase : List[Any] = { 'google/canine-s': 'https://huggingface.co/google/canine-s/resolve/main/config.json', # See all ...
587
0
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...
277
from __future__ import annotations def __UpperCAmelCase ( __A ) -> list[int]: '''simple docstring''' UpperCAmelCase__ = [True] * limit UpperCAmelCase__ = False UpperCAmelCase__ = False Upper...
277
1
'''simple docstring''' import inspect from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch import torch.utils.checkpoint from ...models import UNetaDModel, VQModel from ...schedulers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteS...
603
import tempfile import unittest import numpy as np from diffusers import ( DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler, LMSDiscreteScheduler, OnnxStableDiffusionPipeline, PNDMScheduler, ) from diffusers.utils.testing_utils import i...
462
0
import sys import turtle def A ( UpperCAmelCase , UpperCAmelCase ): return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2 def A ( UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , UpperCAmelCase , ): my_pen.up() my_pen.goto(ver...
278
import gc import unittest import numpy as np import torch import torch.nn.functional as F from transformers import ( ClapTextConfig, ClapTextModelWithProjection, RobertaTokenizer, SpeechTaHifiGan, SpeechTaHifiGanConfig, ) from diffusers import ( AudioLDMPipeline, ...
278
1
"""simple docstring""" import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def lowerCamelCase ( _snake_case ): UpperCAmelCase__ : Tuple = [ 'encoder.version', 'decoder.version', ...
110
"""simple docstring""" import random def lowerCamelCase ( _snake_case ): UpperCAmelCase__ : Tuple = num - 1 UpperCAmelCase__ : Dict = 0 while s % 2 == 0: UpperCAmelCase__ : Optional[int] = s // 2 t += 1 for _ in...
110
1
import shutil import tempfile import unittest import numpy as np from transformers.testing_utils import ( is_pt_tf_cross_test, require_tf, require_torch, require_torchvision, require_vision, ) from transformers.utils import is_tf_available, is_torch_available, is_vision_available ...
661
from typing import List from .keymap import KEYMAP, get_character def A__ ( lowercase: str ) -> List[str]: def decorator(lowercase: int ): A : Tuple =getattr(lowercase, 'handle_key', [] ) handle += [key] setat...
661
1
'''simple docstring''' import sacrebleu as scb from packaging import version from sacrebleu import CHRF import datasets lowercase__ = '''\\n@inproceedings{popovic-2015-chrf,\n title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\",\n author = \"Popovi{\'c}, Maja\",\n ...
508
'''simple docstring''' import os from typing import List, Optional, Union from ...image_processing_utils import BatchFeature from ...image_utils import ImageInput from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy...
366
0
'''simple docstring''' from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel...
701
'''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.""" )
502
0
'''simple docstring''' import collections import inspect import unittest from transformers import SwinvaConfig 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_configur...
565
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase_ (metaclass=snake_case__ ): '''simple docstring''' __UpperCamelCase: Any = ["torch"] def __init__( self : Tuple , *A : Any , **A : Any ):...
244
0
from typing import List, Optional from ...configuration_utils import PretrainedConfig from ...utils import logging _lowerCamelCase : Optional[Any] = logging.get_logger(__name__) _lowerCamelCase : Tuple = { "huggingface/autoformer-tourism-monthly": "https://huggin...
702
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 @require_torch class ...
196
0
from ..utils import DummyObject, requires_backends class lowercase ( metaclass=UpperCAmelCase_ ): """simple docstring""" snake_case_ = ["""flax""", """transformers"""] def __init__( self : List[str] , *a_ : Optional[Any] , **a...
165
"""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_rober...
93
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 # #...
555
'''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''' ) def A ( ): s...
555
1
'''simple docstring''' import unittest from transformers import AlbertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTester from ...test_modeling_common import Mod...
314
'''simple docstring''' from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union import numpy as np import PIL from PIL import Image from ...utils import BaseOutput, is_torch_available, is_transformers_available @dataclass class a_ ( snake_case_ ): '''si...
314
1
import unittest from huggingface_hub import hf_hub_download from transformers import MODEL_FOR_VIDEO_CLASSIFICATION_MAPPING, VideoMAEFeatureExtractor from transformers.pipelines import VideoClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify,...
705
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available lowerCamelCase :List[Any] = { 'configuration_roc_bert': ['ROC_BERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'RoCBertConfig'], 'tokenization_roc_bert': ['RoC...
346
0
from __future__ import annotations from typing import Any class __magic_name__ : '''simple docstring''' def __init__( self:Tuple , _a:int ): snake_case__ = num_of_nodes snake_case__ = [] snake_case__ = {} def SCREAMI...
33
from operator import delitem, getitem, setitem import pytest from data_structures.hashing.hash_map import HashMap def snake_case_ ( lowerCAmelCase_ : Union[str, Any] ): return getitem, k def snake_case_ ( lowerCAmelCase_ : Any , lowerCAmelCase_ : Any ...
149
0
import os import time from dataclasses import dataclass, field from enum import Enum from typing import Dict, List, Optional, Union import torch from filelock import FileLock from torch.utils.data import Dataset from ...models.auto.modeling_auto import MODEL_FOR_QUESTION_ANSWERING_MAPPING from ...tokenization_u...
706
# This code is adapted from OpenAI's release # https://github.com/openai/human-eval/blob/master/human_eval/execution.py import contextlib import faulthandler import io import multiprocessing import os import platform import signal import tempfile def UpperCamelCase__ ( lowerCAmelCase__ ,lowerCAmel...
72
0
"""simple docstring""" import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, EulerAncestralDiscreteScheduler, LMSDiscreteScheduler, PNDMScheduler, StableDiffusion...
160
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel from diffusers import DDIMScheduler, LDMPipeline, UNetaDModel, VQModel from diffusers.utils.testing_utils import enable_full_determinism, require_torch, slow, torch_device enable_full_determinism() class...
412
0
'''simple docstring''' from typing import Union import fire import torch from tqdm import tqdm def __lowerCamelCase ( __snake_case : str, __snake_case : str = "cpu", __snake_case : Union[str, None] = None ) -> None: """simple docstring""" A__ : Optional[int] ...
712
'''simple docstring''' import gc import importlib.metadata import tempfile import unittest from packaging import version from transformers import ( AutoModel, AutoModelForCausalLM, AutoModelForSeqaSeqLM, AutoModelForSequenceClassification, AutoTokenizer, BitsAndBytesConfig, pipeline, ...
687
0
'''simple docstring''' from __future__ import annotations import math def a__ ( lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ , lowerCAmelCase__ ) -> int: if depth < 0: raise ValueError('''Depth cannot be less than 0...
75
from __future__ import annotations import os import tempfile import unittest import numpy as np from huggingface_hub import hf_hub_download from transformers import is_tensorflow_text_available, is_tf_available from transformers.testing_utils import require_tensorflow_text, require_tf, slow from ..test_modeling_tf_...
398
0
from __future__ import annotations _lowercase = [True] * 1000001 _lowercase = 2 while i * i <= 1000000: if seive[i]: for j in range(i * i, 1000001, i): _lowercase = False i += 1 def UpperCamelCase ( snake_case__): return seive[n]...
683
from collections.abc import Iterable from typing import Any class __snake_case : """simple docstring""" def __init__( self : Optional[Any] ,lowerCAmelCase__ : int | None = None ) -> List[str]: '''simple docstring''' lowerCAmelCase_ : Dict...
683
1
from __future__ import annotations from typing import Any class lowerCAmelCase_ : """simple docstring""" def __init__( self :Tuple , lowerCamelCase__ :int , lowerCamelCase__ :int , lowerCamelCase__ :float = 0 ): UpperCamelCase__ , UpperCa...
45
def A ( lowercase__ : int ) -> Optional[Any]: stooge(lowercase__ , 0 , len(lowercase__ ) - 1 ) return arr def A ( lowercase__ : Union[str, Any] , lowercase__ : Dict , lowercase__ : str ) -> List[str]: if i >= h: return # If first element is smaller than the last the...
45
1
'''simple docstring''' from typing import Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, t...
92
'''simple docstring''' import argparse import glob import importlib.util import os import re import black from doc_builder.style_doc import style_docstrings_in_code # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_copies.py a_ =...
92
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase__ : Optional[int] = { "configuration_roberta": ["R...
591
'''simple docstring''' class _a : """simple docstring""" def __init__( self , A__ ) -> List[Any]: # we need a list not a string, so do something to change the type _SCREAMING_SNAKE_CASE = arr.split(""",""" ) def Upp...
591
1
'''simple docstring''' 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, CharacterTokenize...
568
'''simple docstring''' import os import jsonlines import numpy as np from tqdm import tqdm snake_case = 20_48 snake_case = 40_96 snake_case = 42 snake_case = os.environ.pop("""PROCESS_TRAIN""", """false""") snake_case = {"""null""": 0, """s...
568
1
import random from .binary_exp_mod import bin_exp_mod def UpperCamelCase__( UpperCamelCase__ : int , UpperCamelCase__ : Any=10_00 )->int: if n < 2: return False if n % 2 == 0: return n == 2 # this means n is odd ...
190
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _lowerCamelCase : Tuple = {'''configuration_focalnet''': ['''FOCALNET_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FocalNetConfig''']} try: if n...
686
0
"""simple docstring""" from PIL import Image def lowerCAmelCase_ ( lowercase_ : Image , lowercase_ : int ): '''simple docstring''' __SCREAMING_SNAKE_CASE : Dict = (259 * (level + 255)) / (255 * (259 - level)) def contrast(lowercase_ : ...
401
"""simple docstring""" import unittest from transformers import BigBirdConfig, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask if is_flax_available(): import jax from tran...
401
1
"""simple docstring""" import itertools from dataclasses import dataclass from typing import List, Optional import pyarrow as pa import pyarrow.parquet as pq import datasets from datasets.table import table_cast a :Optional[int] = datasets.utils.logging.get_logger(__name__) @dataclass class __a ...
680
"""simple docstring""" import argparse from copy import deepcopy import numpy as np from datasets import ClassLabel, DatasetDict, load_dataset from evaluate import load from transformers import ( AutoModelForSequenceClassification, AutoTokenizer, DataCollatorWithPadding, Trainer, TrainerCallba...
110
0
import inspect import unittest import numpy as np from transformers import BeitConfig from transformers.testing_utils import require_flax, require_vision, slow from transformers.utils import cached_property, is_flax_available, is_vision_available from ...test_configuration_common import ConfigTester from...
170
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import rescale, resize, to_channel_dimension_format from ...image_utils import ( ChannelDimension, ImageInput, PILImag...
170
1
"""simple docstring""" def lowercase__ ( lowerCamelCase : list[int] , lowerCamelCase : str ) -> list[int]: lowerCAmelCase__ : Tuple = int(lowerCamelCase ) # Initialize Result lowerCAmelCase__ : Optional[int] = ...
308
"""simple docstring""" from typing import Dict, Optional import numpy as np import datasets __UpperCAmelCase = "\nIoU is the area of overlap between the predicted segmentation and the ground truth divided by the area of union\nbetween the predicted segmentation and the ground trut...
308
1
'''simple docstring''' from __future__ import annotations def __UpperCamelCase ( _UpperCAmelCase, _UpperCAmelCase ): __UpperCAmelCase , __UpperCAmelCase : Tuple = position __UpperCAmelCase : Tuple = [ (y + 1, x + 2), (y - 1, x + 2), (y ...
329
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class SCREAMING_SNAKE_CASE__ ( snake_case__ ): """simple docstring""" SCREAMING_SNAKE_CASE = '''ClapFeatureExtractor''' SCREAMING_SNAKE_CASE ...
329
1
import inspect import warnings from typing import Any, Dict, Optional, Union from packaging import version def __snake_case ( *lowerCAmelCase_ , lowerCAmelCase_ = None , lowerCAmelCase_=True , lowerCAmelCase_=2 ) -> int: from .. import __version__ SCREAMING_SN...
100
from ...configuration_utils import PretrainedConfig lowerCamelCase__ = { """google/tapas-base-finetuned-sqa""": ( """https://huggingface.co/google/tapas-base-finetuned-sqa/resolve/main/config.json""" ), """google/tapas-base-finetuned-wtq""": ( """https://hugg...
455
0
from json import JSONDecodeError # Workaround for requests.exceptions.JSONDecodeError import requests def _lowerCamelCase ( A_ : str = "isbn/0140328726" ) -> dict: '''simple docstring''' UpperCamelCase__ : Optional[Any] =olid.strip().strip("/" ) # Remove leading/trailing white...
702
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowercase__( snake_case__ ): '''simple docstring''' snake_case__ = ['''image_processor''', '''tokenizer'''] snake_case__ = ''...
582
0
from __future__ import annotations from typing import Generic, TypeVar lowercase_ : Optional[Any] = TypeVar('T') class _lowerCamelCase ( Generic[T] ): def __init__( self , lowerCAmelCase ) -> None: SCREAMING_SNAKE_CASE__: int= data SCREAMING_SNAKE_CASE__: Any= ...
64
"""simple docstring""" import os from pathlib import Path import numpy as np import pytest from pack_dataset import pack_data_dir from parameterized import parameterized from save_len_file import save_len_file from torch.utils.data import DataLoader from transformers import AutoTo...
260
0
import numpy as np import torch from torch.utils.data import Dataset from utils import logger class A_ ( __UpperCamelCase ): '''simple docstring''' def __init__( self: Any , a: Optional[Any] , a: Optional[int] ): __lowerCamelCase : int = params ...
230
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) lowercase_ = {'configuration_opt': ['OPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'OPTConfig']} try: ...
230
1
"""simple docstring""" import argparse import re import torch from CLAP import create_model from transformers import AutoFeatureExtractor, ClapConfig, ClapModel a_ : List[str] = { '''text_branch''': '''text_model''', '''audio_branch''': '''audio_model.audio_encoder''', '''attn''': ...
594
"""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_ : int = logging.get_logger(__name__) a_ : Optional[Any...
594
1
class snake_case_ : '''simple docstring''' def __init__( self : List[str] ) -> int: lowerCamelCase_ : Optional[Any] = {} def __SCREAMING_SNAKE_CASE ( self : Optional[int] ) -> None: print...
253
import argparse import json import os import fairseq import torch from fairseq.data import Dictionary from transformers import ( WavaVecaConformerConfig, WavaVecaConformerForCTC, WavaVecaConformerForPreTraining, WavaVecaCTCTokenizer, WavaVecaFeatureExtractor, WavaVecaProcessor, loggin...
253
1
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(): ...
323
from manim import * class __magic_name__ ( A__ ): def SCREAMING_SNAKE_CASE_ ( self : Any ) -> int: '''simple docstring''' UpperCAmelCase = Rectangle(height=0.5 , width=0.5 ) UpperCAmelCase = Rectangle(height=0.46 ...
323
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __UpperCAmelCase = {'configuration_glpn': ['GLPN_PRETRAINED_CONFIG_ARCHIVE_MAP', 'GLPNConfig']} try: if not is_vision_available(): ...
220
'''simple docstring''' import argparse from collections import OrderedDict from pathlib import Path import torch from huggingface_hub import hf_hub_download from PIL import Image from torchvision.transforms import functional as F from transformers import DetrImageProcessor, TableTransformerConfig, Table...
220
1
import json import os from typing import Dict, List, Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging SCREAMING_SNAKE_CASE_:List[str] = logging.get_logger(__name__) SCREAMING_SNAKE_CASE_:List[Any] = { """vocab_file""": """vocab.json""", """token...
662
import re def __UpperCamelCase ( _lowerCAmelCase ) -> str: """simple docstring""" if len(re.findall("""[ATCG]""" , _lowerCAmelCase ) ) != len(_lowerCAmelCase ): raise ValueError("""Invalid Strand""" ) return dna.translate(dna.maketrans(""...
662
1
"""simple docstring""" from typing import List, Optional, TypeVar from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets from .dataset_dict import DatasetDict, IterableDatasetDict from .info import DatasetInfo from .iterable_dataset import IterableDataset, _concatenate_...
702
"""simple docstring""" import unittest import numpy as np from transformers import MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING, TF_MODEL_FOR_AUDIO_CLASSIFICATION_MAPPING from transformers.pipelines import AudioClassificationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_si...
121
0
"""simple docstring""" import importlib.metadata import warnings from copy import deepcopy from packaging import version from ..utils import logging from .import_utils import is_accelerate_available, is_bitsandbytes_available if is_bitsandbytes_available(): import bitsandbytes as bnb import torch ...
34
"""simple docstring""" from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __snake_case = { 'configuration_informer': [ 'INFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'InformerConfig...
200
0
def __magic_name__ ( __a : int , __a : int ): '''simple docstring''' if not isinstance(_lowerCamelCase , _lowerCamelCase ): raise ValueError("""iterations must be defined as integers""" ) if not isinstance(_lowerCamelCase , _lowerCamelCase ) or not number >= 1: ...
705
import argparse import hashlib import os import urllib import warnings import torch from torch import nn from tqdm import tqdm from transformers import WhisperConfig, WhisperForConditionalGeneration lowerCamelCase_ = { '''tiny.en''': '''https://openaipublic.azureedge.net/main/whisper/models/d3dd57d32accea...
86
0
"""simple docstring""" def a_ ( lowercase__ :list[int] ): if not nums: # Makes sure that the list is not empty raise ValueError("""List is empty""" ) __lowerCamelCase = sum(lowercase__ ) / len(lowercase__ ) # Calculate the average return sum(abs(...
281
"""simple docstring""" import unittest from transformers import CamembertTokenizer, CamembertTokenizerFast from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.utils import is_torch_available from ...test_tokenization_common impor...
281
1
from collections.abc import Iterator, MutableMapping from dataclasses import dataclass from typing import Generic, TypeVar UpperCAmelCase_ = TypeVar("""KEY""") UpperCAmelCase_ = TypeVar("""VAL""") @dataclass(frozen=lowerCamelCase__ , slots=lowerCamelCase__ ) c...
436
# 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 r...
436
1
import json import os import torch from diffusers import UNetaDModel os.makedirs("""hub/hopper-medium-v2/unet/hor32""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/unet/hor128""", exist_ok=True) os.makedirs("""hub/hopper-medium-v2/value_function""", exist_ok=True) def lowerCamelCase__ ( lowe...
62
def lowerCamelCase__ ( lowercase , lowercase ): """simple docstring""" return 1 if input_a == input_a else 0 def lowerCamelCase__ ( ): """simple docstring""" assert xnor_gate(0 , 0 ) == 1 assert xnor_gate(0 , 1 ) == 0 assert xnor_gate(1 , 0 ...
62
1
import unittest from .lib import ( Matrix, Vector, axpy, square_zero_matrix, unit_basis_vector, zero_vector, ) class lowerCamelCase_ ( unittest.TestCase ): def __magic_name__ ( self ): a_ = Vector([1, 2, 3] ) self.ass...
717
import importlib import sys from argparse import REMAINDER, ArgumentParser from pathlib import Path import torch_xla.distributed.xla_multiprocessing as xmp def __SCREAMING_SNAKE_CASE ( ) -> List[str]: """simple docstring""" a_ = ArgumentParser( description=( """PyTorch TPU ...
403
0
"""simple docstring""" def __SCREAMING_SNAKE_CASE ( A_ ): # if the collection is empty, returns empty if collection == []: return [] # get some information about the collection lowerCAmelCase__ : Any = len(A_ ) lowerCAmelCase__ : int = max(A_ )...
450
"""simple docstring""" import os import shutil from pathlib import Path from typing import Optional, Union import numpy as np from huggingface_hub import hf_hub_download from ..utils import ONNX_EXTERNAL_WEIGHTS_NAME, ONNX_WEIGHTS_NAME, is_onnx_available, logging if is_onnx_available(): import onnxrun...
450
1
import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DPMSolverMultistepScheduler, TextToVideoSDPipeline, UNetaDConditionModel, ) from diffusers.utils import...
559
from sklearn.metrics import mean_squared_error import datasets __a : Union[str, Any] = """\ @article{scikit-learn, title={Scikit-learn: Machine Learning in {P}ython}, author={Pedregosa, F. and Varoquaux, G. and Gramfort, A. and Michel, V. and Thirion, B. and Grisel, O. and Blond...
559
1
import math def snake_case ( lowerCamelCase ): '''simple docstring''' __lowercase = [] __lowercase = 2 __lowercase = int(math.sqrt(lowerCamelCase ) ) # Size of every segment __lowercase = [True] * (end + 1) __lowercase = ...
80
'''simple docstring''' import os import unittest from tempfile import TemporaryDirectory import torch import torch.nn as nn from accelerate.utils import ( OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight, ) ...
430
0
'''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.numpy as jnp f...
703
'''simple docstring''' import warnings from contextlib import contextmanager from ...processing_utils import ProcessorMixin class lowerCamelCase ( __UpperCAmelCase ): _SCREAMING_SNAKE_CASE = "Speech2TextFeatureExtractor" _SCREAMING_SNAKE_CASE = "Speech2...
273
0
'''simple docstring''' from ...utils import ( OptionalDependencyNotAvailable, is_torch_available, is_transformers_available, is_transformers_version, ) try: if not (is_transformers_available() and is_torch_available() and is_transformers_version('>=', '4.25.0')): raise OptionalDepen...
396
'''simple docstring''' 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_availabl...
396
1
import argparse import torch from transformers import BlenderbotConfig, BlenderbotForConditionalGeneration from transformers.utils import logging logging.set_verbosity_info() _lowerCamelCase : Dict = logging.get_logger(__name__) _lowerCamelCase : Any = [ ["""at...
308
import argparse import csv import logging import os import random import numpy as np import torch from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, TensorDataset from tqdm import tqdm, trange from transformers import ( CONFIG_NAME, WEIGHTS_NAME, AdamW, O...
308
1
import os try: from .build_directory_md import good_file_paths except ImportError: from build_directory_md import good_file_paths # type: ignore _SCREAMING_SNAKE_CASE : Union[str, Any] = list(good_file_paths()) assert filepaths, "good_file_paths() failed!" _SCREAMING_SNAKE_CASE ...
226
import tempfile import unittest from transformers import SPIECE_UNDERLINE, BatchEncoding, PLBartTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torch, ) from ...test_tokenization_common impor...
336
0
'''simple docstring''' def __lowerCamelCase ( snake_case__ = 1_00 ) -> Dict: """simple docstring""" _SCREAMING_SNAKE_CASE = n * (n + 1) * (2 * n + 1) / 6 _SCREAMING_SNAKE_CASE = (n * (n + 1) / 2) ** 2 return in...
714
from ..utils import is_flax_available, is_torch_available if is_torch_available(): from .autoencoder_kl import AutoencoderKL from .controlnet import ControlNetModel from .dual_transformer_ad import DualTransformeraDModel from .modeling_utils import ModelMixin from .prior_transformer im...
569
0
from ...configuration_utils import PretrainedConfig from ...utils import logging lowerCAmelCase__ : Any =logging.get_logger(__name__) lowerCAmelCase__ : Union[str, Any] ={ 'caidas/swin2sr-classicalsr-x2-64': ( 'https://huggingface.co/caidas/swin2sr-classicalsr-x2...
101
def SCREAMING_SNAKE_CASE ( __lowerCAmelCase = 100 ) -> int: snake_case__ = set() snake_case__ = 0 snake_case__ = n + 1 # maximum limit for a in range(2 , __lowerCAmelCase ): for b in range(2 , __lowerCAmelCase ): snake_case__ = a*...
33
0
from decimal import Decimal, getcontext from math import ceil, factorial def UpperCamelCase ( lowercase_ ) -> str: '''simple docstring''' if not isinstance(lowercase_ , lowercase_ ): raise TypeError("""Undefined for non-integers""" ) elif precision < 1: raise Value...
495
import sys lowerCamelCase__ : List[Any] = ( """73167176531330624919225119674426574742355349194934""" """96983520312774506326239578318016984801869478851843""" """85861560789112949495459501737958331952853208805511""" """12540698747158523863050715693290963295227443043557""" """...
495
1
'''simple docstring''' import logging import os from dataclasses import dataclass from enum import Enum from typing import List, Optional, Union from filelock import FileLock from transformers import PreTrainedTokenizer, is_tf_available, is_torch_available _snake_case : Optional[int] ...
22
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available...
253
0
'''simple docstring''' from __future__ import annotations from dataclasses import dataclass @dataclass class SCREAMING_SNAKE_CASE : """simple docstring""" lowercase : float lowercase : TreeNode | None = None lowercase : TreeNode | None = None def ...
58
'''simple docstring''' from PIL import Image def UpperCamelCase__ ( a__ , a__ ): '''simple docstring''' def brightness(a__ ) -> float: return 1_2_8 + level + (c - 1_2_8) if not -255.0 <= level <= 255.0: raise ValueError('level must be be...
58
1
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from .tokenization_electra import ElectraTokenizer lowercase_ : Any = {'''vocab_file''': '''vocab.txt''', '''tokenizer_...
588
'''simple docstring''' def SCREAMING_SNAKE_CASE ( lowercase_ : int ): lowercase = abs(lowercase_ ) lowercase = 0 while n > 0: res += n % 10 n //= 10 return res def SCREAMING_SNAKE_CASE ( lowercase_ : int ): ...
588
1
'''simple docstring''' from math import ceil def __lowercase (_SCREAMING_SNAKE_CASE :Optional[int] , _SCREAMING_SNAKE_CASE :int ): SCREAMING_SNAKE_CASE : Optional[Any] = list(range(0 , _SCREAMING_SNAKE_CASE ) ) SCREAMING_SNAKE_CASE : Lis...
355
'''simple docstring''' from collections import deque def __lowercase (_SCREAMING_SNAKE_CASE :List[str] ): SCREAMING_SNAKE_CASE : Optional[Any] = len(_SCREAMING_SNAKE_CASE ) SCREAMING_SNAKE_CASE : List[str] = deque() SCREAMING_SNAKE_CASE : ...
355
1
'''simple docstring''' import functools import operator from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCamelCase : str = logging.get_logger(__name__) __lowerCamelCase : Union[str, Any] = { "asapp/sew-d-tiny-100k": "https://hugging...
310
'''simple docstring''' import argparse from transformers import TaConfig, TaForConditionalGeneration, load_tf_weights_in_ta from transformers.utils import logging logging.set_verbosity_info() def UpperCAmelCase_ ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ): """si...
310
1
from dataclasses import dataclass, field from typing import TYPE_CHECKING, Any, ClassVar, Dict, List, Optional, Union import pyarrow as pa if TYPE_CHECKING: from .features import FeatureType @dataclass class a : SCREAMING_SNAKE_CASE__ : int = 42 SCREAMING_SNAKE_CASE__ ...
702
from __future__ import annotations from math import pow, sqrt def lowerCAmelCase ( UpperCamelCase__ : float , UpperCamelCase__ : float , UpperCamelCase__ : float ) -> dict[str, float]: """simple docstring""" if (resistance, reactance,...
146
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available lowercase__ : Union[str, Any] = { '''configuration_blip_2''': [ '''BLIP_2_PRETRAINED_CONFIG_ARCHIVE_MAP''', ...
8
from collections import OrderedDict from typing import TYPE_CHECKING, Any, List, Mapping, Optional, Union from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import TensorType, logging if TYPE_CHECKING: from ...onnx.config import PatchingSpec from ...tokenizati...
31
0
from math import pi, sqrt, tan def lowerCamelCase ( SCREAMING_SNAKE_CASE ): '''simple docstring''' if side_length < 0: raise ValueError('''surface_area_cube() only accepts non-negative values''' ) return 6 * side_length**2 def lowerCamelCase ( SCREAMING_SNAKE_CASE ...
717
import gc import random import unittest import numpy as np import torch from transformers import ( CLIPImageProcessor, CLIPTextConfig, CLIPTextModel, CLIPTokenizer, CLIPVisionConfig, CLIPVisionModelWithProjection, ) from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableUnCLI...
452
0
import argparse from typing import List import evaluate import numpy as np import torch from datasets import DatasetDict, load_dataset # New Code # # We'll be using StratifiedKFold for this example from sklearn.model_selection import StratifiedKFold from torch.optim import AdamW from torch.utils.data import DataLoad...
548
import argparse import gc import json import os import torch from datasets import load_dataset from torch.optim import AdamW from torch.utils.data import DataLoader from transformers import AutoModelForSequenceClassification, AutoTokenizer, get_linear_schedule_with_warmup, set_seed from accelerate import Accelerator...
548
1
'''simple docstring''' from __future__ import annotations import pandas as pd def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : Optional[int] , SCREAMING_SNAKE_CASE_ : Optional[int] , SCREAMING_SNAKE_CASE_ : List[Any] ) -> list[int]: """...
718
'''simple docstring''' def __lowerCamelCase ( SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , SCREAMING_SNAKE_CASE_ : float , ) -> float:...
68
0
from pickle import UnpicklingError import jax import jax.numpy as jnp import numpy as np from flax.serialization import from_bytes from flax.traverse_util import flatten_dict from ..utils import logging lowerCamelCase__ : List[str] = logging.get_logger(__name__) def UpperCAmelCase_ (...
31
import unittest from transformers import RoFormerTokenizer, RoFormerTokenizerFast from transformers.testing_utils import require_rjieba, require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_rjieba @require_tokenizers class __lowercase (UpperCamelCase__ , unitte...
587
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a = { 'configuration_table_transformer': [ 'TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TableTransformerConfig', 'TableTransformerOnnxConfig', ...
700
def UpperCamelCase__ ( _A: int ): '''simple docstring''' if not isinstance(_A , _A ): __lowerCamelCase = f'''Input value of [number={number}] must be an integer''' raise TypeError(_A ) if number < 0: ...
571
0
import unicodedata from dataclasses import dataclass from typing import Optional, Union import numpy as np from transformers.data.data_collator import DataCollatorMixin from transformers.file_utils import PaddingStrategy from transformers.tokenization_utils_base import PreTrainedTokenizerBase ...
228
import itertools import json import os import unittest from transformers import AddedToken, RobertaTokenizer, RobertaTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import T...
230
0
'''simple docstring''' import argparse import json import subprocess def UpperCamelCase__ ( a__ , a__ ): '''simple docstring''' _lowerCAmelCase =[] _lowerCAmelCase =( F'''curl -H "Accept: application/vnd.github+json" -H "Authorization: Be...
58
'''simple docstring''' lowercase_ = { '''A''': '''.-''', '''B''': '''-...''', '''C''': '''-.-.''', '''D''': '''-..''', '''E''': '''.''', '''F''': '''..-.''', '''G''': '''--.''', '''H''': '''....''', '''I''': '''..''', '''J''': '''.---''', '''K''': '''-.-''', '''L''': '''.-..''', '''M''': '''--''', '''N''...
58
1
import io import itertools import json from dataclasses import dataclass from typing import Optional import pyarrow as pa import pyarrow.json as paj import datasets from datasets.table import table_cast from datasets.utils.file_utils import readline lowerCamelCase__ : int =...
33
import argparse import json from pathlib import Path import requests import timm import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import DeiTImageProcessor, ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import...
33
1
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ViTConfig, ViTForImageClassification, ViTImageProcessor, ViTModel from transformers.utils import logging logging.set_verbosity_info() lowerCA...
700
import unittest from transformers import is_torch_available, is_vision_available from transformers.testing_utils import require_torch, require_vision, slow, torch_device if is_torch_available(): import torch from transformers import AutoModelForImageClassification if is_vision_available(): from trans...
353
0
'''simple docstring''' import logging import os from typing import List, TextIO, Union from conllu import parse_incr from utils_ner import InputExample, Split, TokenClassificationTask UpperCAmelCase__ : Union[str, Any] = logging.getLogger(__name__) class A ( SCREAMING_SNAKE_CASE__ ): ...
48
"""simple docstring""" from argparse import ArgumentParser, Namespace from typing import Any, List, Optional from ..pipelines import Pipeline, get_supported_tasks, pipeline from ..utils import logging from . import BaseTransformersCLICommand try: from fastapi import Body, FastAPI, HTTPException from fastap...
661
0
import math import tensorflow as tf from packaging import version def __UpperCAmelCase ( UpperCAmelCase )-> Tuple: """simple docstring""" lowercase = tf.convert_to_tensor(UpperCAmelCase ) lowercase = 0.5 * (1.0 + tf.math.er...
479
import unittest import numpy as np from transformers.testing_utils import require_torch, require_vision from transformers.utils import is_torch_available, is_vision_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): i...
479
1
'''simple docstring''' import math import time from typing import Dict, List, Optional from torch.utils.data import Dataset from transformers import SeqaSeqTrainer, is_torch_tpu_available from transformers.trainer_utils import PredictionOutput, speed_metrics if is_torch_tpu_available(check_device=False): ...
24
from maths.prime_check import is_prime def _UpperCAmelCase ( UpperCamelCase: int ): """simple docstring""" if not isinstance(UpperCamelCase , UpperCamelCase ): __lowerCAmelCase = F"Input value of [number={number}] must be an integer" raise TypeError(UpperCamelCase ) if is_pri...
611
0
import math def _snake_case( SCREAMING_SNAKE_CASE__ : int = 100 ) -> int: '''simple docstring''' A__ = sum(i * i for i in range(1 , n + 1 ) ) A__ = int(math.pow(sum(range(1 , n + 1 ) ) , 2 ) ) retu...
586
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,...
586
1