"""simple docstring"""




from __future__ import annotations

import math
import random
from typing import Any
class 			UpperCamelCase__:





						def __init__(				self   )    -> None:
													A__		   =							[]
													A__		   =							0
													A__		   =							0





						def  snake_case__		(				self   )    -> bool:
													return self.head == self.tail





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> None:
													self.data.append(__UpperCAmelCase   )
													A__		   =							self.tail + 1





						def  snake_case__		(				self   )    -> Any:
													A__		   =							self.data[self.head]
													A__		   =							self.head + 1
													return ret





						def  snake_case__		(				self   )    -> int:
													return self.tail - self.head





						def  snake_case__		(				self   )    -> None:
													print(self.data   )
													print('**************'   )
													print(self.data[self.head : self.tail]   )






class 			UpperCamelCase__:





						def __init__(				self						,__UpperCAmelCase   )    -> None:
													A__		   =							data
													A__		   =							None
													A__		   =							None
													A__		   =							1





						def  snake_case__		(				self   )    -> Any:
													return self.data





						def  snake_case__		(				self   )    -> MyNode | None:
													return self.left





						def  snake_case__		(				self   )    -> MyNode | None:
													return self.right





						def  snake_case__		(				self   )    -> int:
													return self.height





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> None:
													A__		   =							data





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> None:
													A__		   =							node





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> None:
													A__		   =							node





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> None:
													A__		   =							height






def      UpperCAmelCase    (		UpperCamelCase__ ):






							"""simple docstring"""





							if node is None:
														return 0
							return node.get_height()






def      UpperCAmelCase    (		UpperCamelCase__				,			UpperCamelCase__ ):






							"""simple docstring"""





							if a > b:
														return a
							return b






def      UpperCAmelCase    (		UpperCamelCase__ ):






							"""simple docstring"""





							print('left rotation node:'				,			node.get_data() )
							A__		   =							node.get_left()
							assert ret is not None
							node.set_left(ret.get_right() )
							ret.set_right(UpperCamelCase__ )
							A__		   =							my_max(get_height(node.get_right() )				,			get_height(node.get_left() ) ) + 1
							node.set_height(UpperCamelCase__ )
							A__		   =							my_max(get_height(ret.get_right() )				,			get_height(ret.get_left() ) ) + 1
							ret.set_height(UpperCamelCase__ )
							return ret






def      UpperCAmelCase    (		UpperCamelCase__ ):






							"""simple docstring"""





							print('right rotation node:'				,			node.get_data() )
							A__		   =							node.get_right()
							assert ret is not None
							node.set_right(ret.get_left() )
							ret.set_left(UpperCamelCase__ )
							A__		   =							my_max(get_height(node.get_right() )				,			get_height(node.get_left() ) ) + 1
							node.set_height(UpperCamelCase__ )
							A__		   =							my_max(get_height(ret.get_right() )				,			get_height(ret.get_left() ) ) + 1
							ret.set_height(UpperCamelCase__ )
							return ret






def      UpperCAmelCase    (		UpperCamelCase__ ):






							"""simple docstring"""





							A__		   =							node.get_left()
							assert left_child is not None
							node.set_left(left_rotation(UpperCamelCase__ ) )
							return right_rotation(UpperCamelCase__ )






def      UpperCAmelCase    (		UpperCamelCase__ ):






							"""simple docstring"""





							A__		   =							node.get_right()
							assert right_child is not None
							node.set_right(right_rotation(UpperCamelCase__ ) )
							return left_rotation(UpperCamelCase__ )






def      UpperCAmelCase    (		UpperCamelCase__				,			UpperCamelCase__ ):






							"""simple docstring"""





							if node is None:
														return MyNode(UpperCamelCase__ )
							if data < node.get_data():
														node.set_left(insert_node(node.get_left()				,			UpperCamelCase__ ) )
														if (
														    get_height(node.get_left() ) - get_height(node.get_right() ) == 2
														):  # an unbalance detected
																					A__		   =							node.get_left()
																					assert left_child is not None
																					if (
																					    data < left_child.get_data()
																					):  # new node is the left child of the left child
																												A__		   =							right_rotation(UpperCamelCase__ )
																					else:
																												A__		   =							lr_rotation(UpperCamelCase__ )
							else:
														node.set_right(insert_node(node.get_right()				,			UpperCamelCase__ ) )
														if get_height(node.get_right() ) - get_height(node.get_left() ) == 2:
																					A__		   =							node.get_right()
																					assert right_child is not None
																					if data < right_child.get_data():
																												A__		   =							rl_rotation(UpperCamelCase__ )
																					else:
																												A__		   =							left_rotation(UpperCamelCase__ )
							A__		   =							my_max(get_height(node.get_right() )				,			get_height(node.get_left() ) ) + 1
							node.set_height(UpperCamelCase__ )
							return node






