





from typing import List, Optional

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


_snake_case  :   int						   =  logging.get_logger(__name__)

_snake_case  :   List[Any]						   =  {
    'huggingface/autoformer-tourism-monthly': 'https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json',
}



class     _UpperCAmelCase   (   _UpperCamelCase   ):

  """simple docstring"""


  a_      =			'''autoformer'''
  a_      =			{
      '''hidden_size''': '''d_model''',
      '''num_attention_heads''': '''encoder_attention_heads''',
      '''num_hidden_layers''': '''encoder_layers''',
  }






  def __init__(    self			:		Optional[Any] ,  lowerCAmelCase_			:		Optional[int] = None ,  lowerCAmelCase_			:		Optional[int] = None ,  lowerCAmelCase_			:		str = "student_t" ,  lowerCAmelCase_			:		str = "nll" ,  lowerCAmelCase_			:		int = 1 ,  lowerCAmelCase_			:		List[int] = [1, 2, 3, 4, 5, 6, 7] ,  lowerCAmelCase_			:		bool = True ,  lowerCAmelCase_			:		int = 0 ,  lowerCAmelCase_			:		int = 0 ,  lowerCAmelCase_			:		int = 0 ,  lowerCAmelCase_			:		int = 0 ,  lowerCAmelCase_			:		Optional[List[int]] = None ,  lowerCAmelCase_			:		Optional[List[int]] = None ,  lowerCAmelCase_			:		int = 6_4 ,  lowerCAmelCase_			:		int = 2 ,  lowerCAmelCase_			:		int = 2 ,  lowerCAmelCase_			:		int = 2 ,  lowerCAmelCase_			:		int = 2 ,  lowerCAmelCase_			:		int = 3_2 ,  lowerCAmelCase_			:		int = 3_2 ,  lowerCAmelCase_			:		str = "gelu" ,  lowerCAmelCase_			:		float = 0.1 ,  lowerCAmelCase_			:		float = 0.1 ,  lowerCAmelCase_			:		float = 0.1 ,  lowerCAmelCase_			:		float = 0.1 ,  lowerCAmelCase_			:		float = 0.1 ,  lowerCAmelCase_			:		int = 1_0_0 ,  lowerCAmelCase_			:		float = 0.02 ,  lowerCAmelCase_			:		bool = True ,  lowerCAmelCase_			:		Optional[int]=True ,  lowerCAmelCase_			:		int = 1_0 ,  lowerCAmelCase_			:		int = 2_5 ,  lowerCAmelCase_			:		int = 3 ,  **lowerCAmelCase_			:		List[Any] ,  )							->						Optional[int]:
     # time series specific configuration
     __lowerCAmelCase							     =     prediction_length
     __lowerCAmelCase							     =     context_length if context_length is not None else prediction_length
     __lowerCAmelCase							     =     distribution_output
     __lowerCAmelCase							     =     loss
     __lowerCAmelCase							     =     input_size
     __lowerCAmelCase							     =     num_time_features
     __lowerCAmelCase							     =     lags_sequence
     __lowerCAmelCase							     =     scaling
     __lowerCAmelCase							     =     num_dynamic_real_features
     __lowerCAmelCase							     =     num_static_real_features
     __lowerCAmelCase							     =     num_static_categorical_features
     if cardinality is not None and num_static_categorical_features > 0:
        if len(_a					) != num_static_categorical_features:
           raise ValueError(
               'The cardinality should be a list of the same length as `num_static_categorical_features`'					)
        __lowerCAmelCase							     =     cardinality
     else:
        __lowerCAmelCase							     =     [0]
     if embedding_dimension is not None and num_static_categorical_features > 0:
        if len(_a					) != num_static_categorical_features:
           raise ValueError(
               'The embedding dimension should be a list of the same length as `num_static_categorical_features`'					)
        __lowerCAmelCase							     =     embedding_dimension
     else:
        __lowerCAmelCase							     =     [min(5_0 ,  (cat + 1) // 2					) for cat in self.cardinality]
     __lowerCAmelCase							     =     num_parallel_samples

     # Transformer architecture configuration
     __lowerCAmelCase							     =     input_size * len(self.lags_sequence					) + self._number_of_features
     __lowerCAmelCase							     =     d_model
     __lowerCAmelCase							     =     encoder_attention_heads
     __lowerCAmelCase							     =     decoder_attention_heads
     __lowerCAmelCase							     =     encoder_ffn_dim
     __lowerCAmelCase							     =     decoder_ffn_dim
     __lowerCAmelCase							     =     encoder_layers
     __lowerCAmelCase							     =     decoder_layers

     __lowerCAmelCase							     =     dropout
     __lowerCAmelCase							     =     attention_dropout
     __lowerCAmelCase							     =     activation_dropout
     __lowerCAmelCase							     =     encoder_layerdrop
     __lowerCAmelCase							     =     decoder_layerdrop

     __lowerCAmelCase							     =     activation_function
     __lowerCAmelCase							     =     init_std

     __lowerCAmelCase							     =     use_cache

     # Autoformer
     __lowerCAmelCase							     =     label_length
     __lowerCAmelCase							     =     moving_average
     __lowerCAmelCase							     =     autocorrelation_factor

     super().__init__(is_encoder_decoder=_a ,  **_a					)






  @property
  def     lowercase		(    self			:		List[Any]					)							->						Optional[int]:
     return (
         sum(self.embedding_dimension					)
         + self.num_dynamic_real_features
         + self.num_time_features
         + self.num_static_real_features
         + self.input_size * 2  # the log1p(abs(loc)) and log(scale) features
     )







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) = }""")

