import copy

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


UpperCAmelCase      		=					logging.get_logger(__name__)




class  __lowerCAmelCase	(							a_    ):



 '''simple docstring'''
 _lowerCamelCase    :						Optional[int]					     =			'speech-encoder-decoder'
 _lowerCamelCase    :						str					     =			True

 def __init__(      self							:		int							,      **lowerCamelCase							:		Optional[Any]	)			->				Optional[int]:
        super().__init__(**lowerCamelCase	)
        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  :							Any	    =	kwargs.pop('encoder'	)
        _UpperCamelCase  :							List[Any]	    =	encoder_config.pop('model_type'	)
        _UpperCamelCase  :							Union[str, Any]	    =	kwargs.pop('decoder'	)
        _UpperCamelCase  :							Optional[Any]	    =	decoder_config.pop('model_type'	)

        _UpperCamelCase  :							Dict	    =	AutoConfig.for_model(lowerCamelCase							,      **lowerCamelCase	)
        _UpperCamelCase  :							Dict	    =	AutoConfig.for_model(lowerCamelCase							,      **lowerCamelCase	)
        _UpperCamelCase  :							List[Any]	    =	True

 @classmethod
 def        __snake_case       (      cls							:		Union[str, Any]							,      lowerCamelCase							:		PretrainedConfig							,      lowerCamelCase							:		PretrainedConfig							,      **lowerCamelCase							:		Any	)			->				PretrainedConfig:
        logger.info('Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config'	)
        _UpperCamelCase  :							str	    =	True
        _UpperCamelCase  :							Optional[int]	    =	True

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

 def        __snake_case       (      self							:		List[Any]	)			->				Optional[Any]:
        _UpperCamelCase  :							Optional[Any]	    =	copy.deepcopy(self.__dict__	)
        _UpperCamelCase  :							List[Any]	    =	self.encoder.to_dict()
        _UpperCamelCase  :							Optional[Any]	    =	self.decoder.to_dict()
        _UpperCamelCase  :							List[Any]	    =	self.__class__.model_type
        return output




from typing import TYPE_CHECKING

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


snake_case__						      =			{
    'configuration_dpr': ['DPR_PRETRAINED_CONFIG_ARCHIVE_MAP', 'DPRConfig'],
    'tokenization_dpr': [
        'DPRContextEncoderTokenizer',
        'DPRQuestionEncoderTokenizer',
        'DPRReaderOutput',
        'DPRReaderTokenizer',
    ],
}


try:
     if not is_tokenizers_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     snake_case__						      =			[
         'DPRContextEncoderTokenizerFast',
         'DPRQuestionEncoderTokenizerFast',
         'DPRReaderTokenizerFast',
     ]

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     snake_case__						      =			[
         'DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST',
         'DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST',
         'DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST',
         'DPRContextEncoder',
         'DPRPretrainedContextEncoder',
         'DPRPreTrainedModel',
         'DPRPretrainedQuestionEncoder',
         'DPRPretrainedReader',
         'DPRQuestionEncoder',
         'DPRReader',
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     snake_case__						      =			[
         'TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST',
         'TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST',
         'TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST',
         'TFDPRContextEncoder',
         'TFDPRPretrainedContextEncoder',
         'TFDPRPretrainedQuestionEncoder',
         'TFDPRPretrainedReader',
         'TFDPRQuestionEncoder',
         'TFDPRReader',
     ]


if TYPE_CHECKING:
     from .configuration_dpr import DPR_PRETRAINED_CONFIG_ARCHIVE_MAP, DPRConfig
     from .tokenization_dpr import (
         DPRContextEncoderTokenizer,
         DPRQuestionEncoderTokenizer,
         DPRReaderOutput,
         DPRReaderTokenizer,
     )

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_dpr_fast import (
              DPRContextEncoderTokenizerFast,
              DPRQuestionEncoderTokenizerFast,
              DPRReaderTokenizerFast,
          )

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_dpr import (
              DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
              DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
              DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
              DPRContextEncoder,
              DPRPretrainedContextEncoder,
              DPRPreTrainedModel,
              DPRPretrainedQuestionEncoder,
              DPRPretrainedReader,
              DPRQuestionEncoder,
              DPRReader,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_dpr import (
              TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
              TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
              TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
              TFDPRContextEncoder,
              TFDPRPretrainedContextEncoder,
              TFDPRPretrainedQuestionEncoder,
              TFDPRPretrainedReader,
              TFDPRQuestionEncoder,
              TFDPRReader,
          )

else:
     import sys

     snake_case__						      =			_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)