


"""simple docstring"""

import inspect
import unittest

from datasets import load_dataset
from packaging import version

from transformers import BeitConfig
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, require_torch_multi_gpu, require_vision, slow, torch_device
from transformers.utils import cached_property, is_torch_available, is_vision_available

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
       import torch
       from torch import nn

       from transformers import (
           MODEL_MAPPING,
           BeitForImageClassification,
           BeitForMaskedImageModeling,
           BeitForSemanticSegmentation,
           BeitModel,
       )
       from transformers.models.beit.modeling_beit import BEIT_PRETRAINED_MODEL_ARCHIVE_LIST


if is_vision_available():
       import PIL
       from PIL import Image

       from transformers import BeitImageProcessor





class  lowerCamelCase__    :
      def __init__(		self						:						Optional[Any]   ,							A_						:						Optional[Any]   ,							A_						:						Any=1_0_0   ,							A_						:						int=1_3   ,							A_						:						int=3_0   ,							A_						:						Tuple=2   ,							A_						:						List[Any]=3   ,							A_						:						Optional[int]=True   ,							A_						:						Optional[Any]=True   ,							A_						:						Tuple=3_2   ,							A_						:						int=4   ,							A_						:						Optional[Any]=4   ,							A_						:						int=3_7   ,							A_						:						Any="gelu"   ,							A_						:						str=0.1   ,							A_						:						Optional[Any]=0.1   ,							A_						:						int=1_0   ,							A_						:						List[str]=0.02   ,							A_						:						Optional[Any]=3   ,							A_						:						Optional[Any]=None   ,							A_						:						int=[0, 1, 2, 3]   ,							):






       '''simple docstring'''


       __lowercase						=						parent
       __lowercase						=						1_0_0
       __lowercase						=						batch_size
       __lowercase						=						image_size
       __lowercase						=						patch_size
       __lowercase						=						num_channels
       __lowercase						=						is_training
       __lowercase						=						use_labels
       __lowercase						=						hidden_size
       __lowercase						=						num_hidden_layers
       __lowercase						=						num_attention_heads
       __lowercase						=						intermediate_size
       __lowercase						=						hidden_act
       __lowercase						=						hidden_dropout_prob
       __lowercase						=						attention_probs_dropout_prob
       __lowercase						=						type_sequence_label_size
       __lowercase						=						initializer_range
       __lowercase						=						scope
       __lowercase						=						out_indices
       __lowercase						=						num_labels

       # in BeiT, the seq length equals the number of patches + 1 (we add 1 for the [CLS] token)
       __lowercase						=						(image_size // patch_size) ** 2
       __lowercase						=						num_patches + 1
      def SCREAMING_SNAKE_CASE_						(		self						:						Optional[int]				):






       '''simple docstring'''


       __lowercase						=						floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]				)

       __lowercase						=						None
       __lowercase						=						None
       if self.use_labels:
        __lowercase						=						ids_tensor([self.batch_size]   ,							self.type_sequence_label_size				)
        __lowercase						=						ids_tensor([self.batch_size, self.image_size, self.image_size]   ,							self.num_labels				)

       __lowercase						=						self.get_config()

       return config, pixel_values, labels, pixel_labels
      def SCREAMING_SNAKE_CASE_						(		self						:						Dict				):






       '''simple docstring'''


       return BeitConfig(
           vocab_size=self.vocab_size   ,							image_size=self.image_size   ,							patch_size=self.patch_size   ,							num_channels=self.num_channels   ,							hidden_size=self.hidden_size   ,							num_hidden_layers=self.num_hidden_layers   ,							num_attention_heads=self.num_attention_heads   ,							intermediate_size=self.intermediate_size   ,							hidden_act=self.hidden_act   ,							hidden_dropout_prob=self.hidden_dropout_prob   ,							attention_probs_dropout_prob=self.attention_probs_dropout_prob   ,							is_decoder=A_   ,							initializer_range=self.initializer_range   ,							out_indices=self.out_indices   ,							)
      def SCREAMING_SNAKE_CASE_						(		self						:						Any   ,							A_						:						str   ,							A_						:						int   ,							A_						:						str   ,							A_						:						Optional[Any]				):






       '''simple docstring'''


       __lowercase						=						BeitModel(config=A_				)
       model.to(A_				)
       model.eval()
       __lowercase						=						model(A_				)
       self.parent.assertEqual(result.last_hidden_state.shape   ,							(self.batch_size, self.seq_length, self.hidden_size)				)
      def SCREAMING_SNAKE_CASE_						(		self						:						str   ,							A_						:						List[str]   ,							A_						:						List[Any]   ,							A_						:						List[Any]   ,							A_						:						List[Any]				):






       '''simple docstring'''


       __lowercase						=						BeitForMaskedImageModeling(config=A_				)
       model.to(A_				)
       model.eval()
       __lowercase						=						model(A_				)
       self.parent.assertEqual(result.logits.shape   ,							(self.batch_size, self.seq_length - 1, self.vocab_size)				)
      def SCREAMING_SNAKE_CASE_						(		self						:						List[Any]   ,							A_						:						Tuple   ,							A_						:						List[Any]   ,							A_						:						str   ,							A_						:						Optional[Any]				):






       '''simple docstring'''


       __lowercase						=						self.type_sequence_label_size
       __lowercase						=						BeitForImageClassification(A_				)
       model.to(A_				)
       model.eval()
       __lowercase						=						model(A_   ,							labels=A_				)
       self.parent.assertEqual(result.logits.shape   ,							(self.batch_size, self.type_sequence_label_size)				)

       # test greyscale images
       __lowercase						=						1
       __lowercase						=						BeitForImageClassification(A_				)
       model.to(A_				)
       model.eval()

       __lowercase						=						floats_tensor([self.batch_size, 1, self.image_size, self.image_size]				)
       __lowercase						=						model(A_   ,							labels=A_				)
       self.parent.assertEqual(result.logits.shape   ,							(self.batch_size, self.type_sequence_label_size)				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Optional[Any]   ,							A_						:						Any   ,							A_						:						Any   ,							A_						:						str   ,							A_						:						Tuple				):






       '''simple docstring'''


       __lowercase						=						self.num_labels
       __lowercase						=						BeitForSemanticSegmentation(A_				)
       model.to(A_				)
       model.eval()
       __lowercase						=						model(A_				)
       self.parent.assertEqual(
           result.logits.shape   ,							(self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)				)
       __lowercase						=						model(A_   ,							labels=A_				)
       self.parent.assertEqual(
           result.logits.shape   ,							(self.batch_size, self.num_labels, self.image_size * 2, self.image_size * 2)				)






      def SCREAMING_SNAKE_CASE_						(		self						:						Tuple				):






       '''simple docstring'''


       __lowercase						=						self.prepare_config_and_inputs()
       __lowercase				,		__lowercase				,		__lowercase				,		__lowercase						=						config_and_inputs
       __lowercase						=						{"""pixel_values""": pixel_values}
       return config, inputs_dict






