





import copy

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


_snake_case  :   Any						   =  logging.get_logger(__name__)



class     _UpperCAmelCase   (   a__   ):

  """simple docstring"""


  a_      =			"""encoder-decoder"""
  a_      =			True






  def __init__(    self			:		Optional[int] ,  **lowerCAmelCase_			:		Any					)							->						Union[str, Any]:
     super().__init__(**lowerCAmelCase__					)
     assert (
         "encoder" in kwargs and "decoder" in kwargs
     ), "Config has to be initialized with encoder and decoder config"
     __lowerCAmelCase							     =     kwargs.pop('encoder'					)
     __lowerCAmelCase							     =     encoder_config.pop('model_type'					)
     __lowerCAmelCase							     =     kwargs.pop('decoder'					)
     __lowerCAmelCase							     =     decoder_config.pop('model_type'					)

     from ..auto.configuration_auto import AutoConfig

     __lowerCAmelCase							     =     AutoConfig.for_model(lowerCAmelCase__ ,  **lowerCAmelCase__					)
     __lowerCAmelCase							     =     AutoConfig.for_model(lowerCAmelCase__ ,  **lowerCAmelCase__					)
     __lowerCAmelCase							     =     True






  @classmethod
  def     lowercase		(    cls			:		Optional[Any] ,  lowerCAmelCase_			:		Tuple ,  lowerCAmelCase_			:		Optional[int] ,  **lowerCAmelCase_			:		Optional[int]					)							->						PretrainedConfig:
     logger.info('Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config'					)
     __lowerCAmelCase							     =     True
     __lowerCAmelCase							     =     True

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






  def     lowercase		(    self			:		int					)							->						Tuple:
     __lowerCAmelCase							     =     copy.deepcopy(self.__dict__					)
     __lowerCAmelCase							     =     self.encoder.to_dict()
     __lowerCAmelCase							     =     self.decoder.to_dict()
     __lowerCAmelCase							     =     self.__class__.model_type
     return output







from collections.abc import Sequence

def   a_   (			lowerCAmelCase_				:      Sequence[float],     lowerCAmelCase_				:      bool = False     ):
   if not arr:
      return 0

   __lowerCAmelCase							     =     0 if allow_empty_subarrays else float('-inf'     )
   __lowerCAmelCase							     =     0.0
   for num in arr:
      __lowerCAmelCase							     =     max(0 if allow_empty_subarrays else num,     curr_sum + num     )
      __lowerCAmelCase							     =     max(lowerCAmelCase_,     lowerCAmelCase_     )

   return max_sum


if __name__ == "__main__":
     from doctest import testmod

     testmod()

     _snake_case  :   Optional[Any]						   =  [-2, 1, -3, 4, -1, 2, 1, -5, 4]
     print(F"""{max_subarray_sum(nums) = }""")

