




'''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

lowercase      :   int      =       logging.get_logger(__name__)







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     Dict          =					"""vision-encoder-decoder"""
     lowerCAmelCase_  :     str          =					True







     def __init__(				self							,**__a							)      ->				Optional[Any]:
          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}'''							)

          snake_case			:      List[Any]        =			kwargs.pop("""encoder"""							)
          snake_case			:      Any        =			encoder_config.pop("""model_type"""							)
          snake_case			:      Union[str, Any]        =			kwargs.pop("""decoder"""							)
          snake_case			:      Optional[int]        =			decoder_config.pop("""model_type"""							)

          snake_case			:      Optional[int]        =			AutoConfig.for_model(__a							,**__a							)
          snake_case			:      int        =			AutoConfig.for_model(__a							,**__a							)
          snake_case			:      Any        =			True







     @classmethod
     def 			snake_case_      (				cls							,__a							,__a							,**__a							)      ->				PretrainedConfig:
          logger.info("""Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"""							)
          snake_case			:      Tuple        =			True
          snake_case			:      int        =			True

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







     def 			snake_case_      (				self							)      ->				Optional[int]:
          snake_case			:      Any        =			copy.deepcopy(self.__dict__							)
          snake_case			:      Tuple        =			self.encoder.to_dict()
          snake_case			:      Optional[Any]        =			self.decoder.to_dict()
          snake_case			:      Optional[Any]        =			self.__class__.model_type
          return output







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     Optional[Any]          =					version.parse("""1.11"""	)







     @property
     def 			snake_case_      (				self							)      ->				Mapping[str, Mapping[int, str]]:
          return OrderedDict(
              [
                  ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
              ]							)







     @property
     def 			snake_case_      (				self							)      ->				float:
          return 1E-4







     @property
     def 			snake_case_      (				self							)      ->				Mapping[str, Mapping[int, str]]:
          return OrderedDict({"""last_hidden_state""": {0: """batch""", 1: """encoder_sequence"""}}							)







class 					_a (a__	):





     '''simple docstring'''



     @property
     def 			snake_case_      (				self							)      ->				Mapping[str, Mapping[int, str]]:
          snake_case			:      Optional[Any]        =			OrderedDict()
          snake_case			:      Any        =			{0: """batch""", 1: """past_decoder_sequence + sequence"""}
          snake_case			:      Optional[Any]        =			{0: """batch""", 1: """past_decoder_sequence + sequence"""}
          snake_case			:      Tuple        =			{0: """batch""", 1: """encoder_sequence"""}

          return common_inputs







     def 			snake_case_      (				self							,__a							,__a = -1							,__a = -1							,__a = False							,__a = None							,)      ->				Mapping[str, Any]:
          import torch

          snake_case			:      str        =			OrderedDict()

          snake_case			:      List[str]        =			super().generate_dummy_inputs(
              __a							,batch_size=__a							,seq_length=__a							,is_pair=__a							,framework=__a							)

          snake_case ,		snake_case			:      Any        =			dummy_input["""input_ids"""].shape
          snake_case			:      Dict        =			(batch, encoder_sequence, self._config.encoder_hidden_size)
          snake_case			:      Optional[Any]        =			dummy_input.pop("""input_ids"""							)
          snake_case			:      Dict        =			dummy_input.pop("""attention_mask"""							)
          snake_case			:      Any        =			torch.zeros(__a							)

          return common_inputs







class 					_a (a__	):





     '''simple docstring'''



     @property
     def 			snake_case_      (				self							)      ->				None:
          pass







     def 			snake_case_      (				self							,__a							)      ->				OnnxConfig:
          return VisionEncoderDecoderEncoderOnnxConfig(__a							)







     def 			snake_case_      (				self							,__a							,__a							,__a = "default"							)      ->				OnnxConfig:
          snake_case			:      Optional[Any]        =			encoder_config.hidden_size
          return VisionEncoderDecoderDecoderOnnxConfig(__a							,__a							)









'''simple docstring'''







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase      :   Union[str, Any]      =       {
    """configuration_instructblip""": [
        """INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """InstructBlipConfig""",
        """InstructBlipQFormerConfig""",
        """InstructBlipVisionConfig""",
    ],
    """processing_instructblip""": ["""InstructBlipProcessor"""],
}

try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      lowercase      :   Union[str, Any]      =       [
          """INSTRUCTBLIP_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """InstructBlipQFormerModel""",
          """InstructBlipPreTrainedModel""",
          """InstructBlipForConditionalGeneration""",
          """InstructBlipVisionModel""",
      ]

if TYPE_CHECKING:
      from .configuration_instructblip import (
          INSTRUCTBLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
          InstructBlipConfig,
          InstructBlipQFormerConfig,
          InstructBlipVisionConfig,
      )
      from .processing_instructblip import InstructBlipProcessor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_instructblip import (
                INSTRUCTBLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
                InstructBlipForConditionalGeneration,
                InstructBlipPreTrainedModel,
                InstructBlipQFormerModel,
                InstructBlipVisionModel,
            )

else:
      import sys

      lowercase      :   List[Any]      =       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



