




import copy

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


a_      						=   logging.get_logger(__name__)

class        _lowerCamelCase  (	_SCREAMING_SNAKE_CASE      ):

      """simple docstring"""

      lowerCAmelCase__	:       Tuple			=    "speech-encoder-decoder"
      lowerCAmelCase__	:       int			=    True







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

          __UpperCamelCase     						=  kwargs.pop('''encoder''' )
          __UpperCamelCase     						=  encoder_config.pop('''model_type''' )
          __UpperCamelCase     						=  kwargs.pop('''decoder''' )
          __UpperCamelCase     						=  decoder_config.pop('''model_type''' )

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







      @classmethod
      def 					snake_case		(   cls    :       int       ,				snake_case    :       PretrainedConfig       ,				snake_case    :       PretrainedConfig       ,				**snake_case    :       int ):
          logger.info('''Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config''' )
          __UpperCamelCase     						=  True
          __UpperCamelCase     						=  True

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







      def 					snake_case		(   self    :       int ):
          __UpperCamelCase     						=  copy.deepcopy(self.__dict__ )
          __UpperCamelCase     						=  self.encoder.to_dict()
          __UpperCamelCase     						=  self.decoder.to_dict()
          __UpperCamelCase     						=  self.__class__.model_type
          return output









from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


UpperCamelCase__     :					Dict								=			{
    "configuration_donut_swin": ["DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP", "DonutSwinConfig"],
    "processing_donut": ["DonutProcessor"],
}

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCamelCase__     :					Optional[int]								=			[
           "DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST",
           "DonutSwinModel",
           "DonutSwinPreTrainedModel",
       ]

try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCamelCase__     :					List[Any]								=			["DonutFeatureExtractor"]
       UpperCamelCase__     :					Dict								=			["DonutImageProcessor"]


if TYPE_CHECKING:
       from .configuration_donut_swin import DONUT_SWIN_PRETRAINED_CONFIG_ARCHIVE_MAP, DonutSwinConfig
       from .processing_donut import DonutProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_donut_swin import (
                  DONUT_SWIN_PRETRAINED_MODEL_ARCHIVE_LIST,
                  DonutSwinModel,
                  DonutSwinPreTrainedModel,
              )

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .feature_extraction_donut import DonutFeatureExtractor
              from .image_processing_donut import DonutImageProcessor

else:
       import sys

       UpperCamelCase__     :					Tuple								=			_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)