def      UpperCAmelCase    (		UpperCamelCase__ ):






							"""simple docstring"""





							while True:
														A__		   =							root.get_right()
														if right_child is None:
																					break
														A__		   =							right_child
							return root.get_data()






def      UpperCAmelCase    (		UpperCamelCase__ ):






							"""simple docstring"""





							while True:
														A__		   =							root.get_left()
														if left_child is None:
																					break
														A__		   =							left_child
							return root.get_data()






def      UpperCAmelCase    (		UpperCamelCase__				,			UpperCamelCase__ ):






							"""simple docstring"""





							A__		   =							root.get_left()
							A__		   =							root.get_right()
							if root.get_data() == data:
														if left_child is not None and right_child is not None:
																					A__		   =							get_left_most(UpperCamelCase__ )
																					root.set_data(UpperCamelCase__ )
																					root.set_right(del_node(UpperCamelCase__				,			UpperCamelCase__ ) )
														elif left_child is not None:
																					A__		   =							left_child
														elif right_child is not None:
																					A__		   =							right_child
														else:
																					return None
							elif root.get_data() > data:
														if left_child is None:
																					print('No such data' )
																					return root
														else:
																					root.set_left(del_node(UpperCamelCase__				,			UpperCamelCase__ ) )
							else:  # root.get_data() < data
														if right_child is None:
																					return root
														else:
																					root.set_right(del_node(UpperCamelCase__				,			UpperCamelCase__ ) )

							if get_height(UpperCamelCase__ ) - get_height(UpperCamelCase__ ) == 2:
														assert right_child is not None
														if get_height(right_child.get_right() ) > get_height(right_child.get_left() ):
																					A__		   =							left_rotation(UpperCamelCase__ )
														else:
																					A__		   =							rl_rotation(UpperCamelCase__ )
							elif get_height(UpperCamelCase__ ) - get_height(UpperCamelCase__ ) == -2:
														assert left_child is not None
														if get_height(left_child.get_left() ) > get_height(left_child.get_right() ):
																					A__		   =							right_rotation(UpperCamelCase__ )
														else:
																					A__		   =							lr_rotation(UpperCamelCase__ )
							A__		   =							my_max(get_height(root.get_right() )				,			get_height(root.get_left() ) ) + 1
							root.set_height(UpperCamelCase__ )
							return root
class 			UpperCamelCase__:





						def __init__(				self   )    -> None:
													A__		   =							None





						def  snake_case__		(				self   )    -> int:
													return get_height(self.root   )





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> None:
													print('insert:' + str(__UpperCAmelCase   )   )
													A__		   =							insert_node(self.root						,__UpperCAmelCase   )





						def  snake_case__		(				self						,__UpperCAmelCase   )    -> None:
													print('delete:' + str(__UpperCAmelCase   )   )
													if self.root is None:
																				print('Tree is empty!'   )
																				return
													A__		   =							del_node(self.root						,__UpperCAmelCase   )





						def __str__(				self						,)    -> str:  # a level traversale, gives a more intuitive look on the tree
													A__		   =							''
													A__		   =							MyQueue()
													q.push(self.root   )
													A__		   =							self.get_height()
													if layer == 0:
																				return output
													A__		   =							0
													while not q.is_empty():
																				A__		   =							q.pop()
																				A__		   =							' ' * int(math.pow(2						,layer - 1   )   )
																				output += space
																				if node is None:
																											output += "*"
																											q.push(__UpperCAmelCase   )
																											q.push(__UpperCAmelCase   )
																				else:
																											output += str(node.get_data()   )
																											q.push(node.get_left()   )
																											q.push(node.get_right()   )
																				output += space
																				A__		   =							cnt + 1
																				for i in range(1_00   ):
																											if cnt == math.pow(2						,__UpperCAmelCase   ) - 1:
																																		A__		   =							layer - 1
																																		if layer == 0:
																																									output += "\n*************************************"
																																									return output
																																		output += "\n"
																																		break
													output += "\n*************************************"
													return output






