

'''simple docstring'''






from typing import List, Optional, Union

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


lowerCAmelCase__											=	logging.get_logger(__name__)

lowerCAmelCase__											=	{
    '''huggingface/informer-tourism-monthly''': (
        '''https://huggingface.co/huggingface/informer-tourism-monthly/resolve/main/config.json'''
    ),
    # See all Informer models at https://huggingface.co/models?filter=informer
}






class 			lowercase_	(lowerCamelCase__      ):




  """simple docstring"""




  SCREAMING_SNAKE_CASE    :  Any							=			'informer'
  SCREAMING_SNAKE_CASE    :  Optional[Any]							=			{
      'hidden_size': 'd_model',
      'num_attention_heads': 'encoder_attention_heads',
      'num_hidden_layers': 'encoder_layers',
  }






  def __init__(      self   :     Tuple					,lowercase__   :     Optional[int] = None					,lowercase__   :     Optional[int] = None					,lowercase__   :     str = "student_t"					,lowercase__   :     str = "nll"					,lowercase__   :     int = 1					,lowercase__   :     List[int] = None					,lowercase__   :     Optional[Union[str, bool]] = "mean"					,lowercase__   :     int = 0					,lowercase__   :     int = 0					,lowercase__   :     int = 0					,lowercase__   :     int = 0					,lowercase__   :     Optional[List[int]] = None					,lowercase__   :     Optional[List[int]] = None					,lowercase__   :     int = 6_4					,lowercase__   :     int = 3_2					,lowercase__   :     int = 3_2					,lowercase__   :     int = 2					,lowercase__   :     int = 2					,lowercase__   :     int = 2					,lowercase__   :     int = 2					,lowercase__   :     bool = True					,lowercase__   :     str = "gelu"					,lowercase__   :     float = 0.0_5					,lowercase__   :     float = 0.1					,lowercase__   :     float = 0.1					,lowercase__   :     float = 0.1					,lowercase__   :     float = 0.1					,lowercase__   :     int = 1_0_0					,lowercase__   :     float = 0.0_2					,lowercase__   :     Any=True					,lowercase__   :     str = "prob"					,lowercase__   :     int = 5					,lowercase__   :     bool = True					,**lowercase__   :     List[str]					,):
   # time series specific configuration
   __lowercase							  = prediction_length
   __lowercase							  = context_length or prediction_length
   __lowercase							  = distribution_output
   __lowercase							  = loss
   __lowercase							  = input_size
   __lowercase							  = num_time_features
   __lowercase							  = lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
   __lowercase							  = scaling
   __lowercase							  = num_dynamic_real_features
   __lowercase							  = num_static_real_features
   __lowercase							  = num_static_categorical_features

   # set cardinality
   if cardinality and num_static_categorical_features > 0:
    if len(lowercase__			) != num_static_categorical_features:
     raise ValueError(
         '''The cardinality should be a list of the same length as `num_static_categorical_features`'''			)
    __lowercase							  = cardinality
   else:
    __lowercase							  = [0]

   # set embedding_dimension
   if embedding_dimension and num_static_categorical_features > 0:
    if len(lowercase__			) != num_static_categorical_features:
     raise ValueError(
         '''The embedding dimension should be a list of the same length as `num_static_categorical_features`'''			)
    __lowercase							  = embedding_dimension
   else:
    __lowercase							  = [min(5_0					,(cat + 1) // 2			) for cat in self.cardinality]

   __lowercase							  = num_parallel_samples

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

   __lowercase							  = dropout
   __lowercase							  = attention_dropout
   __lowercase							  = activation_dropout
   __lowercase							  = encoder_layerdrop
   __lowercase							  = decoder_layerdrop

   __lowercase							  = activation_function
   __lowercase							  = init_std

   __lowercase							  = use_cache

   # Informer
   __lowercase							  = attention_type
   __lowercase							  = sampling_factor
   __lowercase							  = distil

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






  @property
  def 					SCREAMING_SNAKE_CASE      (      self   :     List[Any]			):
   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
   )






'''simple docstring'''






from __future__ import annotations


def  snake_case_     (					_lowerCAmelCase  :						str   ,      _lowerCAmelCase  :						str  )      ->   bool:
							UpperCAmelCase :       str 							=		get_failure_array(_lowerCAmelCase  )

							# 2) Step through text searching for pattern
							UpperCAmelCase							,		UpperCAmelCase :       Optional[Any] 							=		0, 0  # index into text, pattern
							while i < len(_lowerCAmelCase  ):
														if pattern[j] == text[i]:
																					if j == (len(_lowerCAmelCase  ) - 1):
																												return True
																					j += 1

														# if this is a prefix in our pattern
														# just go back far enough to continue
														elif j > 0:
																					UpperCAmelCase :       Optional[Any] 							=		failure[j - 1]
																					continue
														i += 1
							return False


def  snake_case_     (					_lowerCAmelCase  :						str  )      ->   list[int]:
							UpperCAmelCase :       Optional[Any] 							=		[0]
							UpperCAmelCase :       str 							=		0
							UpperCAmelCase :       List[str] 							=		1
							while j < len(_lowerCAmelCase  ):
														if pattern[i] == pattern[j]:
																					i += 1
														elif i > 0:
																					UpperCAmelCase :       Union[str, Any] 							=		failure[i - 1]
																					continue
														j += 1
														failure.append(_lowerCAmelCase  )
							return failure


if __name__ == "__main__":
						# Test 1)
						UpperCamelCase__:   str								=			"abc1abc12"
						UpperCamelCase__:   str								=			"alskfjaldsabc1abc1abc12k23adsfabcabc"
						UpperCamelCase__:   Any								=			"alskfjaldsk23adsfabcabc"
						assert kmp(pattern, texta) and not kmp(pattern, texta)

						# Test 2)
						UpperCamelCase__:   Tuple								=			"ABABX"
						UpperCamelCase__:   Union[str, Any]								=			"ABABZABABYABABX"
						assert kmp(pattern, text)

						# Test 3)
						UpperCamelCase__:   Any								=			"AAAB"
						UpperCamelCase__:   str								=			"ABAAAAAB"
						assert kmp(pattern, text)

						# Test 4)
						UpperCamelCase__:   int								=			"abcdabcy"
						UpperCamelCase__:   Any								=			"abcxabcdabxabcdabcdabcy"
						assert kmp(pattern, text)

						# Test 5)
						UpperCamelCase__:   List[str]								=			"aabaabaaa"
						assert get_failure_array(pattern) == [0, 1, 0, 1, 2, 3, 4, 5, 2]





