



import copy

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


_UpperCamelCase							    =						logging.get_logger(__name__)






class  lowerCamelCase_   (    SCREAMING_SNAKE_CASE_					):
  """simple docstring"""




  a_							 ='speech-encoder-decoder'
  a_							 =True




  def __init__(			self				:     Union[str, Any]      ,     **_a				:     Any       ) -> Optional[int]:
    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 not both `encoder` and'
          f' `decoder` sub-configurations are passed, but only {kwargs}'       )

    __lowerCamelCase	:	int   	=			kwargs.pop('encoder'       )
    __lowerCamelCase	:	Optional[int]   	=			encoder_config.pop('model_type'       )
    __lowerCamelCase	:	Union[str, Any]   	=			kwargs.pop('decoder'       )
    __lowerCamelCase	:	Tuple   	=			decoder_config.pop('model_type'       )

    __lowerCamelCase	:	Optional[Any]   	=			AutoConfig.for_model(_a      ,     **_a       )
    __lowerCamelCase	:	Any   	=			AutoConfig.for_model(_a      ,     **_a       )
    __lowerCamelCase	:	List[str]   	=			True




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

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




  def 						_lowercase					(			self				:     Union[str, Any]       ) -> Union[str, Any]:
    __lowerCamelCase	:	Union[str, Any]   	=			copy.deepcopy(self.__dict__       )
    __lowerCamelCase	:	List[Any]   	=			self.encoder.to_dict()
    __lowerCamelCase	:	Union[str, Any]   	=			self.decoder.to_dict()
    __lowerCamelCase	:	Dict   	=			self.__class__.model_type
    return output











'''simple docstring'''





from typing import TYPE_CHECKING

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


_UpperCamelCase							    =						{
    'configuration_imagegpt': ['IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'ImageGPTConfig', 'ImageGPTOnnxConfig']
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase							    =						['ImageGPTFeatureExtractor']
   _UpperCamelCase							    =						['ImageGPTImageProcessor']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCamelCase							    =						[
       'IMAGEGPT_PRETRAINED_MODEL_ARCHIVE_LIST',
       'ImageGPTForCausalImageModeling',
       'ImageGPTForImageClassification',
       'ImageGPTModel',
       'ImageGPTPreTrainedModel',
       'load_tf_weights_in_imagegpt',
   ]


if TYPE_CHECKING:
   from .configuration_imagegpt import IMAGEGPT_PRETRAINED_CONFIG_ARCHIVE_MAP, ImageGPTConfig, ImageGPTOnnxConfig

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .feature_extraction_imagegpt import ImageGPTFeatureExtractor
      from .image_processing_imagegpt import ImageGPTImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_imagegpt import (
          IMAGEGPT_PRETRAINED_MODEL_ARCHIVE_LIST,
          ImageGPTForCausalImageModeling,
          ImageGPTForImageClassification,
          ImageGPTModel,
          ImageGPTPreTrainedModel,
          load_tf_weights_in_imagegpt,
      )

else:
   import sys

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






