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 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, EulerAncestralDiscreteScheduler, LMSDiscreteSchedu...
674
"""simple docstring""" import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils...
674
1
import inspect import os import sys import unittest import accelerate from accelerate.test_utils import execute_subprocess_async, require_tpu class __SCREAMING_SNAKE_CASE ( unittest.TestCase): """simple docstring""" def lowercase_ ( self ): __snake_case ...
679
import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModelWithProjection, CLIPTokenizer from diffusers import HeunDiscreteScheduler, PriorTransformer, ShapEPipeline from diffusers.pipelines.shap_e import ShapERenderer from diffusers.utils import load_numpy, slow f...
679
1
'''simple docstring''' class UpperCAmelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' pass class UpperCAmelCase_ ( _SCREAMING_SNAKE_CASE ): '''simple docstring''' pass class UpperCAmelCase_ : '''simple doc...
5
'''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()): raise OptionalDependencyNotAvailable() except OptionalDepend...
5
1
import os from datetime import datetime as dt from github import Github a_ : Optional[Any] = [ 'good first issue', 'good second issue', 'good difficult issue', 'enhancement', 'new pipeline/model', 'new scheduler', 'wip', ] def _SCREAMING_SNAKE_CASE ( )...
678
def _SCREAMING_SNAKE_CASE ( snake_case_ : str ): return " ".join( ''''''.join(word[::-1] ) if len(snake_case_ ) > 4 else word for word in sentence.split() ) if __name__ == "__main__": import doctest doctest.testmod() print(reverse_long_words('Hey wollef sroirraw'))
678
1
'''simple docstring''' import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel a = False a = True a = False if __name__ == "__main__": a = arg...
350
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging lowercase__ = logging.get_logger(__name__) lowercase__ = { """facebook/dpr-ctx_encoder-single-nq-base""": ( """https://huggingface.co/facebook/dpr-ctx_encoder-singl...
630
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, ...
414
from collections import UserDict from typing import Union import numpy as np import requests from ..utils import ( add_end_docstrings, logging, ) from .audio_classification import ffmpeg_read from .base import PIPELINE_INIT_ARGS, Pipeline __a : Optional[int] = lo...
414
1
import warnings from ...utils import logging from .image_processing_mobilevit import MobileViTImageProcessor _lowerCAmelCase : Union[str, Any] = logging.get_logger(__name__) class __snake_case ( lowerCAmelCase__ ): def __init__( self ,*a_ ,**a_ ): """simple docstring""...
193
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 lowercase_ = """src/diffusers""...
74
0
"""simple docstring""" import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ConvNextConfig, UperNetConfig from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device from transformers.utils import is_torch_av...
509
"""simple docstring""" def A_ ( UpperCAmelCase__ , UpperCAmelCase__ ) -> float: if discount_rate < 0: raise ValueError('Discount rate cannot be negative' ) if not cash_flows: raise ValueError('Cash flows list cannot be empty' ) a : List[str...
509
1
import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import classes from unilm.wavlm.WavLM imp...
276
import shutil import tempfile import unittest import numpy as np import pytest from transformers import is_speech_available, is_vision_available from transformers.testing_utils import require_torch if is_vision_available(): from transformers import TvltImageProcessor if is_speech_available(): from trans...
276
1
import os 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 lowercase : int = logging.get_logger(__name__) lowercase : Any = """▁""" lowerc...
716
import json import os from typing import Optional, Tuple from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging lowercase : str = logging.get_logger(__name__) lowercase : Tuple = {"""vocab_file""": """vocab.json"""} lowercase : int = { """vocab_file""":...
105
0
import warnings from .generation import TFGenerationMixin class __magic_name__ ( __UpperCAmelCase): '''simple docstring''' warnings.warn( "Importing `TFGenerationMixin` from `src/transformers/generation_tf_utils.py` is deprecated and will " "be r...
234
import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils import lo...
234
1
from random import randint from tempfile import TemporaryFile import numpy as np def __UpperCamelCase ( lowerCAmelCase__ : List[Any] , lowerCAmelCase__ : int , lowerCAmelCase__ : List[str] ): __a : Optional[int] = 0 if st...
326
from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import Features, Value from .base import TaskTemplate @dataclass(frozen=__lowercase ) class UpperCamelCase__ ( __lowercase ): _SCREAMING_SNAKE_CASE : str = field(default="language-modeling" ...
326
1
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer A_ = logging.get_logger(__...
143
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available A_ = { "configuration_instructblip": [ "INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP", "InstructBlipConfig", "InstructBli...
143
1
from ...configuration_utils import PretrainedConfig from ...utils import logging _UpperCAmelCase = logging.get_logger(__name__) _UpperCAmelCase = { 'SCUT-DLVCLab/lilt-roberta-en-base': ( 'https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.json' ), }...
717
import json import os import unittest from transformers.models.xlm.tokenization_xlm import VOCAB_FILES_NAMES, XLMTokenizer from transformers.testing_utils import slow from ...test_tokenization_common import TokenizerTesterMixin class _UpperCamelCase ( lowerCAmelCase_ , unittest.TestCase ...
371
0
from __future__ import annotations import math from collections.abc import Callable def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ = 100 , ): snake_case_ = x_start snake_...
39
import cmath import math def __SCREAMING_SNAKE_CASE (SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ , SCREAMING_SNAKE_CASE__ ): snake_case_ = math.radians(SCREAMING_SNAKE_CASE__ ) snake_case_ = math.radians(SCREAMING_SNAKE_C...
39
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_tokenizers_available, is_torch_available, ) UpperCamelCase ={ "configuration_convbert": ["CONVBERT_PRETRAINED_CONFIG_ARCHIVE_MAP", "Con...
543
'''simple docstring''' import torch from diffusers import StableDiffusionPipeline UpperCamelCase ="path-to-your-trained-model" UpperCamelCase =StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.floataa).to("cuda") UpperCamelCase ="A photo of sks dog in a bucket" UpperCamel...
543
1
'''simple docstring''' snake_case_ = """ABCDEFGHIJKLMNOPQRSTUVWXYZ""" def __lowercase (): SCREAMING_SNAKE_CASE : Optional[Any] = input('''Enter message: ''' ) SCREAMING_SNAKE_CASE : Any = input('''Enter key [alphanumeric]: ''' ) SCREAMING_SNAKE_CAS...
507
from ...configuration_utils import PretrainedConfig from ...utils import logging __A = logging.get_logger(__name__) __A = { "unc-nlp/lxmert-base-uncased": "https://huggingface.co/unc-nlp/lxmert-base-uncased/resolve/main/config.json", } class __low...
469
0
import unittest import numpy as np from transformers import RoFormerConfig, 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.numpy as jnp f...
72
import copy import os from typing import Union from ...configuration_utils import PretrainedConfig from ...utils import logging __SCREAMING_SNAKE_CASE : Union[str, Any] =logging.get_logger(__name__) __SCREAMING_SNAKE_CASE : Tuple ={ '''google/pix2struct-textcaps-b...
72
1
import torch import torch.nn as nn from transformers import CLIPConfig, CLIPVisionModel, PreTrainedModel from ...utils import logging SCREAMING_SNAKE_CASE__ : Tuple = logging.get_logger(__name__) def A ( _SCREAMING_SNAKE_CASE ,_SCREAMING_SNAKE_CASE ) -> Any: lowe...
311
import torch from diffusers import KDPMaDiscreteScheduler from diffusers.utils import torch_device from .test_schedulers import SchedulerCommonTest class UpperCamelCase__ (lowerCAmelCase__ ): '''simple docstring''' lowerCamelCase_ : Optional[Any] = (KDPM...
311
1
def snake_case (UpperCamelCase : str , UpperCamelCase : int ): '''simple docstring''' lowerCamelCase__ = [[] for _ in range(UpperCamelCase )] lowerCamelCase__ = key - 1 if key <= 0: raise ValueError("""Height of grid can't be 0 or negative""" ...
235
def snake_case (UpperCamelCase : dict ): '''simple docstring''' lowerCamelCase__ = set() # To detect a back edge, keep track of vertices currently in the recursion stack lowerCamelCase__ = set() return any( node not in visited and depth_first_search(UpperCam...
235
1
"""simple docstring""" import gc import random import unittest import numpy as np import torch from transformers import XLMRobertaTokenizer from diffusers import ( AltDiffusionImgaImgPipeline, AutoencoderKL, PNDMScheduler, UNetaDConditionModel, ) from diffusers.image_processor import VaeImag...
83
"""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, ViltForImagesAndTextClassification, ...
46
0
'''simple docstring''' import gc import random import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer import diffusers from diffusers import ( AutoencoderKL, EulerDiscreteScheduler, StableDiffusionLatentUpscalePipeline, StableDiffusionPip...
92
'''simple docstring''' import re import jax.numpy as jnp from flax.traverse_util import flatten_dict, unflatten_dict from jax.random import PRNGKey from ..utils import logging a_ = logging.get_logger(__name__) def UpperCamelCase_ ( __SCREAMING_SNAKE_CASE ): """simple docstring""...
92
1
"""simple docstring""" def _UpperCamelCase ( UpperCamelCase ) -> str: """simple docstring""" __UpperCAmelCase : int = [] __UpperCAmelCase : Optional[int] = [] __UpperCAmelCase : Union[str, Any] = ...
77
'''simple docstring''' from __future__ import annotations a_ : int = list[list[int]] # assigning initial values to the grid a_ : Matrix = [ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0, 8, 0], [9, 0, 0, 8...
676
0
"""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 ...
715
"""simple docstring""" _UpperCamelCase = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ _...
74
0
'''simple docstring''' def a ( UpperCamelCase_ : Optional[Any] ) -> Optional[Any]: snake_case__ =len(UpperCamelCase_ ) for i in range(length - 1 ): snake_case__ =i for k in range(i + 1 , UpperCamelCase_ ): if collection[k] < collection[least]: ...
538
'''simple docstring''' import gc import math import unittest import torch from diffusers import UNetaDModel from diffusers.utils import floats_tensor, logging, slow, torch_all_close, torch_device from diffusers.utils.testing_utils import enable_full_determinism from .test_modeling_common import ModelTesterMixin...
538
1
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_torch_available, ) SCREAMING_SNAKE_CASE__ = {"configuration_vit_mae": ["VIT_MAE_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTMAEConfig"]} try: if not is_...
140
import argparse import os import numpy as np import tensorflow as tf import torch from transformers import BertModel def lowercase ( a , a , a ): '''simple docstring''' SCREAMING_SNAKE_CASE_ :int = ("dense.weight", "attention.self.query", "attention.self.key", "...
140
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 ...
73
from typing import List, Optional, Tuple, Union import torch from ...models import UNetaDModel from ...schedulers import ScoreSdeVeScheduler from ...utils import randn_tensor from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput class __SCREAMING_SNAKE_CASE ( UpperCamelCase): ...
576
0
'''simple docstring''' def _a ( _lowercase : int ): '''simple docstring''' __UpperCAmelCase : str = generate_pascal_triangle(_lowercase ) for row_idx in range(_lowercase ): # Print left spaces for ...
266
'''simple docstring''' import json import logging import os import re import sys from dataclasses import dataclass, field from typing import Any, Dict, List, Optional, Union import datasets import numpy as np import torch import torchaudio from packaging import version from torch import nn ...
266
1
"""simple docstring""" def __snake_case ( __A ) -> Tuple: lowercase : List[str] = [0] * len(__A ) lowercase : str = [] lowercase : Optional[int] = [] lowercase : List[str] = 0 for values in graph.value...
607
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transforme...
607
1
import warnings from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class SCREAMING_SNAKE_CASE ( lowerCamelCase__ ): __lowerCamelCase : List[str] =['image_processor', 'tokenizer'] __lowerCamelCase : Tuple ='ViTImageProcessor' ...
547
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.import_utils import ...
547
1
def lowerCAmelCase_ ( __lowerCamelCase ): stooge(__lowerCamelCase , 0 , len(__lowerCamelCase ) - 1 ) return arr def lowerCAmelCase_ ( __lowerCamelCase , __lowerCamelCase , __lowerCamelCase ): if i >= h: re...
81
def snake_case_ ( _SCREAMING_SNAKE_CASE ): __lowercase = [] __lowercase = set({"(", "[", "{"} ) __lowercase = set({")", "]", "}"} ) __lowercase = {"{": "}", "[": "]", "(": ")"} for i in range(len(_SCREAMING_SNAKE_CASE ) ): if s[i] in open_brackets...
402
0
from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available, ) snake_case = { """configuration_roberta""": ["""ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP""", ...
488
import warnings 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 snake_case = logging.get_logger(__name__) snake_case = { """nvidia/...
488
1
from functools import reduce _UpperCamelCase = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' '''66896...
243
from functools import reduce _UpperCamelCase = ( '''73167176531330624919225119674426574742355349194934''' '''96983520312774506326239578318016984801869478851843''' '''85861560789112949495459501737958331952853208805511''' '''12540698747158523863050715693290963295227443043557''' '''66896...
243
1
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available a__ = { '''configuration_poolformer''': [ '''POOLFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PoolFormerConfig''', '''PoolFormerOnnxConfi...
713
import argparse import pickle import numpy as np import torch from torch import nn from transformers import ReformerConfig, ReformerModelWithLMHead from transformers.utils import logging logging.set_verbosity_info() def __UpperCAmelCase ( __a : Tuple ,__a : Dict ,__a : ...
578
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 : Optional[int] = logging.get_logger(__name__) __A : Opti...
394
'''simple docstring''' from .integrations import ( is_optuna_available, is_ray_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb, ) from .trainer_utils import ( HPSearchBackend, default_hp_s...
517
0
'''simple docstring''' _lowerCamelCase : Optional[Any] = { """A""": """.-""", """B""": """-...""", """C""": """-.-.""", """D""": """-..""", """E""": """.""", """F""": """..-.""", """G""": """--.""", """H""": """....""", """I""": """..""", """J""": """.---""", """K""": """-.-""", """L...
704
'''simple docstring''' from graphs.minimum_spanning_tree_kruskal import kruskal def _lowerCAmelCase ( ) -> Dict: '''simple docstring''' _UpperCamelCase :int =9 _UpperCamelCase :Optional[int] =[ [0, 1, 4], [0, 7, 8], ...
512
0
def a__ ( lowercase__ , lowercase__ ): '''simple docstring''' UpperCAmelCase_ =len(lowercase__ ) print("The following activities are selected:" ) # The first activity is always selected UpperCAmelCase_ =0 print(lowercase_...
54
from __future__ import annotations def a__ ( lowercase__ , lowercase__ ): '''simple docstring''' if b == 0: return (1, 0) ((UpperCAmelCase_) , (UpperCAmelCase_)) =extended_euclid(lowercase__ , a % b ) UpperCAmelC...
54
1
"""simple docstring""" import json import os import unittest from transformers import BatchEncoding, MvpTokenizer, MvpTokenizerFast from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES from transformers.testing_utils import require_tokenizers, require_torch from transformers.utils i...
598
"""simple docstring""" import json import unittest import numpy as np from huggingface_hub import hf_hub_download 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 ImageProc...
598
1
import argparse import logging from collections import namedtuple import torch from model_bertabs import BertAbsSummarizer from models.model_builder import AbsSummarizer # The authors' implementation from transformers import BertTokenizer logging.basicConfig(level=logging.INFO) SCREAMING_...
79
'''simple docstring''' from __future__ import annotations from collections.abc import Callable __magic_name__ : Dict = list[list[float | int]] def A__ ( A_ , A_ ) -> Matrix: _lowercase = len(A_ ) _lowercase = [[0 for _ in range(size + 1 )] for _ in range(...
497
0
'''simple docstring''' import warnings from ...utils import logging from .image_processing_yolos import YolosImageProcessor __A : str = logging.get_logger(__name__) class __snake_case ( _SCREAMING_SNAKE_CASE): """simple docstr...
398
'''simple docstring''' import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class __snake_case ( unittest.TestCase): """simple docstring...
398
1
"""simple docstring""" import collections import json import math import os import re import time from fnmatch import fnmatch from typing import Dict import requests from slack_sdk import WebClient _A = WebClient(token=os.environ["CI_SLACK_BOT_TOKEN"]) def lowercase (_snake_case ) -> ...
505
from typing import List, Optional, Union import torch from transformers import ( XLMRobertaTokenizer, ) from ...models import UNetaDConditionModel, VQModel from ...pipelines import DiffusionPipeline from ...pipelines.pipeline_utils import ImagePipelineOutput from ...schedulers import DDIMScheduler, DDPM...
423
0
import argparse import torch # Step 1. clone https://github.com/microsoft/unilm # Step 2. git checkout to https://github.com/microsoft/unilm/commit/b94ec76c36f02fb2b0bf0dcb0b8554a2185173cd # Step 3. cd unilm # Step 4. ln -s $(realpath wavlm/modules.py) ./ # create simlink # import classes from unilm.wavlm.WavLM impo...
701
import PIL.Image import PIL.ImageOps from packaging import version from PIL import Image if version.parse(version.parse(PIL.__version__).base_version) >= version.parse('9.1.0'): __lowerCAmelCase : List[Any] = { 'linear': PIL.Image.Resampling.BILINEAR, 'bilinear': PIL.Image.Resamp...
164
0
'''simple docstring''' import argparse import torch from transformers import FunnelBaseModel, FunnelConfig, FunnelModel, load_tf_weights_in_funnel from transformers.utils import logging logging.set_verbosity_info() def lowerCamelCase_ ( __UpperCamelCase : Optional[int] , __...
292
'''simple docstring''' from __future__ import annotations def lowerCamelCase_ ( __UpperCamelCase : dict , __UpperCamelCase : str ) -> set[str]: """simple docstring""" _A , _A = set(__UpperCamelCase ), [start] while stack: ...
292
1
'''simple docstring''' class _a : """simple docstring""" def __init__( self : Optional[int] ): '''simple docstring''' lowercase_ = """""" lowercase_ = """""" lowercase_ = [] def lowerCamelCase__ ( self : List[str] , lo...
717
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available __snake_case = { """configuration_data2vec_audio""": ["""DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Data2VecAudioConfig"""], """config...
603
0
"""simple docstring""" import logging import os import sys from dataclasses import dataclass, field from importlib import import_module from typing import Dict, List, Optional, Tuple import numpy as np from seqeval.metrics import accuracy_score, fa_score, precision_score, recall_score from torch import nn from util...
91
"""simple docstring""" import os 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 _lowercase = logging.get_logger(__name__) _lowercase = '''▁'...
91
1
'''simple docstring''' import tempfile import unittest from transformers import TaConfig, is_torch_available from transformers.testing_utils import ( require_sentencepiece, require_tokenizers, require_torch, slow, torch_device, ) from ...generation.test_utils impor...
517
'''simple docstring''' import argparse from collections import defaultdict import yaml _SCREAMING_SNAKE_CASE = "docs/source/en/_toctree.yml" def __lowerCamelCase ( __lowerCAmelCase : Tuple ) -> Optional[int]: snake_case = defaultdict(__l...
517
1
import math from collections import defaultdict from typing import List, Optional, Tuple, Union import numpy as np import torch from ..configuration_utils import ConfigMixin, register_to_config from .scheduling_utils import KarrasDiffusionSchedulers, SchedulerMixin, SchedulerOutput def _UpperCAmelCase ( ...
611
import inspect import unittest import warnings from transformers import DeiTConfig from transformers.models.auto import get_values from transformers.testing_utils import ( require_accelerate, require_torch, require_torch_gpu, require_vision, slow, torch_device, ) from transformers.utils import...
611
1
"""simple docstring""" from typing import Optional import torch import torch.utils.checkpoint from torch import Tensor, nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...activations import ACTaFN from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_...
556
"""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 TokenizerTesterMix...
556
1
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import ( OptionalDependencyNotAvailable, _LazyModule, is_torch_available, ) A__ : List[str] = { """configuration_gpt_bigcode""": ["""GPT_BIGCODE_PRETRAINED_CONFIG_ARCHIVE_MAP""", """GPTBigCodeConfig"""], } try: ...
13
'''simple docstring''' from datasets.utils.patching import _PatchedModuleObj, patch_submodule from . import _test_patching def a__ ( ) -> Tuple: """simple docstring""" import os as original_os from os import path as original_path from os import rename as...
98
0
import argparse import collections import os import re from transformers.utils import direct_transformers_import # All paths are set with the intent you should run this script from the root of the repo with the command # python utils/check_table.py _snake_case = """src/transformers""" _snake_case ...
611
import importlib import json import os from collections import OrderedDict from typing import Dict, Optional, Union # Build the list of all image processors from ...configuration_utils import PretrainedConfig from ...dynamic_module_utils import get_class_from_dynamic_module, resolve_trust_remote_code from ...ima...
611
1
def _SCREAMING_SNAKE_CASE ( lowercase : str ): '''simple docstring''' lowerCamelCase_ = 0 # if input_string is "aba" than new_input_string become "a|b|a" lowerCamelCase_ = '''''' lowerCamelCase_ = '''''' ...
70
"""simple docstring""" from ...configuration_utils import PretrainedConfig from ...utils import logging __A : List[Any] = logging.get_logger(__name__) __A : str = { '''facebook/timesformer''': '''https://huggingface.co/facebook/timesformer/r...
231
0
import itertools import json import linecache import os import pickle import re import socket import string from collections import Counter from logging import getLogger from pathlib import Path from typing import Callable, Dict, Iterable, List import git import torch from torch.utils.data import Dataset from t...
711
import numpy as np import torch from torch.utils.data import DataLoader from accelerate.utils.dataclasses import DistributedType class lowerCamelCase_ : '''simple docstring''' def __init__( self , snake_case_=2 , snake_case_=3 , snake_case_=6_4 , snake_case_=Non...
527
0
'''simple docstring''' import argparse import os import re import packaging.version lowerCamelCase = """examples/""" lowerCamelCase = { """examples""": (re.compile(R"""^check_min_version\(\"[^\"]+\"\)\s*$""", re.MULTILINE), """check_min_version(\"VERSION\")\n"""), """init""...
474
'''simple docstring''' import gc import unittest import numpy as np import torch from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, StableDiffusionSAGPipeline, UNetaDConditionModel, ) from diffusers.utils import slow, torc...
474
1
'''simple docstring''' from __future__ import annotations def _lowerCAmelCase ( lowerCamelCase_ : list[int] , lowerCamelCase_ : int ): __lowercase = 0 __lowercase = len(UpperCAmelCase__ ) - 1 while i < j: if nums[i]...
710
'''simple docstring''' from __future__ import annotations import time from math import sqrt # 1 for manhattan, 0 for euclidean _SCREAMING_SNAKE_CASE = 0 _SCREAMING_SNAKE_CASE = [ [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], # 0 are free path whereas 1's are obstac...
56
0
"""simple docstring""" import math def __A ( a_ : List[Any] )-> Any: '''simple docstring''' SCREAMING_SNAKE_CASE : List[str] = [True] * n SCREAMING_SNAKE_CASE : List[Any] = False SCREAMING_SNAKE_CASE : List[Any] = False SCREAMING_SNAKE_C...
698
'''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_ima...
474
0
from __future__ import annotations def lowercase ( a , a , a ): '''simple docstring''' if (voltage, current, resistance).count(0 ) != 1: raise ValueError("One and only one argument must be 0" ) if resistance < 0: raise ValueError("Resistance cannot...
715
import re from pathlib import Path from unittest import TestCase import pytest @pytest.mark.integration class _UpperCAmelCase ( lowercase ): def _snake_case ( self : List[Any] , UpperCAmelCase : str): with open(UpperCAmelCase , encoding="utf-8") as in...
140
0
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class a ( unittest....
63
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_torch_tpu_avai...
63
1
import csv from collections import defaultdict from dataclasses import dataclass, field from typing import List, Optional import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import ScalarFormatter from transformers import HfArgumentParser def A_ ( snake_case : Any=None , ...
451
import inspect import unittest from huggingface_hub import hf_hub_download from transformers import ASTConfig from transformers.testing_utils import require_torch, require_torchaudio, slow, torch_device from transformers.utils import cached_property, is_torch_available, is_torchaudio_available from ...test_configur...
451
1
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, MaxNewToke...
31
UpperCAmelCase_ = {"""a""": ["""c""", """b"""], """b""": ["""d""", """e"""], """c""": [], """d""": [], """e""": []} UpperCAmelCase_ = ["""a""", """b""", """c""", """d""", """e"""] def __magic_name__ ( lowercase , lowercase , lowercase ) -> Union[str...
458
0
'''simple docstring''' def UpperCamelCase__ ( _lowercase : Any ) -> Tuple: return number & 1 == 0 if __name__ == "__main__": import doctest doctest.testmod()
717
'''simple docstring''' from __future__ import annotations SCREAMING_SNAKE_CASE_ = 10 def UpperCamelCase__ ( _lowercase : list[int] ) -> list[int]: __UpperCAmelCase: Union[str, Any] = 1 __UpperCAmelCase: Optional[Any] = max(_lowercase ) while placement <= ma...
466
0
import json import os import shutil import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoConfig, BertConfig, GPTaConfig from transformers.configur...
297
from __future__ import annotations def SCREAMING_SNAKE_CASE ( snake_case_ : float , snake_case_ : float , snake_case_ : float ): if (voltage, current, resistance).count(0 ) != 1: raise ValueError("One and only one argument must be 0" ) if resistance < 0: raise Valu...
297
1
"""simple docstring""" from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available SCREAMING_SNAKE_CASE = { 'configuration_biogpt': ['BIOGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'BioGptConfig'], 'tokenization_bi...
283
"""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_chan...
283
1
def _snake_case (__lowercase , __lowercase , __lowercase , __lowercase): UpperCamelCase_ , UpperCamelCase_ = len(__lowercase), len(grid[0]) if ( min(__lowercase , __lowercase) < 0 or row == row_length or col == col_length or...
23
snake_case__ : int = '''Input must be a string of 8 numbers plus letter''' snake_case__ : Optional[int] = '''TRWAGMYFPDXBNJZSQVHLCKE''' def lowercase ( _lowerCAmelCase ): if not isinstance(_lowerCAmelCase , _lowerCAmelCase ): UpperCAmelCase__ ...
392
0
'''simple docstring''' import json import multiprocessing as mp import re from collections import defaultdict from functools import partial from typing import Dict, List, Optional, Set, Tuple, Type from datasets import Dataset from datasketch import MinHash, MinHashLSH from dpu_utils.util...
506
'''simple docstring''' def SCREAMING_SNAKE_CASE_ ( _UpperCAmelCase : list ) -> float: _a : Union[str, Any] =0 while len(_UpperCAmelCase ) > 1: _a : Any =0 # Consider two files with minimum c...
506
1
from typing import Dict, List, Optional, Union import numpy as np from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( center_crop, get_resize_output_image_size, normalize, rescale, resize, to_channel_dimension_format, ) from ...
686
"""simple docstring""" from heapq import heappop, heappush import numpy as np def __lowerCamelCase ( lowerCAmelCase__ ,lowerCAmelCase__ ,lowerCAmelCase__ ,lowerCAmelCase__ ,): A__ , A__ = grid.shape A__ = ...
260
0
'''simple docstring''' from collections.abc import Iterable from typing import Generic, TypeVar A__: int = TypeVar('''_T''') class A__ ( Generic[_T] ): def __init__( self :Optional[int] , SCREAMING_SNAKE_CASE :List[str] = None ) -> ...
710
'''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, ...
506
0
'''simple docstring''' import pytest from datasets import Dataset, DatasetDict, Features, NamedSplit, Value from datasets.io.text import TextDatasetReader from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases def UpperCAmelCase ( lowerCamelCase_ :Any , lowerCa...
334
'''simple docstring''' from __future__ import annotations import math def UpperCAmelCase ( lowerCamelCase_ :int ): '''simple docstring''' if 1 < number < 4: # 2 and 3 are primes return True elif number < 2 or number % 2 == 0 or number % 3 == 0: # Negatives, 0, 1, all even...
334
1
import torch from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.file_utils import add_start_docstrings, add_start_docstrings_to_model_forward from transformers.models.bert.modeling_bert import ( BERT_INPUTS_DOCSTRING, BERT_START_DOCSTRING, BertEmbeddings, ...
707
def _lowerCAmelCase ( __lowerCAmelCase ) -> float: """simple docstring""" if edge <= 0 or not isinstance(__lowerCAmelCase , __lowerCAmelCase ): raise ValueError('''Length must be a positive.''' ) return 3 * ((25 + 10 * (5 ** (1 / 2))) ** (1 / 2)) *...
219
0
"""simple docstring""" from typing import Dict, List, Optional, Union import numpy as np from transformers.utils import is_vision_available from transformers.utils.generic import TensorType from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict from ...image_transforms import ( ...
425
'''simple docstring''' from __future__ import annotations import os from collections.abc import Mapping _UpperCamelCase : Any = tuple[int, int] class snake_case__ : def __init__( self : List[str] , _A : set[int] , _A : Mapping[EdgeT, int] ) -> Non...
541
0
'''simple docstring''' from __future__ import annotations from collections.abc import Callable __A : Optional[int] = list[list[float | int]] def lowerCamelCase_ ( lowercase__ , lowercase__): lowerCamelCase__ = len(__UpperCAmelCase) lowerCamelCase__ = ...
713
'''simple docstring''' def lowerCamelCase_ ( lowercase__ , lowercase__ , lowercase__): return round(float(moles / volume) * nfactor) def lowerCamelCase_ ( lowercase__ , lowercase__ , lowercase__): return round(float((moles * 0.0_821 * temperature) / (v...
187
0
"""simple docstring""" import copy from dataclasses import dataclass, field from typing import ClassVar, Dict from ..features import ClassLabel, Features, Value from .base import TaskTemplate @dataclass(frozen=snake_case ) class UpperCAmelCase_ ( snake_case ): # `task` is not a ...
76
"""simple docstring""" a_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' def __UpperCAmelCase ( __UpperCamelCase ): # Make sure the supplied data is a bytes-like object if not isinstance(__UpperCamelCase , __UpperCamelCase ): ...
76
1
import argparse import json import os import re import shutil import torch from transformers import BioGptConfig, BioGptForCausalLM from transformers.models.biogpt.tokenization_biogpt import VOCAB_FILES_NAMES from transformers.tokenization_utils_base import TOKENIZER_CONFIG_FILE from transformers.utils imp...
702
import math def A__ ( lowercase: int ) -> list: A : Optional[Any] =[True] * n A : Tuple =False A : List[Any] =False A : Dict =True for i in range(3, int(n**0.5 + 1 ), 2 ): ...
661
0
"""simple docstring""" def _UpperCamelCase ( UpperCamelCase ) -> bool: """simple docstring""" if p < 2: raise ValueError("p should not be less than 2!" ) elif p == 2: return True __UpperCAmelCase : List[Any] = 4 __UpperCAme...
77
"""simple docstring""" import json import os from typing import Optional, Tuple import regex as re from ...tokenization_utils import PreTrainedTokenizer from ...utils import logging a_ = logging.get_logger(__name__) a_ = { 'vocab_file': 'vocab.json', ...
76
0
'''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 d...
714
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_rofo...
490
0
import argparse import requests import torch from PIL import Image from transformers import SwinConfig, SwinForMaskedImageModeling, ViTImageProcessor def _SCREAMING_SNAKE_CASE ( lowerCAmelCase__ ): lowerCamelCase_ : int = SwinConfig(image_size=1_92 ) if "b...
364
import json import os import tempfile import datasets from utils import generate_example_dataset, get_duration _lowercase : List[str] =5_0000 _lowercase : str =5000 _lowercase , _lowercase : List[str] =os.path.split(__file__) _lowercase : Union[str, A...
364
1
'''simple docstring''' def snake_case ( a_ : str ) -> str: """simple docstring""" UpperCamelCase_ : int = 0 # if input_string is "aba" than new_input_string become "a|b|a" UpperCamelCase_ : Any = '''''' Uppe...
718
'''simple docstring''' 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...
543
0
from collections import defaultdict def UpperCamelCase_( lowerCamelCase_ , lowerCamelCase_ ) -> bool: _lowercase : Any = first_str.lower().strip() _lowercase : List[str] = second_str.lower().strip() # Remove whitespace _lowercase : str...
89
'''simple docstring''' import unittest from transformers import LiltConfig, is_torch_available from transformers.testing_utils import require_torch, slow, torch_device from ...generation.test_utils import GenerationTesterMixin from ...test_configuration_common import ConfigTester from ...test_modeling_common imp...
627
0
"""simple docstring""" import json import os import re import shutil import tempfile import unittest from typing import Tuple from transformers import AddedToken, BatchEncoding, ByTaTokenizer from transformers.utils import cached_property, is_tf_available, is_torch_available from ...test_tokenization_common import...
595
"""simple docstring""" import argparse import json from pathlib import Path import requests import torch from huggingface_hub import cached_download, hf_hub_url from PIL import Image from transformers import DPTConfig, DPTForDepthEstimation, DPTForSemanticSegmentation, DPTImageProcessor from transformers.utils imp...
595
1
'''simple docstring''' import inspect import unittest from transformers import SegformerConfig, is_torch_available, is_vision_available from transformers.models.auto import get_values from transformers.testing_utils import require_torch, slow, torch_device from ...test_configuration_common import ConfigTe...
525
'''simple docstring''' import json import os import shutil import warnings from argparse import ArgumentParser, Namespace from pathlib import Path from typing import List from ..utils import logging from . import BaseTransformersCLICommand try: from cookiecutter.main import cookiecutter lowerC...
525
1
'''simple docstring''' from __future__ import annotations import math def _UpperCAmelCase ( a : int ): if num <= 0: snake_case__ = F'''{num}: Invalid input, please enter a positive integer.''' raise ValueError(a ) snake_case__ = [True] * (...
701
from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available a__ = { """configuration_lilt""": ["""LILT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LiltConfig"""], } try: if not is_torch_available(): raise OptionalDependencyNotAvailable() exc...
99
0
'''simple docstring''' import argparse import json import os from tensorflow.core.protobuf.saved_model_pba import SavedModel # 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 UpperCamelCase_ = "." ...
28
'''simple docstring''' import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_distilbert import DistilBertTokenizer UpperCamelCase_ = logg...
28
1
"""simple docstring""" import copy from ...configuration_utils import PretrainedConfig from ...utils import add_start_docstrings a_ = r''' [`RagConfig`] stores the configuration of a *RagModel*. Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model output...
717
"""simple docstring""" import os from shutil import copyfile from typing import List, Optional, Tuple from tokenizers import processors from ...tokenization_utils import AddedToken, BatchEncoding from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import is_sentencepiece_available, loggi...
48
0
"""simple docstring""" import sys def lowerCamelCase_ ( _lowerCamelCase : Dict ): lowerCamelCase_ = len(_lowerCamelCase ) lowerCamelCase_ = [[0 for x in range(_lowerCamelCase )] for x in range(_lowerCamelCase )] lowerCamelCase_ = ...
142
"""simple docstring""" import collections import importlib.util import os import re from pathlib import Path __lowercase : Dict = """src/transformers""" # Matches is_xxx_available() __lowercase : Tuple = re.compile(r"""is\_([a-z_]*)_available()""") # Catches a one-lin...
142
1
'''simple docstring''' def UpperCamelCase( UpperCAmelCase_ ): assert isinstance(__snake_case , __snake_case ), F"""The input value of [n={number}] is not an integer""" if number == 1: return 2 elif number < 1: UpperCAmelCase : Any = F"""The input value of [n={number}] has to b...
712
'''simple docstring''' import io import json import unittest from parameterized import parameterized from transformers import FSMTForConditionalGeneration, FSMTTokenizer from transformers.testing_utils import get_tests_dir, require_torch, slow, torch_device from utils import calculate_bleu lowerca...
695
0
'''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...
92
'''simple docstring''' def _lowerCAmelCase ( __magic_name__ : int = 600851475143 ) -> int: try: lowercase : Any =int(__magic_name__ ) except (TypeError, ValueError): raise TypeError('''Parameter n must be int or castable to int.''' ...
92
1
from typing import Dict, Iterable, 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_chann...
314
from collections import deque from math import floor from random import random from time import time class a__ : """simple docstring""" def __init__( self :Dict ): lowercase = {} def __UpperCAmelCase ( self :Dict , lower...
314
1
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch import math from dataclasses import dataclass from typing import Optional, Tuple, Union import torch from ..configuration_utils import ConfigMixin, register_to_config from ..utils import BaseOutput...
280
import tempfile import unittest from pathlib import Path from shutil import copyfile from transformers import MaMaaaTokenizer, is_torch_available from transformers.testing_utils import ( get_tests_dir, nested_simplify, require_sentencepiece, require_tokenizers, require_torc...
280
1
from ...configuration_utils import PretrainedConfig from ...utils import logging __lowerCAmelCase : Tuple = logging.get_logger(__name__) __lowerCAmelCase : Tuple = { "microsoft/markuplm-base": "https://huggingface.co/microsoft/markuplm-base/resolve/main/config.json", "...
284
import unittest from transformers import is_torch_available from transformers.testing_utils import require_torch if is_torch_available(): import torch from transformers.activations import gelu_new, gelu_python, get_activation @require_torch class __lowerCAmelCase ( unittest.TestCase ):...
284
1
import unittest from transformers.utils.backbone_utils import ( BackboneMixin, get_aligned_output_features_output_indices, verify_out_features_out_indices, ) class _snake_case ( unittest.TestCase ): def SCREAMING_SNAKE_CASE__ ( self) -> Optional[Any]: SCREA...
73
import sys import tempfile import unittest import unittest.mock as mock from pathlib import Path from huggingface_hub import HfFolder, delete_repo from requests.exceptions import HTTPError from transformers import AutoFeatureExtractor, WavaVecaFeatureExtractor from transformers.testing_utils import TO...
1
0
'''simple docstring''' from typing import TYPE_CHECKING import torch from ..models.auto import AutoModelForVisualQuestionAnswering, AutoProcessor from ..utils import requires_backends from .base import PipelineTool if TYPE_CHECKING: from PIL import Image class SCREAMING_SNAKE_C...
719
'''simple docstring''' from collections import OrderedDict from typing import Mapping from ...configuration_utils import PretrainedConfig from ...onnx import OnnxConfig from ...utils import logging a : Union[str, Any] = logging.get_logger(__name__) a : List[Any] = { ...
680
0
"""simple docstring""" from __future__ import annotations __SCREAMING_SNAKE_CASE =list[list[int]] # assigning initial values to the grid __SCREAMING_SNAKE_CASE =[ [3, 0, 6, 5, 0, 8, 4, 0, 0], [5, 2, 0, 0, 0, 0, 0, 0, 0], [0, 8, 7, 0, 0, 0, 0, 3, 1], [0, 0, 3, 0, 1, 0, 0,...
425
"""simple docstring""" import argparse import json import requests import torch from huggingface_hub import hf_hub_download from PIL import Image from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation def lowercase__( __SCREAMING_SNAKE_CASE : An...
425
1
"""simple docstring""" from collections import namedtuple lowerCAmelCase_ = namedtuple('from_to', 'from_ to') lowerCAmelCase_ = { 'cubicmeter': from_to(1, 1), 'litre': from_to(0.0_0_1, 1_000), 'kilolitre': from_to(1, 1), 'gallon': from_to(0.0_0_4_5_4,...
122
"""simple docstring""" 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, SwinC...
122
1
"""simple docstring""" import gzip import hashlib import json import multiprocessing import os import re import shutil import time from pathlib import Path import numpy as np from arguments import PreprocessingArguments from datasets import load_dataset from minhash_deduplication im...
522
'''simple docstring''' from ..utils import DummyObject, requires_backends class lowerCamelCase ( metaclass=lowerCamelCase ): '''simple docstring''' lowerCAmelCase__ = ['''onnx'''] def __init__( self : List[Any] , *UpperCAmelCase__ : Union[...
390
0
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available __a: Optional[Any] = { """configuration_maskformer""": ["""MASKFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MaskFormerConfig"""], """co...
428
'''simple docstring''' from typing import TYPE_CHECKING from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available __a: Tuple = { """configuration_m2m_100""": ["""M2M_100_PRETRAINED_CONFIG_ARCHIVE_MAP""", """M2M100Config""", """M2M100OnnxConfig"""],...
428
1
from __future__ import annotations from decimal import Decimal from numpy import array def __a ( A__ : list[list[float]] ): SCREAMING_SNAKE_CASE = Decimal # Check if the provided matrix has 2 rows and 2 columns # since this implementation only works fo...
16
'''simple docstring''' import warnings from ...utils import logging from .image_processing_chinese_clip import ChineseCLIPImageProcessor snake_case_ = logging.get_logger(__name__) class SCREAMING_SNAKE_CASE__ ( _UpperCAmelCase ): def __init__( self ,...
421
0
import string from math import logaa def lowerCamelCase__ ( _A , _A ): '''simple docstring''' snake_case_ = document.translate( str.maketrans("" , "" , string.punctuation ) ).replace("\n" , "" ) snake_case_ = docum...
139
from __future__ import annotations from collections import namedtuple from dataclasses import dataclass @dataclass class UpperCAmelCase : '''simple docstring''' lowerCAmelCase_ = 42 lowerCAmelCase_ = None lowerCAmelCase_ = None ...
139
1
'''simple docstring''' def __magic_name__ ( __UpperCAmelCase , __UpperCAmelCase , __UpperCAmelCase=False ) -> Tuple: '''simple docstring''' if isinstance(__UpperCAmelCase , __UpperCAmelCase ) and isinstance(__UpperCAmelCase , __UpperCAmelCas...
109
"""simple docstring""" from arguments import InitializationArguments from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, HfArgumentParser # Configuration SCREAMING_SNAKE_CASE__:str = HfArgumentParser(InitializationArguments) SCREAMING_SNAKE_CASE__:List[str] = parser.parse...
528
0
import json from typing import List, Optional, Tuple from tokenizers import normalizers from ...tokenization_utils_fast import PreTrainedTokenizerFast from ...utils import logging from .tokenization_bert import BertTokenizer lowerCamelCase =logging.get_logger(__name__) lowerCamelCase ={"vocab_file": "vo...
462
import argparse import json import os import torch from transformers.file_utils import has_file from diffusers import UNetaDConditionModel, UNetaDModel lowerCamelCase =False lowerCamelCase =True lowerCamelCase =False if __name__ == "__main__": lowerCamelCase =argparse.ArgumentParser() ...
462
1
"""simple docstring""" 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_...
52
'''simple docstring''' from ...processing_utils import ProcessorMixin from ...tokenization_utils_base import BatchEncoding class _SCREAMING_SNAKE_CASE ( __a ): __SCREAMING_SNAKE_CASE :Optional[int] = """ClapFeatureExtractor""" __SCREAMING_SNAKE_CASE :List[Any] = ("""Robe...
432
0
import math import os import unittest from transformers import MegatronBertConfig, is_torch_available from transformers.models.auto import get_values from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device from ...test_configuration_common import ConfigT...
142
import argparse from torch import nn # transformers_old should correspond to branch `save_old_prophetnet_model_structure` here # original prophetnet_checkpoints are saved under `patrickvonplaten/..._old` respectively from transformers_old.modeling_prophetnet import ( ProphetNetForConditionalGeneration as Prop...
142
1