@require_torch
class  lowerCamelCase__    (		_a      , _a      , unittest.TestCase     ):
      a			:  List[Any]           =		(
          (BeitModel, BeitForImageClassification, BeitForMaskedImageModeling, BeitForSemanticSegmentation)
          if is_torch_available()
          else ()
      )
      a			:  Dict           =		(
          {
              """feature-extraction""": BeitModel,
              """image-classification""": BeitForImageClassification,
              """image-segmentation""": BeitForSemanticSegmentation,
          }
          if is_torch_available()
          else {}
      )

      a			:  Tuple           =		False
      a			:  List[str]           =		False
      a			:  int           =		False
      def SCREAMING_SNAKE_CASE_						(		self						:						Tuple				):






       '''simple docstring'''


       __lowercase						=						BeitModelTester(self				)
       __lowercase						=						ConfigTester(self   ,							config_class=A_   ,							has_text_modality=A_   ,							hidden_size=3_7				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Dict				):






       '''simple docstring'''


       self.config_tester.run_common_tests()
      @unittest.skip(reason="""BEiT does not use inputs_embeds"""				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Union[str, Any]				):






       '''simple docstring'''


       pass
      @require_torch_multi_gpu
      @unittest.skip(reason="""BEiT has some layers using `add_module` which doesn't work well with `nn.DataParallel`"""				)
      def SCREAMING_SNAKE_CASE_						(		self						:						List[Any]				):






       '''simple docstring'''


       pass
      def SCREAMING_SNAKE_CASE_						(		self						:						str				):






       '''simple docstring'''


       __lowercase				,		__lowercase						=						self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
        __lowercase						=						model_class(A_				)
        self.assertIsInstance(model.get_input_embeddings()   ,							(nn.Module)				)
        __lowercase						=						model.get_output_embeddings()
        self.assertTrue(x is None or isinstance(A_   ,							nn.Linear				)				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Tuple				):






       '''simple docstring'''


       __lowercase				,		__lowercase						=						self.model_tester.prepare_config_and_inputs_for_common()

       for model_class in self.all_model_classes:
        __lowercase						=						model_class(A_				)
        __lowercase						=						inspect.signature(model.forward				)
        # signature.parameters is an OrderedDict => so arg_names order is deterministic
        __lowercase						=						[*signature.parameters.keys()]

        __lowercase						=						["""pixel_values"""]
        self.assertListEqual(arg_names[:1]   ,							A_				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Union[str, Any]				):






       '''simple docstring'''


       __lowercase						=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*A_				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Optional[Any]				):






       '''simple docstring'''


       __lowercase						=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_lm(*A_				)
      def SCREAMING_SNAKE_CASE_						(		self						:						int				):






       '''simple docstring'''


       __lowercase						=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_image_classification(*A_				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Any				):






       '''simple docstring'''


       __lowercase						=						self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_semantic_segmentation(*A_				)
      def SCREAMING_SNAKE_CASE_						(		self						:						Union[str, Any]				):






       '''simple docstring'''


       if not self.model_tester.is_training:
        return

       __lowercase				,		__lowercase						=						self.model_tester.prepare_config_and_inputs_for_common()
       __lowercase						=						True

       for model_class in self.all_model_classes:
        # we don't test BeitForMaskedImageModeling
        if model_class in [*get_values(A_				), BeitForMaskedImageModeling]:
         continue

        __lowercase						=						model_class(A_				)
        model.to(A_				)
        model.train()
        __lowercase						=						self._prepare_for_class(A_   ,							A_   ,							return_labels=A_				)
        __lowercase						=						model(**A_				).loss
        loss.backward()
      def SCREAMING_SNAKE_CASE_						(		self						:						Optional[int]				):






       '''simple docstring'''


       __lowercase				,		__lowercase						=						self.model_tester.prepare_config_and_inputs_for_common()
       if not self.model_tester.is_training:
        return

       __lowercase						=						False
       __lowercase						=						True

       for model_class in self.all_model_classes:
        # we don't test BeitForMaskedImageModeling
        if (
            model_class in [*get_values(A_				), BeitForMaskedImageModeling]
            or not model_class.supports_gradient_checkpointing
        ):
         continue

        __lowercase						=						model_class(A_				)
        model.gradient_checkpointing_enable()
        model.to(A_				)
        model.train()
        __lowercase						=						self._prepare_for_class(A_   ,							A_   ,							return_labels=A_				)
        __lowercase						=						model(**A_				).loss
        loss.backward()
      def SCREAMING_SNAKE_CASE_						(		self						:						int				):






       '''simple docstring'''


       __lowercase				,		__lowercase						=						self.model_tester.prepare_config_and_inputs_for_common()

       __lowercase						=						_config_zero_init(A_				)
       for model_class in self.all_model_classes:
        __lowercase						=						model_class(config=A_				)
        for name, param in model.named_parameters():
         # we skip lambda parameters as these require special initial values
         # determined by config.layer_scale_init_value
         if "lambda" in name:
          continue
         if param.requires_grad:
          self.assertIn(
              ((param.data.mean() * 1e9).round() / 1e9).item()   ,							[0.0, 1.0]   ,							msg=F'''Parameter {name} of model {model_class} seems not properly initialized'''   ,							)






      @slow
      def SCREAMING_SNAKE_CASE_						(		self						:						Optional[int]				):






       '''simple docstring'''


       for model_name in BEIT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
        __lowercase						=						BeitModel.from_pretrained(A_				)
        self.assertIsNotNone(A_				)






