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
from dataclasses import dataclass from typing import Dict, Optional, Union import torch import torch.nn.functional as F from torch import nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .attention import BasicTransformerBlock from .attention_processor import...
35
"""simple docstring""" from collections.abc import Sequence from queue import Queue class UpperCAmelCase_ : def __init__( self : Optional[Any] , __UpperCamelCase : List[Any] , __UpperCamelCase : List[str] , __UpperCamelCase : Tuple , __UpperCamelCase : Optional[int]=...
420
0
'''simple docstring''' def UpperCamelCase ( lowercase_ : float , lowercase_ : int ) -> float: '''simple docstring''' if digit_amount > 0: return round(number - int(lowercase_ ) , lowercase_ ) return number - int(lowercase_ ) if __name__ == "__main__": pri...
145
'''simple docstring''' import argparse import os from io import BytesIO from pathlib import Path import requests from clip_retrieval.clip_client import ClipClient from PIL import Image from tqdm import tqdm def UpperCamelCase ( lowercase_ : List[str] , lowercase_ : Optional[Any] , ...
145
1
"""simple docstring""" from itertools import product def _snake_case ( _snake_case : Dict , _snake_case : Dict ) -> list[int]: '''simple docstring''' _A = sides_number _A = max_face_number * dice_number _A = [0] * (max_total + ...
7
import argparse from transformers import CLIPImageProcessor, CLIPVisionModelWithProjection from diffusers import UnCLIPImageVariationPipeline, UnCLIPPipeline if __name__ == "__main__": lowerCamelCase_ : int = argparse.ArgumentParser() parser.add_argument("""--dump_path""", default=None, type...
548
0
import unittest from transformers.testing_utils import CaptureStdout from transformers.tools.python_interpreter import evaluate def _SCREAMING_SNAKE_CASE ( __lowercase : Optional[int] ) -> List[str]: """simple docstring""" return x + 2 class __lowercase ...
199
import argparse import requests import torch from PIL import Image from transformers import ViTMAEConfig, ViTMAEForPreTraining, ViTMAEImageProcessor def _SCREAMING_SNAKE_CASE ( __lowercase : str ) -> str: """simple docstring""" if "cls_token" in name: __A ...
199
1
import json import logging import math import os import sys from dataclasses import dataclass, field from typing import Optional from datasets import Dataset, load_dataset import transformers from transformers import ( CONFIG_MAPPING, MODEL_FOR_MASKED_LM_MAPPING, AutoConfig, AutoModelForMaskedLM, ...
514
'''simple docstring''' import argparse import os import re __snake_case : Dict = 'src/diffusers' # Pattern that looks at the indentation in a line. __snake_case : Optional[Any] = re.compile(r'^(\s*)\S') # Pattern that matches `"key":" and puts `key` in group 0. __snake_case : ...
215
0
from __future__ import annotations import math def lowerCAmelCase ( _lowerCAmelCase : int ): """simple docstring""" if num <= 0: UpperCAmelCase__ = F'''{num}: Invalid input, please enter a positive integer.''' raise ValueError(_lowerCAmelCase ) UpperCAmelCase__ ...
364
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available _lowerCAmelCase : Optional[int] = { "configuration_maskformer": ["MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "MaskFormerConfig"], "configuration_maskformer...
364
1
'''simple docstring''' import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Image from .base import TaskTemplate @dataclass(frozen=SCREAMING_SNAKE_CASE ) class SCREAMING_SNAKE_CASE ( SCREAMING_SNAKE_C...
435
'''simple docstring''' def __A ( UpperCAmelCase ) -> str: '''simple docstring''' if isinstance(UpperCAmelCase ,UpperCAmelCase ): raise TypeError("'float' object cannot be interpreted as an integer" ) if isinstance(UpperCAmelCase ,U...
435
1
def __UpperCAmelCase ( __A ) -> int: '''simple docstring''' if divisor % 5 == 0 or divisor % 2 == 0: return 0 UpperCAmelCase__ = 1 UpperCAmelCase__ = 1 while repunit: UpperCAmelCase__ ...
277
from __future__ import annotations class lowercase__ : def __init__( self : int , _lowercase : list[list[int]] ): """simple docstring""" UpperCAmelCase__ = TypeError( "Matrices must be formed ...
277
1
"""simple docstring""" import os import tempfile import unittest from transformers import NezhaConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device from ...generation.test_utils import ...
223
"""simple docstring""" import math class lowerCAmelCase_ : """simple docstring""" def __init__(self , SCREAMING_SNAKE_CASE__=0 ) -> str: # a graph with Node 0,1,...,N-1 """simple docstring""" SCREAMING_SNAKE_CASE__ : ...
223
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available lowerCamelCase_ = {'''configuration_swin''': ['''SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SwinConfig''', '''SwinOnnxConfig''']} try: if not is_torch_available(): ...
86
def __magic_name__ ( __a : str , __a : str ): '''simple docstring''' UpperCamelCase__ = len(__a ) UpperCamelCase__ = len(__a ) UpperCamelCase__ = [[False for _ in range(m + 1 )] for _ in range(n + 1 )] UpperCamelCase__ = True for i in...
86
1
lowerCamelCase =8.31_4462 # Unit - J mol-1 K-1 def SCREAMING_SNAKE_CASE_ ( UpperCamelCase__ , UpperCamelCase__ , UpperCamelCase__ ): if moles < 0 or kelvin < 0 or volume < 0: raise ValueError('''Invalid inputs. Enter positive value.''' ) return moles * kelvin * UNIVERSAL_...
285
"""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, CharacterToke...
155
0
import sys def __UpperCAmelCase ( snake_case_ : List[str] ): '''simple docstring''' UpperCAmelCase: Optional[Any] = len(snake_case_ ) UpperCAmelCase: Optional[int] = [[0 for x in range(snake_case_ )] for x in range(snake_case_ )] ...
704
from __future__ import annotations import numpy as np def __UpperCAmelCase ( snake_case_ : list[float] ): '''simple docstring''' return np.maximum(0 , snake_case_ ) if __name__ == "__main__": print(np.array(relu([-1, 0, 5]))) # --> [0, 0, 5]
166
0
import pprint import requests _A = "https://zenquotes.io/api" def lowerCamelCase__ ( ): """simple docstring""" return requests.get(API_ENDPOINT_URL + "/today" ).json() def lowerCamelCase__ ( ): """simple docstring""" return requests.get(API_ENDPO...
290
from math import loga def lowerCamelCase__ ( __lowerCAmelCase : int ): """simple docstring""" if a < 0: raise ValueError("Input value must be a positive integer" ) elif isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise TypeError("Inp...
290
1
import warnings from typing import List, Optional, Tuple, Union import numpy as np import PIL import torch from ...models import UNetaDModel from ...schedulers import RePaintScheduler from ...utils import PIL_INTERPOLATION, logging, randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipel...
705
def a ( A__ : str , A__ : int ) -> list[str]: """simple docstring""" return [sentence[i : i + ngram_size] for i in range(len(A__ ) - ngram_size + 1 )] if __name__ == "__main__": from doctest import testmod testmod()
380
0
import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class UpperCAmelCase__ ( unittest.TestCase ): '''simple docstring''' def lowerCAmelCase_ ( self : Union[str, Any] ): ...
322
def UpperCamelCase__ ( UpperCAmelCase_ , UpperCAmelCase_ , UpperCAmelCase_ ) -> float: '''simple docstring''' if principal <= 0: raise Exception('''Principal borrowed must be > 0''' ) if rate_per_annum < 0: raise Exception('''R...
322
1
import datasets import faiss import numpy as np import streamlit as st import torch from elasticsearch import Elasticsearch from elia_utils import ( embed_questions_for_retrieval, make_qa_sas_model, qa_sas_generate, query_es_index, query_qa_dense_index, ) import transformers ...
713
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, is_vision_available, ) UpperCAmelCase__ : Optional[Any] = { ...
676
0
from dataclasses import dataclass from typing import Optional, Tuple, Union import torch import torch.nn as nn from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput from .embeddings import GaussianFourierProjection, TimestepEmbedding, Timesteps from .mod...
27
from collections.abc import Callable def __lowerCAmelCase( _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE , _SCREAMING_SNAKE_CASE ) -> float: """simple docstring""" _A = a _A = b if function(_SCREAMING_S...
27
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 ( is_accelerate_a...
370
"""simple docstring""" import unittest from transformers import SPIECE_UNDERLINE from transformers.models.speechta import SpeechTaTokenizer from transformers.testing_utils import get_tests_dir, require_sentencepiece, require_tokenizers, slow from transformers.tokenization_utils import AddedToken from ...test_toke...
370
1
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCamelCase__ : Dict = logging.get_logger(__name__) UpperCamelCase__ : Tuple = { """google/pegasus-large""": """https://huggingface.co/google/pegasus-large/resolve/main/config....
387
import os def lowerCAmelCase_ ( ): with open(os.path.dirname(snake_case_ ) + """/p022_names.txt""" ) as file: _A : Optional[Any] = str(file.readlines()[0] ) _A : Dict = names.replace("""\"""","""""" ).split(""",""" ) names.sort() _A ...
307
0
import argparse import torch from ...utils import logging from . import AlbertConfig, AlbertForPreTraining, load_tf_weights_in_albert logging.set_verbosity_info() def lowercase_( SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ , SCREAMING_SNAKE_CASE_ ): '''simple docstrin...
716
import os import re from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import logging _snake_case = logging.get_logger(__name__) _snake_case = {'''voca...
231
0
"""simple docstring""" from __future__ import annotations from decimal import Decimal from math import * # noqa: F403 from sympy import diff def A__ ( __lowerCamelCase, __lowerCamelCase, __lowerCamelCase = 1_0**-1_0 ): """simple docstring""" _lowerCAmelCase = ...
589
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available __UpperCAmelCase = { 'configuration_table_transformer': [ 'TABLE_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TableTransformerConfig', 'Ta...
406
0
'''simple docstring''' from typing import Any, Dict, List, Union from ..utils import add_end_docstrings, is_torch_available, is_vision_available, logging, requires_backends from .base import PIPELINE_INIT_ARGS, ChunkPipeline if is_vision_available(): from PIL import Image from ..image_utils import...
245
'''simple docstring''' from argparse import ArgumentParser, Namespace from ..utils import logging from . import BaseTransformersCLICommand def UpperCamelCase ( a ) -> Optional[int]: '''simple docstring''' return ConvertCommand( args.model_type , args.tf_checkpoint , arg...
245
1
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by ap...
73
from __future__ import annotations import unittest from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_available from transformers.testing_utils import require_tf, require_tokenizers, slow from transformers.utils import cached_property from ...test_configuration_common import ConfigTest...
439
0
import gc import random import unittest import numpy as np import torch from PIL import Image from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import AutoencoderKL, DDIMScheduler, DDPMScheduler, StableDiffusionUpscalePipeline, UNetaDConditionModel from diffusers.utils import ...
703
"""simple docstring""" def SCREAMING_SNAKE_CASE_ ( snake_case : int )-> int: return 1 if digit in (0, 1) else (digit * factorial(digit - 1 )) def SCREAMING_SNAKE_CASE_ ( snake_case : int )-> bool: _lowerCamelCase = 0 _lowerCamelCase = n...
222
0
import colorsys from PIL import Image # type: ignore def __snake_case ( lowerCAmelCase_ , lowerCAmelCase_ , lowerCAmelCase_ ) -> float: SCREAMING_SNAKE_CASE__ = x SCREAMING_SNAKE_CASE__ = y for step in range(lowerCAmelCase_ ): # noqa: B0...
100
import argparse import json from collections import OrderedDict import torch from huggingface_hub import cached_download, hf_hub_url from transformers import AutoImageProcessor, CvtConfig, CvtForImageClassification def __snake_case ( lowerCAmelCase_ ) -> Optional[Any]: SCREAMING_SN...
100
1
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 ...toke...
702
import itertools import random import unittest import numpy as np from transformers import is_speech_available from transformers.testing_utils import require_torch, require_torchaudio from ...test_sequence_feature_extraction_common import SequenceFeatureExtractionTestMixin if is_speech_available(): from ...
552
0
import argparse import os import re _a = "src/diffusers" # Pattern that looks at the indentation in a line. _a = re.compile(r"^(\s*)\S") # Pattern that matches `"key":" and puts `key` in group 0. _a = re.compile(r"^\s*\"([^\"]+)\":") # Pattern that matches `_import_structure["key"]` and puts ...
481
'''simple docstring''' from statistics import mean import numpy as np def a_ ( lowerCamelCase : list , lowerCamelCase : list , lowerCamelCase : list , lowerCamelCase : int ): lowerCAmelCase = 0 # Number of processe...
133
0
import argparse import json from collections import OrderedDict from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import PoolFormerConfig, PoolFormerForImageClassification, PoolFormerImageProcessor from transformers.utils import...
716
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) _SCREAMING_SNAKE_CASE : List[Any] = { '''configuration_roberta''': ['''ROBERTA_PRETRAI...
472
0
'''simple docstring''' import pytest from datasets.utils.sharding import _distribute_shards, _number_of_shards_in_gen_kwargs, _split_gen_kwargs @pytest.mark.parametrize( """kwargs, expected""" , [ ({"""num_shards""": 0, """max_num_jobs""": 1}, []), ({"""num_shards""": 10, """m...
38
'''simple docstring''' import argparse import os import re __lowerCAmelCase = "src/diffusers" # Pattern that looks at the indentation in a line. __lowerCAmelCase = re.compile(R"^(\s*)\S") # Pattern that matches `"key":" and puts `key` in group 0. __lowerCAmelCase = ...
536
0
'''simple docstring''' import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia ...
709
'''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_t...
512
0
'''simple docstring''' from __future__ import annotations def __snake_case (__UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase , ): """simple docstring""" lowerCamelCase_ : Union[str, Any] = len(__Uppe...
501
'''simple docstring''' from typing import Callable, List, Optional, Union import PIL import torch from transformers import ( CLIPImageProcessor, CLIPSegForImageSegmentation, CLIPSegProcessor, CLIPTextModel, CLIPTokenizer, ) from diffusers import DiffusionPipeline from diffusers.configu...
501
1
'''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 __UpperCAmelCase = logging.get_logger(__name__) __UpperCAmelCase ...
715
'''simple docstring''' import argparse from typing import Dict import tensorflow as tf import torch from tqdm import tqdm from transformers import BigBirdPegasusConfig, BigBirdPegasusForConditionalGeneration __UpperCAmelCase = [ # tf -> hf ("/", "."), ("layer_", "layers."), ("k...
692
0
"""simple docstring""" from ..utils import DummyObject, requires_backends class A_ ( metaclass=_a ): lowerCAmelCase__ = ['transformers', 'torch', 'note_seq'] def __init__( self: Union[str, Any] ,*__lowerCAmelCase: List[str] ,**__lowerCAmelCase: L...
46
'''simple docstring''' import copy import unittest from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_configuration_c...
653
0
# DISCLAIMER: This file is strongly influenced by https://github.com/ermongroup/ddim from dataclasses import dataclass from typing import Optional, Tuple, Union import flax import jax import jax.numpy as jnp from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils_flax import ( C...
688
# Lint as: python3 import os import re import urllib.parse from pathlib import Path from typing import Callable, List, Optional, Union from zipfile import ZipFile from ..utils.file_utils import cached_path, hf_github_url from ..utils.logging import get_logger from ..utils.version import Version SCREAMING_SNAKE_CASE...
688
1
from __future__ import annotations import math def snake_case( __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ , __magic_name__ ) -> int: '''simple docstring''' if depth < 0: raise ...
217
import inspect import logging import os import random import shutil import tempfile import unittest import pytest import torch from torch import nn from torch.utils.data import DataLoader, TensorDataset from accelerate import Accelerator from accelerate.test_utils import execute_subprocess_asy...
217
1
'''simple docstring''' from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import Padd...
490
'''simple docstring''' from ..utils import DummyObject, requires_backends class __lowercase ( metaclass=__magic_name__ ): _a = ["""onnx"""] def __init__( self , *UpperCamelCase , **UpperCamelCase ) -> str: require...
490
1
import unittest import numpy as np import requests 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_...
21
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) _A = { """configuration_roberta_prelayernorm""": [ """ROBERTA_PRELAYERNORM_PRETRAINED_CONF...
258
0
from collections import defaultdict from graphs.minimum_spanning_tree_prims import prisms_algorithm as mst def _UpperCamelCase ( ): __SCREAMING_SNAKE_CASE , __SCREAMING_SNAKE_CASE : Optional[Any] = 9, 14 # noqa: F841 __SCREAMING_SNAKE_CASE : Dict = [ [0, 1, 4], ...
716
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 _lowercase ( A__ ): '''simple docstring''' SCRE...
260
0
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging _SCREAMING_SNAKE_CASE = logging.get_logger(__name__) _SCREAMING_SNAKE_CASE ...
502
'''simple docstring''' import math from collections.abc import Iterator from itertools import takewhile def _lowerCAmelCase ( lowerCamelCase_ : int ): if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number %...
502
1
'''simple docstring''' import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class UpperCamelCase ( ...
700
'''simple docstring''' import numpy # List of input, output pairs UpperCamelCase : List[str] = ( ((5, 2, 3), 15), ((6, 5, 9), 25), ((11, 12, 13), 41), ((1, 1, 1), 8), ((11, 12, 13), 41), ) UpperCamelCase : Dict = (((515, 22, 13), 555), ((61, 35, 49), 150)) UpperCa...
610
0
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available _snake_case = { "configuration_graphormer": ["GRAPHORMER_PRETRAINED_CONFIG_ARCHIVE_MAP", "GraphormerConfig"], } try: if not is_torch_available(): ...
500
from collections import OrderedDict from typing import Any, List, Mapping, Optional from ... import PreTrainedTokenizer, TensorType, is_torch_available from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfigWithPast, PatchingSpec from ...utils import logging _snake_case = loggi...
500
1
import json import os import unittest from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES, BioGptTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class lowerCAmelCase__( __lowercase , unittest.TestCase ): ...
719
import warnings from typing import List, Optional, Union from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy from ...utils import TensorType class lowerCAmelCase__ ( __lowercase ): ...
202
0
from ....configuration_utils import PretrainedConfig from ....utils import logging _lowercase : List[Any] = logging.get_logger(__name__) _lowercase : List[str] = { "speechbrain/m-ctc-t-large": "https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json", ...
641
def _lowerCAmelCase ( UpperCamelCase__: str , UpperCamelCase__: int , UpperCamelCase__: Any=False ) -> str: """simple docstring""" if isinstance(UpperCamelCase__ , UpperCamelCase__ ) and isinstance(UpperCamelCase__ , UpperCamelCase__ ): A ...
641
1
import pickle import unittest import torch from accelerate import Accelerator from accelerate.state import AcceleratorState from accelerate.test_utils import require_cpu @require_cpu class a ( unittest.TestCase ): def _UpperCAmelCase ( self ): '''simple docstring'''...
707
import argparse import json import os from collections import OrderedDict import numpy as np import tensorflow as tf import torch def __SCREAMING_SNAKE_CASE ( lowerCAmelCase: Any ) -> Optional[int]: _UpperCAmelCase : Optional[Any] = os.path.join(args.tf_model_dir , "pa...
467
0
def SCREAMING_SNAKE_CASE_ ( lowerCAmelCase_: int ): snake_case_ : Union[str, Any] = int(lowerCAmelCase_ ) if decimal in (0, 1): # Exit cases for the recursion return str(lowerCAmelCase_ ) snake_case_ ,snake_case_ : Tuple = divmod(lowerCAme...
666
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase = logging.get_logger(__name__) UpperCAmelCase = { "microsoft/git-base": "https://huggingface.co/microsoft/git-base/resolve/mai...
666
1
'''simple docstring''' import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class lowercase_ ( lowerCAmelCase__ ): __UpperCamelCase = ["image_processor", "tokenizer"] __UpperCamelCase = "ViTImageProcessor" ...
706
def UpperCAmelCase ( UpperCamelCase__ ) -> str: '''simple docstring''' if isinstance(UpperCamelCase__ , UpperCamelCase__ ): raise TypeError("""'float' object cannot be interpreted as an integer""" ) if isinstance(UpperCamelCase__ , UpperCamelCase__ ): ...
334
0
"""simple docstring""" import itertools import os import random import tempfile import unittest import numpy as np from transformers import TvltFeatureExtractor, is_datasets_available from transformers.testing_utils import check_json_file_has_correct_format, require_torch, require_torchaudio from transformers.utils...
277
"""simple docstring""" from transformers import BertTokenizerFast from .custom_tokenization import CustomTokenizer class a ( lowerCAmelCase_ ): _snake_case : Dict = CustomTokenizer pass
277
1
def lowerCamelCase__ ( _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : Optional[Any] = 0 while num > 0: digit_sum += num % 10 num //= 10 return digit_sum def lowerCamelCase__ ( _lowerCamelCase = 100 ): '''simple docstr...
704
"""simple docstring""" from __future__ import annotations from collections.abc import Callable _lowerCAmelCase = list[list[float | int]] def lowerCamelCase__ ( _lowerCamelCase , _lowerCamelCase ): '''simple docstring''' _lowerCAmelCase : int = len...
16
0
'''simple docstring''' import collections import inspect import unittest from transformers import FocalNetConfig from transformers.testing_utils import require_torch, require_vision, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_vision_available from ...test_backb...
400
'''simple docstring''' import re from filelock import FileLock try: import nltk _SCREAMING_SNAKE_CASE : Optional[int] = True except (ImportError, ModuleNotFoundError): _SCREAMING_SNAKE_CASE : Optional[Any] = False if NLTK_AVAILABLE: with FileLock(".lock") as lock: ...
400
1
"""simple docstring""" from dataclasses import dataclass, field from typing import Tuple from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends from .benchmark_args_utils import BenchmarkArguments if is_torch_available(): import torch if is_torc...
717
"""simple docstring""" import math lowerCAmelCase__ =10 lowerCAmelCase__ =7 lowerCAmelCase__ =BALLS_PER_COLOUR * NUM_COLOURS def _a ( UpperCAmelCase__ = 20 ) -> str: __SCREAMING_SNAKE_CASE = math.comb(UpperCAmelCase__ , UpperCAmelCase__ ...
690
0
import hashlib import unittest from transformers import MODEL_FOR_DEPTH_ESTIMATION_MAPPING, is_torch_available, is_vision_available from transformers.pipelines import DepthEstimationPipeline, pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require...
62
"""simple docstring""" import unittest from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow from ...test_tokenization_common import TokenizerTesterMixin @require_tokenizers @require_sente...
657
0
"""simple docstring""" import importlib.util import json import os import warnings from dataclasses import dataclass, field import torch from ..training_args import TrainingArguments from ..utils import cached_property, is_sagemaker_dp_enabled, logging _UpperCamelCase = ...
363
"""simple docstring""" from typing import List, Optional, Union from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCamelCase = logging.get_logger(__name__) _UpperCamelCase = { 'huggingface/time-series-transformer-tourism-m...
363
1
'''simple docstring''' from __future__ import annotations def UpperCamelCase__ ( __magic_name__ : str , __magic_name__ : str ) -> bool: '''simple docstring''' snake_case__ : Union[str, Any] = get_failure_array(__magic_name__ ) # 2) Step throu...
38
from __future__ import annotations def _a ( lowerCamelCase ): lowerCamelCase : Union[str, Any] = str(lowerCamelCase ) return n == n[::-1] def _a ( lowerCamelCase = 100_0000 ): lowerCamelCase : Any = 0 for i in range(1, lowerCame...
681
0
from __future__ import annotations snake_case_ : int = [] def __UpperCAmelCase ( snake_case_ : Optional[Any] , snake_case_ : Union[str, Any] , snake_case_ : int ): '''simple docstring''' for i in range(len(__A )...
715
from collections import deque class __lowerCamelCase : def __init__( self , __snake_case , __snake_case , __snake_case ) -> None: """simple docstring""" UpperCAmelCase: Tuple = process_name # process name ...
166
0
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_download, hf_hub_url from PIL import Image from transformers import DetaConfig, DetaForObjectDetection, DetaImageProcessor, SwinConfig from transformers.utils import logging logging....
271
import torch def lowerCAmelCase_ ( ) -> int: '''simple docstring''' if torch.cuda.is_available(): _UpperCamelCase: Any = torch.cuda.device_count() else: _UpperCamelCase: Union[str, Any] = 0 print(F"""Successfully ran on {num_gpus} GPUs""" ) if __name__ == "__ma...
271
1
UpperCamelCase__ = "\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" UpperCamelCase__ = [...
548
from math import ceil, sqrt def _UpperCamelCase (a__ :int = 100_0000 ): """simple docstring""" UpperCamelCase__ = 0 for outer_width in range(3 , (limit // 4) + 2 ): if outer_width**2 > limit: UpperCamelCas...
548
1
from __future__ import annotations def lowerCamelCase ( a_ ) -> bool: lowerCAmelCase_ = str(a_ ) return len(a_ ) == 9 and set(a_ ) == set('123456789' ) def lowerCamelCase ( ) -> int | None: for base_num in range(9_999 ...
318
from __future__ import annotations def lowerCamelCase ( a_ ) -> bool: lowerCAmelCase_ = str(a_ ) return len(a_ ) == 9 and set(a_ ) == set('123456789' ) def lowerCamelCase ( ) -> int | None: for base_num in range(9_999 ...
318
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tensorflow_text_available, is_torch_available snake_case__ = { 'configuration_ernie': ['ERNIE_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ErnieConfig', 'ErnieOnnxConfig'], } try: if not is_torch_availabl...
638
import numpy as np import skfuzzy as fuzz if __name__ == "__main__": # Create universe of discourse in Python using linspace () snake_case__ = np.linspace(start=0, stop=75, num=75, endpoint=True, retstep=False) # Create two fuzzy sets by defining any membership function # (trapmf(), gbe...
638
1
'''simple docstring''' from __future__ import annotations class UpperCAmelCase : """simple docstring""" def __init__( self : int , UpperCamelCase__ : list[list[int]] ) -> Tuple: _UpperCamelCase =TypeError( '''Matrices must be ...
404
'''simple docstring''' import argparse import torch from torch import nn from transformers import SpeechaTextConfig, SpeechaTextForConditionalGeneration def _a (__SCREAMING_SNAKE_CASE ): """simple docstring""" _UpperCamelCase =[ '''encoder.version''', '''decoder.ver...
404
1
'''simple docstring''' import os import shutil import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np from datasets import Dataset from transformers.models.realm.configuration_realm import RealmConfig from transformers.models.realm.retrieval_realm import _REALM_BLOC...
715
'''simple docstring''' import unittest from transformers import MODEL_FOR_DOCUMENT_QUESTION_ANSWERING_MAPPING, AutoTokenizer, is_vision_available from transformers.pipelines import pipeline from transformers.pipelines.document_question_answering import apply_tesseract from transformers.testing_utils import (...
8
0
"""simple docstring""" from collections import OrderedDict from typing import Mapping from packaging import version from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging A = logging.get_logger(__name__) A = { ...
449
"""simple docstring""" # 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...
353
0
"""simple docstring""" 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, R...
705
"""simple docstring""" # Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
229
0
"""simple docstring""" import json import os from typing import Optional import numpy as np from ...feature_extraction_utils import BatchFeature from ...processing_utils import ProcessorMixin from ...utils import logging from ...utils.hub import get_file_from_repo from ..auto import AutoTokenizer SC...
465
"""simple docstring""" import enum import warnings from ..tokenization_utils import TruncationStrategy from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging from .base import PIPELINE_INIT_ARGS, Pipeline if is_tf_available(): import tensorflow as tf from ..models.a...
465
1
from typing import TYPE_CHECKING # rely on isort to merge the imports from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available _a : Optional[Any] = { 'configuration_autoformer': [ 'AUTOFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AutoformerConfig', ...
712
from __future__ import annotations from math import pi # Define the Reduced Planck Constant ℏ (H bar), speed of light C, value of # Pi and the function _a : Union[str, Any] = 1.0_54_57_18_17e-34 # unit of ℏ : J * s _a : Optional[Any] = 3e8 # unit of c : m * s^-1 def Up...
571
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(): ...
371
"""simple docstring""" import os from collections import namedtuple import pytest from datasets import ClassLabel, Features, Sequence, Value from datasets.commands.test import TestCommand from datasets.info import DatasetInfo, DatasetInfosDict lowerCAmelCase : Dict = namedtuple( """_TestC...
543
0
import inspect import tempfile from collections import OrderedDict, UserDict from collections.abc import MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import fields from enum import Enum from typing import Any, ContextManager, List, Tuple import numpy as np from .im...
701
def lowercase_ ( _A : int , _A : int ): """simple docstring""" if a < 0 or b < 0: raise ValueError("the value of both inputs must be positive" ) lowerCamelCase__ : List[str] = str(bin(_A ) )[2:] # remove the leading "0b" ...
5
0
"""simple docstring""" import numpy as np from cva import COLOR_BGR2GRAY, cvtColor, imread from numpy import array, uinta from PIL import Image from digital_image_processing import change_contrast as cc from digital_image_processing import convert_to_negative as cn from digital_image_processing import sepia as sp...
480
"""simple docstring""" from typing import Optional from .. import Features, NamedSplit from ..packaged_modules.text.text import Text from ..utils.typing import NestedDataStructureLike, PathLike from .abc import AbstractDatasetReader class __lowercase ( _UpperCAmelCase): """simple docst...
480
1
"""simple docstring""" def _lowerCamelCase( a ): __a = generate_pascal_triangle(a ) for row_idx in range(a ): # Print left spaces for _ in range(num_rows - row_idx - 1 ): print(end=" " ) # Print ro...
67
"""simple docstring""" from dataclasses import dataclass from typing import Tuple import numpy as np import torch @dataclass class snake_case__ : _snake_case : torch.Tensor # [batch_size x 3] _snake_case : torch.Tensor # [batch_size x 3] _snake_case : torch.Tensor # [batch_size...
67
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_sentencepiece_available, is_tokenizers_available, is_torch_available, ) SCREAMING_SNAKE_CASE_: Tuple ={'configuration_fnet': ['FNET_PRETRAINED_CONFIG_ARCHIVE_MAP'...
78
'''simple docstring''' import logging from transformers import PretrainedConfig SCREAMING_SNAKE_CASE_: Any =logging.getLogger(__name__) SCREAMING_SNAKE_CASE_: Any ={ 'bertabs-finetuned-cnndm': 'https://huggingface.co/remi/bertabs-finetuned-cnndm-extractive-abstractive-summarization/resolve/main/conf...
78
1
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 NestedDataStructureLike, PathLike...
700
# 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 requ...
423
0
import time import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch, torch_device from ..test_modeling_common import ids_tensor if is_torch_available(): import torch from transformers.generation import ( MaxLengthCriteria, ...
99
import copy import os import tempfile from unittest import TestCase from unittest.mock import patch import numpy as np import pyarrow as pa import pyarrow.parquet as pq import pytest from datasets.arrow_writer import ArrowWriter, OptimizedTypedSequence, ParquetWriter, TypedSequence from datasets.features import Ar...
419
0
'''simple docstring''' import math A_ = 10 A_ = 7 A_ = BALLS_PER_COLOUR * NUM_COLOURS def _UpperCamelCase ( __UpperCamelCase = 20 ) -> str: lowerCamelCase_ = math.comb(__UpperCamelCase ,__UpperCamelCase ) lowerCamelCase_ = math.comb(NUM_BALLS...
384
'''simple docstring''' import unittest from transformers.testing_utils import require_bsa from transformers.utils import is_bsa_available from ...test_feature_extraction_common import FeatureExtractionSavingTestMixin if is_bsa_available(): from transformers import MarkupLMFeatureExtractor class Uppe...
384
1
"""simple docstring""" from __future__ import annotations from PIL import Image # Define glider example __lowerCamelCase = [ [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, ...
490
"""simple docstring""" from typing import List, Optional, Union import numpy as np import torch import torchaudio.compliance.kaldi as ta_kaldi from ...feature_extraction_sequence_utils import SequenceFeatureExtractor from ...feature_extraction_utils import BatchFeature from ...utils import PaddingStrategy, Te...
490
1
'''simple docstring''' def __lowerCamelCase ( _UpperCamelCase : int , _UpperCamelCase : int ): '''simple docstring''' return int((input_a, input_a).count(0 ) != 0 ) def __lowerCamelCase ( ): '''simple docstring''' assert nand_gate(0 ...
43
'''simple docstring''' lowercase__ : Union[str, Any] = "\n# Transformers 설치 방법\n! pip install transformers datasets\n# 마지막 릴리스 대신 소스에서 설치하려면, 위 명령을 주석으로 바꾸고 아래 명령을 해제하세요.\n# ! pip install git+https://github.com/huggingface/transformers.git\n" lowercase__ : str = [{"type": "code", "con...
43
1
import unittest from transformers import PegasusConfig, PegasusTokenizer, is_flax_available from transformers.testing_utils import require_flax, slow from ...test_configuration_common import ConfigTester from ...test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor if is_flax_available(): import...
203
def _lowerCamelCase ( SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE ): '''simple docstring''' A_ = len(SCREAMING_SNAKE_CASE ) A_ = len(SCREAMING_SNAKE_CASE ) A_ = ( first_str_length if first_str_length > second_str_l...
203
1
__SCREAMING_SNAKE_CASE : List[Any] ='''ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/''' def UpperCamelCase__ ( lowerCAmelCase__ ): # Make sure the supplied data is a bytes-like object if not isinstance(lowerCAmelCase__ ,lowerCAmelCase__ ): ...
715
import json import os import sys import tempfile import unittest from pathlib import Path from shutil import copyfile from huggingface_hub import HfFolder, Repository, create_repo, delete_repo from requests.exceptions import HTTPError import transformers from transformers import ( CONFIG_MAPPING, FEATUR...
72
0
import comet # From: unbabel-comet import torch import datasets snake_case = datasets.logging.get_logger(__name__) snake_case = """\ @inproceedings{rei-EtAl:2020:WMT, author = {Rei, Ricardo and Stewart, Craig and Farinha, Ana C and Lavie, Alon}, title = {Unbabel's Part...
62
"""simple docstring""" def UpperCAmelCase ( A : list[int] , A : list[int] ): '''simple docstring''' if not len(A ) == len(A ) == 3: raise ValueError('Please enter a valid equation.' ) if equationa[0] == equationa[1] == equationa...
573
0
"""simple docstring""" from typing import Optional from torch import nn from .transformer_ad import TransformeraDModel, TransformeraDModelOutput class a__ ( nn.Module ): def __init__( self, _UpperCAmelCase = 16, _UpperCAmelCase = 88, _UpperCAmelCase = None, _UpperCAmelCase = 1, ...
668
"""simple docstring""" from typing import Any import numpy as np def __a ( A ): '''simple docstring''' return np.array_equal(A , matrix.conjugate().T ) def __a ( A , A ): '''simple docstring''' lowercase__ = v.co...
668
1
from pathlib import PurePosixPath from typing import Optional import fsspec from fsspec import AbstractFileSystem from huggingface_hub.hf_api import DatasetInfo from ..utils.file_utils import get_authentication_headers_for_url from ..utils.hub import hf_hub_url class _snake_case ( UpperCAmelC...
12
import warnings from transformers import AutoTokenizer from transformers.utils import is_torch_available from transformers.utils.generic import ExplicitEnum from ...processing_utils import ProcessorMixin if is_torch_available(): import torch class __SCREAMING_SNAKE_CASE( a_...
328
0
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 __lowercase( __snake_case : Opti...
345
import json import os import unittest from transformers.models.gptsan_japanese.tokenization_gptsan_japanese import ( VOCAB_FILES_NAMES, GPTSanJapaneseTokenizer, ) from transformers.testing_utils import require_tokenizers, slow from ...test_tokenization_common import TokenizerTesterMixin @require_token...
345
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _a ( UpperCamelCase__ ): _lowercase : str = ['''image_processor''', '''tokenizer'''] _lowercase : Any = '''CLIPImagePro...
43
"""simple docstring""" from __future__ import annotations import math from collections.abc import Callable def SCREAMING_SNAKE_CASE ( snake_case, snake_case, snake_case, snake_case = 1_00, ): __snake_case = x_start __snake_case = fnc(snake_case) __snak...
564
0
'''simple docstring''' from abc import ABC, abstractmethod from argparse import ArgumentParser class a ( _lowerCamelCase ): @staticmethod @abstractmethod def A_ ( lowercase_ : ArgumentParser ): raise NotImplementedError() @abstractmethod d...
593
'''simple docstring''' import webbrowser from sys import argv from urllib.parse import parse_qs, quote import requests from bsa import BeautifulSoup from fake_useragent import UserAgent if __name__ == "__main__": a : Any = '%20'.join(argv[1:]) if len(argv) > 1 else quote(str(input(...
593
1
from __future__ import annotations snake_case = [ [-1, 0], # left [0, -1], # down [1, 0], # right [0, 1], # up ] def lowerCamelCase__ ( lowercase , lowercase , lowercase , lowercase , lowercase , ): """simple docstring""" SCREAMING_SNAKE_CASE...
62
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case__ : Dict = { """configuration_whisper""": ["""WHISPER_PRETRAINED_CONFIG_ARCHI...
402
0
'''simple docstring''' a : Any = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" def lowercase ( __magic_name__ ): '''simple docstring''' if not isinstance(__magic_name__ , __magic_name__ ): UpperCAmelCase : Dict ...
713
'''simple docstring''' import math from dataclasses import dataclass from typing import Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput, randn_tensor from .scheduling_utils import SchedulerMixin @dataclas...
609
0
'''simple docstring''' import numpy as np from transformers import BatchFeature from transformers.testing_utils import require_tf, require_torch from .test_feature_extraction_common import FeatureExtractionSavingTestMixin class SCREAMING_SNAKE_CASE (a__ ): # to overw...
8
import copy import inspect import unittest from transformers import AutoBackbone from transformers.configuration_utils import PretrainedConfig from transformers.testing_utils import require_timm, require_torch, torch_device from transformers.utils.import_utils import is_torch_available from ...test_bac...
570
0
'''simple docstring''' from __future__ import annotations from typing import TypedDict class __A ( UpperCamelCase__ ): a__ : str a__ : int def lowerCAmelCase_ ( snake_case_ : str ) -> list[str]: '''simple docstring''' if not isinstance(snake_cas...
415
'''simple docstring''' import unittest from transformers import is_vision_available from transformers.pipelines import pipeline from transformers.testing_utils import ( is_pipeline_test, nested_simplify, require_tf, require_torch, require_vision, slow, ) from .test_pipelines_common import...
415
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __A : List[str] = { "configuration_tapas": ["TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP", "TapasConfig"], "tokenization_tapas": ["TapasTokenizer...
27
UpperCAmelCase_ : dict[str, float] = { "joule": 1.0, "kilojoule": 1_000, "megajoule": 1_000_000, "gigajoule": 1_000_000_000, "wattsecond": 1.0, "watthour": 3_600, "kilowatthour": 3_600_000, "newtonmeter": 1.0, "calorie_nutr": 4_186.8, "kilocalorie_nutr": 4_186_800...
17
0
"""simple docstring""" from __future__ import annotations import random # Maximum size of the population. Bigger could be faster but is more memory expensive. _lowerCAmelCase = 2_0_0 # Number of elements selected in every generation of evolution. The selection takes # place from best to...
16
"""simple docstring""" from __future__ import annotations import json import requests from bsa import BeautifulSoup from fake_useragent import UserAgent _lowerCAmelCase = {"""UserAgent""": UserAgent().random} def lowerCamelCase__ ( _lowerCamelCase ): '''simple docstr...
16
1
"""simple docstring""" import os import unicodedata from shutil import copyfile from typing import Any, Dict, List, Optional, Tuple import sentencepiece as spm from ...tokenization_utils import AddedToken, PreTrainedTokenizer from ...utils import SPIECE_UNDERLINE, logging SCREAMING_SNAKE_CASE_ = lo...
237
"""simple docstring""" from typing import TYPE_CHECKING from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available, is_vision_available from ...utils import OptionalDependencyNotAvailable SCREAMING_SNAKE_CASE_ = {"""configuration_dpt""": ["""DPT_PRETRAINED_CONFIG_ARCHIVE_MAP"...
237
1
"""simple docstring""" import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @requ...
714
"""simple docstring""" import os from argparse import ArgumentParser from typing import List import torch.utils.data from datasets import Dataset, IterableDataset from datasets.distributed import split_dataset_by_node SCREAMING_SNAKE_CASE = 4 SCREAMING_SNAKE_CASE = 3 class...
556
0
import os import unittest from transformers import FunnelTokenizer, FunnelTokenizerFast from transformers.models.funnel.tokenization_funnel import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers from ...test_tokenization_common import TokenizerTesterMixin @require_t...
583
import warnings from ...utils import logging from .image_processing_donut import DonutImageProcessor snake_case__ = logging.get_logger(__name__) class UpperCAmelCase ( __lowerCamelCase ): def __init__( self : Optional[Any] , *lowerCAmelCase : ...
583
1
"""simple docstring""" import numpy as np def __lowerCamelCase ( lowerCAmelCase__ ): return 1 / (1 + np.exp(-vector )) def __lowerCamelCase ( lowerCAmelCase__ ): return vector * sigmoid(lowerCAmelCase__ ) if __name__ == "__main__": ...
554
"""simple docstring""" import os import numpy import onnx def __lowerCamelCase ( lowerCAmelCase__ ,lowerCAmelCase__ ): A__ = a.name A__ = b.name A__ = '' A__ = '' A__ = a...
554
1
import unittest import numpy as np from transformers.testing_utils import require_pytesseract, require_torch from transformers.utils import is_pytesseract_available, is_torch_available from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs if is_torch_available(): ...
30
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor snake_case__ : Optional[Any] = logging.get_logger(__name__) class _A ( _lowercase ): '''simple docstring''' def __init__( self : Dict , *lowerCam...
402
0
"""simple docstring""" import asyncio import os import re import sys import tempfile import unittest from contextlib import contextmanager from copy import deepcopy from distutils.util import strtobool from enum import Enum from importlib.util import find_spec from pathlib import Path fro...
715
"""simple docstring""" import unittest from transformers import ( MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TextaTextGenerationPipeline, pipeline, ) from transformers.testing_utils import is_pipeline_test, require_tf, require_torch fr...
24
0
'''simple docstring''' import unittest import numpy as np from transformers import is_flax_available from transformers.testing_utils import require_flax from ..test_modeling_flax_common import ids_tensor if is_flax_available(): import jax import jax.numpy as jnp from transfo...
90
'''simple docstring''' import argparse import json from pathlib import Path import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import ( BertTokenizer, ViltConfig, ViltForImageAndTextRetrieval, ViltForImagesAn...
90
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 ...
500
"""simple docstring""" def _snake_case ( UpperCAmelCase_ : int ): A__ = 1 for i in range(1 , num + 1 ): fact *= i return fact def _snake_case ( UpperCAmelCase_ : int ): A__ = 0 while number > 0: ...
500
1
'''simple docstring''' 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 _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,...
42
'''simple docstring''' from math import isclose, sqrt def _UpperCamelCase ( __UpperCamelCase ,__UpperCamelCase ,__UpperCamelCase ) -> tuple[float, float, float]: lowerCamelCase_ = point_y / 4 / point_x lowerCamelCase_ = 2 * normal_gradient / (1 + normal_gradi...
42
1
import numpy as np UpperCAmelCase_ : List[Any] = [ ["""a""", """b""", """c""", """d""", """e"""], ["""f""", """g""", """h""", """i""", """k"""], ["""l""", """m""", """n""", """o""", """p"""], ["""q""", """r""", """s""", """t""", """u"""], ["""v""", """w""", """x""", """y""",...
440
from collections import namedtuple UpperCAmelCase_ : Union[str, Any] = namedtuple("""from_to""", """from_ to""") UpperCAmelCase_ : int = { """cubicmeter""": from_to(1, 1), """litre""": from_to(0.0_01, 10_00), """kilolitre""": from_to(1, 1), """gallon""": from_...
440
1
'''simple docstring''' class __UpperCamelCase : def __init__( self :List[Any] ): snake_case_ : Union[str, Any] = {} def a__ ( self :List[Any] ): print(self.vertex ) for i in self.vertex: print(_UpperCAm...
334
'''simple docstring''' def _lowerCAmelCase ( __snake_case : Optional[Any] ) -> Optional[Any]: # noqa: E741 __A : Tuple = len(__snake_case ) __A : Optional[int] = 0 __A : str = [0] * n __A : int = [Fals...
8
0
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 ...test_configuration_com...
716
from ...configuration_utils import PretrainedConfig from ...utils import logging UpperCAmelCase_ : Tuple = logging.get_logger(__name__) UpperCAmelCase_ : List[str] = { """google/fnet-base""": """https://huggingface.co/google/fnet-base/resolve/main/config.json""", """...
440
0