






from typing import List, Optional, Union

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


lowercase    				=   logging.get_logger(__name__)

lowercase    				=   {
    "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 					UpperCamelCase_ (     snake_case_							):



	'''simple docstring'''




	lowerCAmelCase						=					'''informer'''
	lowerCAmelCase						=					{
	    '''hidden_size''': '''d_model''',
	    '''num_attention_heads''': '''encoder_attention_heads''',
	    '''num_hidden_layers''': '''encoder_layers''',
	}




	def __init__(			self			,     a = None			,     a = None			,     a = "student_t"			,     a = "nll"			,     a = 1			,     a = None			,     a = "mean"			,     a = 0			,     a = 0			,     a = 0			,     a = 0			,     a = None			,     a = None			,     a = 64			,     a = 32			,     a = 32			,     a = 2			,     a = 2			,     a = 2			,     a = 2			,     a = True			,     a = "gelu"			,     a = 0.05			,     a = 0.1			,     a = 0.1			,     a = 0.1			,     a = 0.1			,     a = 1_00			,     a = 0.02			,     a=True			,     a = "prob"			,     a = 5			,     a = True			,     **a			,     )			->       Tuple:
								# time series specific configuration
								snake_case_           =				prediction_length
								snake_case_           =				context_length or prediction_length
								snake_case_           =				distribution_output
								snake_case_           =				loss
								snake_case_           =				input_size
								snake_case_           =				num_time_features
								snake_case_           =				lags_sequence if lags_sequence is not None else [1, 2, 3, 4, 5, 6, 7]
								snake_case_           =				scaling
								snake_case_           =				num_dynamic_real_features
								snake_case_           =				num_static_real_features
								snake_case_           =				num_static_categorical_features

								# set cardinality
								if cardinality 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`'   )
															snake_case_           =				cardinality
								else:
															snake_case_           =				[0]

								# set embedding_dimension
								if embedding_dimension 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`'   )
															snake_case_           =				embedding_dimension
								else:
															snake_case_           =				[min(50			,     (cat + 1) // 2   ) for cat in self.cardinality]

								snake_case_           =				num_parallel_samples

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

								snake_case_           =				dropout
								snake_case_           =				attention_dropout
								snake_case_           =				activation_dropout
								snake_case_           =				encoder_layerdrop
								snake_case_           =				decoder_layerdrop

								snake_case_           =				activation_function
								snake_case_           =				init_std

								snake_case_           =				use_cache

								# Informer
								snake_case_           =				attention_type
								snake_case_           =				sampling_factor
								snake_case_           =				distil

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






	@property
	def 				_UpperCamelCase     (			self   )			->       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
								)













import unittest

import numpy as np





def 		__UpperCAmelCase     (	a_				,	a_				,	a_				,	a_ = None				,	):
							snake_case_           =				np.shape(a_)
							snake_case_           =				np.shape(a_)
							snake_case_           =				np.shape(a_)

							if shape_a[0] != shape_b[0]:
														snake_case_           =				(
														    'Expected the same number of rows for A and B. '
														    f'''Instead found A of size {shape_a} and B of size {shape_b}'''
														)
														raise ValueError(a_)

							if shape_b[1] != shape_c[1]:
														snake_case_           =				(
														    'Expected the same number of columns for B and C. '
														    f'''Instead found B of size {shape_b} and C of size {shape_c}'''
														)
														raise ValueError(a_)

							snake_case_           =				pseudo_inv
							if a_inv is None:
														try:
																					snake_case_           =				np.linalg.inv(a_)
														except np.linalg.LinAlgError:
																					raise ValueError(
																					    'Input matrix A is not invertible. Cannot compute Schur complement.')

							return mat_c - mat_b.T @ a_inv @ mat_b




class 					UpperCamelCase_ (     unittest.TestCase							):



	'''simple docstring'''




	def 				_UpperCamelCase     (			self   )			->       None:
								snake_case_           =				np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]   )
								snake_case_           =				np.array([[0, 3], [3, 0], [2, 3]]   )
								snake_case_           =				np.array([[2, 1], [6, 3]]   )

								snake_case_           =				schur_complement(a			,     a			,     a   )

								snake_case_           =				np.block([[a, b], [b.T, c]]   )

								snake_case_           =				np.linalg.det(a   )
								snake_case_           =				np.linalg.det(a   )
								snake_case_           =				np.linalg.det(a   )

								self.assertAlmostEqual(a			,     det_a * det_s   )




	def 				_UpperCamelCase     (			self   )			->       None:
								snake_case_           =				np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]   )
								snake_case_           =				np.array([[0, 3], [3, 0], [2, 3]]   )
								snake_case_           =				np.array([[2, 1], [6, 3]]   )

								with self.assertRaises(a   ):
															schur_complement(a			,     a			,     a   )






	def 				_UpperCamelCase     (			self   )			->       None:
								snake_case_           =				np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]   )
								snake_case_           =				np.array([[0, 3], [3, 0], [2, 3]]   )
								snake_case_           =				np.array([[2, 1, 3], [6, 3, 5]]   )

								with self.assertRaises(a   ):
															schur_complement(a			,     a			,     a   )


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	unittest.main()