def lowerCAmelCase_   (					):






 """simple docstring"""







 __lowercase						=						Image.open("""./tests/fixtures/tests_samples/COCO/000000039769.png"""			)
 return image





@require_torch
@require_vision
class  lowerCamelCase__    (		unittest.TestCase     ):
      @cached_property
      def SCREAMING_SNAKE_CASE_						(		self						:						Any				):






       '''simple docstring'''


       return BeitImageProcessor.from_pretrained("""microsoft/beit-base-patch16-224"""				) if is_vision_available() else None
      @slow
      def SCREAMING_SNAKE_CASE_						(		self						:						Union[str, Any]				):






       '''simple docstring'''


       __lowercase						=						BeitForMaskedImageModeling.from_pretrained("""microsoft/beit-base-patch16-224-pt22k"""				).to(A_				)

       __lowercase						=						self.default_image_processor
       __lowercase						=						prepare_img()
       __lowercase						=						image_processor(images=A_   ,							return_tensors="""pt"""				).pixel_values.to(A_				)

       # prepare bool_masked_pos
       __lowercase						=						torch.ones((1, 1_9_6)   ,							dtype=torch.bool				).to(A_				)

       # forward pass
       with torch.no_grad():
        __lowercase						=						model(pixel_values=A_   ,							bool_masked_pos=A_				)
       __lowercase						=						outputs.logits

       # verify the logits
       __lowercase						=						torch.Size((1, 1_9_6, 8_1_9_2)				)
       self.assertEqual(logits.shape   ,							A_				)

       __lowercase						=						torch.tensor(
           [[-3.24_37, 0.50_72, -13.91_74], [-3.24_56, 0.49_48, -13.94_01], [-3.20_33, 0.51_21, -13.85_50]]				).to(A_				)

       self.assertTrue(torch.allclose(logits[bool_masked_pos][:3, :3]   ,							A_   ,							atol=1e-2				)				)
      @slow
      def SCREAMING_SNAKE_CASE_						(		self						:						Tuple				):






       '''simple docstring'''


       __lowercase						=						BeitForImageClassification.from_pretrained("""microsoft/beit-base-patch16-224"""				).to(A_				)

       __lowercase						=						self.default_image_processor
       __lowercase						=						prepare_img()
       __lowercase						=						image_processor(images=A_   ,							return_tensors="""pt"""				).to(A_				)

       # forward pass
       with torch.no_grad():
        __lowercase						=						model(**A_				)
       __lowercase						=						outputs.logits

       # verify the logits
       __lowercase						=						torch.Size((1, 1_0_0_0)				)
       self.assertEqual(logits.shape   ,							A_				)

       __lowercase						=						torch.tensor([-1.23_85, -1.09_87, -1.01_08]				).to(A_				)

       self.assertTrue(torch.allclose(logits[0, :3]   ,							A_   ,							atol=1e-4				)				)

       __lowercase						=						2_8_1
       self.assertEqual(logits.argmax(-1				).item()   ,							A_				)
      @slow
      def SCREAMING_SNAKE_CASE_						(		self						:						Any				):






       '''simple docstring'''


       __lowercase						=						BeitForImageClassification.from_pretrained("""microsoft/beit-large-patch16-224-pt22k-ft22k"""				).to(
           A_				)

       __lowercase						=						self.default_image_processor
       __lowercase						=						prepare_img()
       __lowercase						=						image_processor(images=A_   ,							return_tensors="""pt"""				).to(A_				)

       # forward pass
       with torch.no_grad():
        __lowercase						=						model(**A_				)
       __lowercase						=						outputs.logits

       # verify the logits
       __lowercase						=						torch.Size((1, 2_1_8_4_1)				)
       self.assertEqual(logits.shape   ,							A_				)

       __lowercase						=						torch.tensor([1.68_81, -0.27_87, 0.59_01]				).to(A_				)

       self.assertTrue(torch.allclose(logits[0, :3]   ,							A_   ,							atol=1e-4				)				)

       __lowercase						=						2_3_9_6
       self.assertEqual(logits.argmax(-1				).item()   ,							A_				)
      @slow
      def SCREAMING_SNAKE_CASE_						(		self						:						List[str]				):






       '''simple docstring'''


       __lowercase						=						BeitForSemanticSegmentation.from_pretrained("""microsoft/beit-base-finetuned-ade-640-640"""				)
       __lowercase						=						model.to(A_				)

       __lowercase						=						BeitImageProcessor(do_resize=A_   ,							size=6_4_0   ,							do_center_crop=A_				)

       __lowercase						=						load_dataset("""hf-internal-testing/fixtures_ade20k"""   ,							split="""test"""				)
       __lowercase						=						Image.open(ds[0]["""file"""]				)
       __lowercase						=						image_processor(images=A_   ,							return_tensors="""pt"""				).to(A_				)

       # forward pass
       with torch.no_grad():
        __lowercase						=						model(**A_				)
       __lowercase						=						outputs.logits

       # verify the logits
       __lowercase						=						torch.Size((1, 1_5_0, 1_6_0, 1_6_0)				)
       self.assertEqual(logits.shape   ,							A_				)

       __lowercase						=						version.parse(PIL.__version__				) < version.parse("""9.0.0"""				)

       if is_pillow_less_than_a:
        __lowercase						=						torch.tensor(
            [
                [[-4.92_25, -2.39_54, -3.05_22], [-2.88_22, -1.00_46, -1.75_61], [-2.95_49, -1.32_28, -2.13_47]],
                [[-5.81_68, -3.41_29, -4.07_78], [-3.86_51, -2.22_14, -3.02_77], [-3.83_56, -2.46_43, -3.35_35]],
                [[-0.00_78, 3.99_52, 4.07_54], [2.98_56, 4.69_44, 5.00_35], [3.24_13, 4.78_13, 4.99_69]],
            ]   ,							device=A_   ,							)
       else:
        __lowercase						=						torch.tensor(
            [
                [[-4.89_60, -2.36_88, -3.03_55], [-2.84_78, -0.98_36, -1.74_18], [-2.94_49, -1.33_32, -2.14_56]],
                [[-5.80_81, -3.41_24, -4.10_06], [-3.85_61, -2.20_81, -3.03_23], [-3.83_65, -2.46_01, -3.36_69]],
                [[-0.03_09, 3.98_68, 4.05_40], [2.96_40, 4.68_77, 4.99_76], [3.20_81, 4.76_90, 4.99_42]],
            ]   ,							device=A_   ,							)

       self.assertTrue(torch.allclose(logits[0, :3, :3, :3]   ,							A_   ,							atol=1e-4				)				)






      @slow
      def SCREAMING_SNAKE_CASE_						(		self						:						List[Any]				):






       '''simple docstring'''


       __lowercase						=						BeitForSemanticSegmentation.from_pretrained("""microsoft/beit-base-finetuned-ade-640-640"""				)
       __lowercase						=						model.to(A_				)

       __lowercase						=						BeitImageProcessor(do_resize=A_   ,							size=6_4_0   ,							do_center_crop=A_				)

       __lowercase						=						load_dataset("""hf-internal-testing/fixtures_ade20k"""   ,							split="""test"""				)
       __lowercase						=						Image.open(ds[0]["""file"""]				)
       __lowercase						=						image_processor(images=A_   ,							return_tensors="""pt"""				).to(A_				)

       # forward pass
       with torch.no_grad():
        __lowercase						=						model(**A_				)

       __lowercase						=						outputs.logits.detach().cpu()

       __lowercase						=						image_processor.post_process_semantic_segmentation(outputs=A_   ,							target_sizes=[(5_0_0, 3_0_0)]				)
       __lowercase						=						torch.Size((5_0_0, 3_0_0)				)
       self.assertEqual(segmentation[0].shape   ,							A_				)

       __lowercase						=						image_processor.post_process_semantic_segmentation(outputs=A_				)
       __lowercase						=						torch.Size((1_6_0, 1_6_0)				)
       self.assertEqual(segmentation[0].shape   ,							A_				)




