


'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


lowercase__				     =		{
    "configuration_blip": [
        "BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "BlipConfig",
        "BlipTextConfig",
        "BlipVisionConfig",
    ],
    "processing_blip": ["BlipProcessor"],
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__				     =		["BlipImageProcessor"]


try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__				     =		[
       "BLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
       "BlipModel",
       "BlipPreTrainedModel",
       "BlipForConditionalGeneration",
       "BlipForQuestionAnswering",
       "BlipVisionModel",
       "BlipTextModel",
       "BlipForImageTextRetrieval",
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   lowercase__				     =		[
       "TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST",
       "TFBlipModel",
       "TFBlipPreTrainedModel",
       "TFBlipForConditionalGeneration",
       "TFBlipForQuestionAnswering",
       "TFBlipVisionModel",
       "TFBlipTextModel",
       "TFBlipForImageTextRetrieval",
   ]

if TYPE_CHECKING:
   from .configuration_blip import BLIP_PRETRAINED_CONFIG_ARCHIVE_MAP, BlipConfig, BlipTextConfig, BlipVisionConfig
   from .processing_blip import BlipProcessor

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .image_processing_blip import BlipImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_blip import (
          BLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
          BlipForConditionalGeneration,
          BlipForImageTextRetrieval,
          BlipForQuestionAnswering,
          BlipModel,
          BlipPreTrainedModel,
          BlipTextModel,
          BlipVisionModel,
      )

   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_blip import (
          TF_BLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFBlipForConditionalGeneration,
          TFBlipForImageTextRetrieval,
          TFBlipForQuestionAnswering,
          TFBlipModel,
          TFBlipPreTrainedModel,
          TFBlipTextModel,
          TFBlipVisionModel,
      )

else:
   import sys

   lowercase__				     =		_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





'''simple docstring'''

import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowercase__				     =		logging.get_logger(__name__)





class 						__SCREAMING_SNAKE_CASE					(      lowerCamelCase__ ):
     UpperCAmelCase 					=				'''encoder-decoder'''
     UpperCAmelCase 					=				True






     def __init__(			self     ,							**__UpperCamelCase		)       ->    List[Any]:
          super().__init__(**__UpperCamelCase		)
          assert (
              "encoder" in kwargs and "decoder" in kwargs
          ), "Config has to be initialized with encoder and decoder config"
          _a						=		kwargs.pop("encoder"		)
          _a						=		encoder_config.pop("model_type"		)
          _a						=		kwargs.pop("decoder"		)
          _a						=		decoder_config.pop("model_type"		)

          from ..auto.configuration_auto import AutoConfig

          _a						=		AutoConfig.for_model(__UpperCamelCase     ,							**__UpperCamelCase		)
          _a						=		AutoConfig.for_model(__UpperCamelCase     ,							**__UpperCamelCase		)
          _a						=		True






     @classmethod
     def  a_					(			cls     ,							__UpperCamelCase     ,							__UpperCamelCase     ,							**__UpperCamelCase		)       ->    PretrainedConfig:
          logger.info("Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"		)
          _a						=		True
          _a						=		True

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






     def  a_					(			self		)       ->    Any:
          _a						=		copy.deepcopy(self.__dict__		)
          _a						=		self.encoder.to_dict()
          _a						=		self.decoder.to_dict()
          _a						=		self.__class__.model_type
          return output