def      UpperCAmelCase    (		):






							"""simple docstring"""





							import doctest

							doctest.testmod()


if __name__ == "__main__":
				_test()
				__lowerCamelCase							 =     AVLtree()
				__lowerCamelCase							 =     list(range(10))
				random.shuffle(lst)
				for i in lst:
								t.insert(i)
								print(str(t))
				random.shuffle(lst)
				for i in lst:
								t.del_node(i)
								print(str(t))






"""simple docstring"""




from typing import List, Optional, Union

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


__lowerCamelCase							 =     logging.get_logger(__name__)

__lowerCamelCase							 =     {
    "huggingface/time-series-transformer-tourism-monthly": (
        "https://huggingface.co/huggingface/time-series-transformer-tourism-monthly/resolve/main/config.json"
    ),
    # See all TimeSeriesTransformer models at https://huggingface.co/models?filter=time_series_transformer
}
class 			UpperCamelCase__(	__A       ):
						lowerCAmelCase__     :  List[Any]  							=						'time_series_transformer'
						lowerCAmelCase__     :  Dict  							=						{
						    'hidden_size': 'd_model',
						    'num_attention_heads': 'encoder_attention_heads',
						    'num_hidden_layers': 'encoder_layers',
						}





						def __init__(				self						,__UpperCAmelCase = None						,__UpperCAmelCase = None						,__UpperCAmelCase = "student_t"						,__UpperCAmelCase = "nll"						,__UpperCAmelCase = 1						,__UpperCAmelCase = [1, 2, 3, 4, 5, 6, 7]						,__UpperCAmelCase = "mean"						,__UpperCAmelCase = 0						,__UpperCAmelCase = 0						,__UpperCAmelCase = 0						,__UpperCAmelCase = 0						,__UpperCAmelCase = None						,__UpperCAmelCase = None						,__UpperCAmelCase = 32						,__UpperCAmelCase = 32						,__UpperCAmelCase = 2						,__UpperCAmelCase = 2						,__UpperCAmelCase = 2						,__UpperCAmelCase = 2						,__UpperCAmelCase = True						,__UpperCAmelCase = "gelu"						,__UpperCAmelCase = 64						,__UpperCAmelCase = 0.1						,__UpperCAmelCase = 0.1						,__UpperCAmelCase = 0.1						,__UpperCAmelCase = 0.1						,__UpperCAmelCase = 0.1						,__UpperCAmelCase = 1_00						,__UpperCAmelCase = 0.0_2						,__UpperCAmelCase=True						,**__UpperCAmelCase						,)    -> List[str]:
													# time series specific configuration
													A__		   =							prediction_length
													A__		   =							context_length or prediction_length
													A__		   =							distribution_output
													A__		   =							loss
													A__		   =							input_size
													A__		   =							num_time_features
													A__		   =							lags_sequence
													A__		   =							scaling
													A__		   =							num_dynamic_real_features
													A__		   =							num_static_real_features
													A__		   =							num_static_categorical_features
													if cardinality and num_static_categorical_features > 0:
																				if len(__UpperCAmelCase   ) != num_static_categorical_features:
																											raise ValueError(
																											    'The cardinality should be a list of the same length as `num_static_categorical_features`'   )
																				A__		   =							cardinality
													else:
																				A__		   =							[0]
													if embedding_dimension and num_static_categorical_features > 0:
																				if len(__UpperCAmelCase   ) != num_static_categorical_features:
																											raise ValueError(
																											    'The embedding dimension should be a list of the same length as `num_static_categorical_features`'   )
																				A__		   =							embedding_dimension
													else:
																				A__		   =							[min(50						,(cat + 1) // 2   ) for cat in self.cardinality]
													A__		   =							num_parallel_samples

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

													A__		   =							dropout
													A__		   =							attention_dropout
													A__		   =							activation_dropout
													A__		   =							encoder_layerdrop
													A__		   =							decoder_layerdrop

													A__		   =							activation_function
													A__		   =							init_std

													A__		   =							use_cache

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





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