"""simple docstring"""

import copy
from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


if TYPE_CHECKING:
       from ... import PreTrainedTokenizerBase, TensorType

UpperCAmelCase__					=logging.get_logger(__name__)





class  lowerCamelCase__    (		_a     ):
      a			:  Optional[int]           =		"""vision-encoder-decoder"""
      a			:  Dict           =		True
      def __init__(		self						:						Dict   ,							**A_						:						List[Any]				):






       '''simple docstring'''


       super().__init__(**A_				)
       if "encoder" not in kwargs or "decoder" not in kwargs:
        raise ValueError(
            F'''A configuraton of type {self.model_type} cannot be instantiated because '''
            F'''not both `encoder` and `decoder` sub-configurations are passed, but only {kwargs}'''				)

       __lowercase						=						kwargs.pop("""encoder"""				)
       __lowercase						=						encoder_config.pop("""model_type"""				)
       __lowercase						=						kwargs.pop("""decoder"""				)
       __lowercase						=						decoder_config.pop("""model_type"""				)

       __lowercase						=						AutoConfig.for_model(A_   ,							**A_				)
       __lowercase						=						AutoConfig.for_model(A_   ,							**A_				)
       __lowercase						=						True
      @classmethod
      def SCREAMING_SNAKE_CASE_						(		cls						:						int   ,							A_						:						PretrainedConfig   ,							A_						:						PretrainedConfig   ,							**A_						:						Any				):






       '''simple docstring'''


       logger.info("""Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"""				)
       __lowercase						=						True
       __lowercase						=						True

       return cls(encoder=encoder_config.to_dict()   ,							decoder=decoder_config.to_dict()   ,							**A_				)






      def SCREAMING_SNAKE_CASE_						(		self						:						Union[str, Any]				):






       '''simple docstring'''


       __lowercase						=						copy.deepcopy(self.__dict__				)
       __lowercase						=						self.encoder.to_dict()
       __lowercase						=						self.decoder.to_dict()
       __lowercase						=						self.__class__.model_type
       return output






class  lowerCamelCase__    (		_a     ):
      a			:  Dict           =		version.parse("""1.11"""     )
      @property
      def SCREAMING_SNAKE_CASE_						(		self						:						Optional[int]				):






       '''simple docstring'''


       return OrderedDict(
           [
               ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
           ]				)
      @property
      def SCREAMING_SNAKE_CASE_						(		self						:						Tuple				):






       '''simple docstring'''


       return 1e-4






      @property
      def SCREAMING_SNAKE_CASE_						(		self						:						Any				):






       '''simple docstring'''


       return OrderedDict({"""last_hidden_state""": {0: """batch""", 1: """encoder_sequence"""}}				)






class  lowerCamelCase__    (		_a     ):
      @property
      def SCREAMING_SNAKE_CASE_						(		self						:						Dict				):






       '''simple docstring'''


       __lowercase						=						OrderedDict()
       __lowercase						=						{0: """batch""", 1: """past_decoder_sequence + sequence"""}
       __lowercase						=						{0: """batch""", 1: """past_decoder_sequence + sequence"""}
       __lowercase						=						{0: """batch""", 1: """encoder_sequence"""}

       return common_inputs






      def SCREAMING_SNAKE_CASE_						(		self						:						str   ,							A_						:						"PreTrainedTokenizerBase"   ,							A_						:						int = -1   ,							A_						:						int = -1   ,							A_						:						bool = False   ,							A_						:						Optional["TensorType"] = None   ,							):






       '''simple docstring'''


       import torch

       __lowercase						=						OrderedDict()

       __lowercase						=						super().generate_dummy_inputs(
           A_   ,							batch_size=A_   ,							seq_length=A_   ,							is_pair=A_   ,							framework=A_				)

       __lowercase				,		__lowercase						=						dummy_input["""input_ids"""].shape
       __lowercase						=						(batch, encoder_sequence, self._config.encoder_hidden_size)
       __lowercase						=						dummy_input.pop("""input_ids"""				)
       __lowercase						=						dummy_input.pop("""attention_mask"""				)
       __lowercase						=						torch.zeros(A_				)

       return common_inputs






class  lowerCamelCase__    (		_a     ):
      @property
      def SCREAMING_SNAKE_CASE_						(		self						:						str				):






       '''simple docstring'''


       pass
      def SCREAMING_SNAKE_CASE_						(		self						:						str   ,							A_						:						PretrainedConfig				):






       '''simple docstring'''


       return VisionEncoderDecoderEncoderOnnxConfig(A_				)






      def SCREAMING_SNAKE_CASE_						(		self						:						Tuple   ,							A_						:						PretrainedConfig   ,							A_						:						PretrainedConfig   ,							A_						:						str = "default"				):






       '''simple docstring'''


       __lowercase						=						encoder_config.hidden_size
       return VisionEncoderDecoderDecoderOnnxConfig(A_   ,							A_				)
