





'''simple docstring'''


from typing import List, Optional

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


lowerCAmelCase_ : Tuple	  =       logging.get_logger(__name__)

lowerCAmelCase_ : Any	  =       {
    "huggingface/autoformer-tourism-monthly": "https://huggingface.co/huggingface/autoformer-tourism-monthly/resolve/main/config.json",
}






class    UpperCamelCase__	(		__lowerCAmelCase  ):
	lowerCAmelCase__       :      List[str]										=    '''autoformer'''
	lowerCAmelCase__       :      int										=    {
	    '''hidden_size''': '''d_model''',
	    '''num_attention_heads''': '''encoder_attention_heads''',
	    '''num_hidden_layers''': '''encoder_layers''',
	}







	def __init__(					self      : Dict			,			lowerCamelCase      : Dict = None			,			lowerCamelCase      : str = None			,			lowerCamelCase      : Optional[int] = "student_t"			,			lowerCamelCase      : Tuple = "nll"			,			lowerCamelCase      : List[Any] = 1			,			lowerCamelCase      : Any = [1, 2, 3, 4, 5, 6, 7]			,			lowerCamelCase      : Union[str, Any] = True			,			lowerCamelCase      : Tuple = 0			,			lowerCamelCase      : Any = 0			,			lowerCamelCase      : Tuple = 0			,			lowerCamelCase      : int = 0			,			lowerCamelCase      : Dict = None			,			lowerCamelCase      : int = None			,			lowerCamelCase      : Optional[Any] = 6_4			,			lowerCamelCase      : Dict = 2			,			lowerCamelCase      : List[str] = 2			,			lowerCamelCase      : Tuple = 2			,			lowerCamelCase      : int = 2			,			lowerCamelCase      : Dict = 3_2			,			lowerCamelCase      : List[Any] = 3_2			,			lowerCamelCase      : Optional[int] = "gelu"			,			lowerCamelCase      : str = 0.1			,			lowerCamelCase      : List[str] = 0.1			,			lowerCamelCase      : Dict = 0.1			,			lowerCamelCase      : Any = 0.1			,			lowerCamelCase      : int = 0.1			,			lowerCamelCase      : Tuple = 1_0_0			,			lowerCamelCase      : Any = 0.02			,			lowerCamelCase      : str = True			,			lowerCamelCase      : List[Any]=True			,			lowerCamelCase      : Optional[Any] = 1_0			,			lowerCamelCase      : List[Any] = 2_5			,			lowerCamelCase      : Any = 3			,			**lowerCamelCase      : List[Any]			,			):




				'''simple docstring'''
				# time series specific configuration
				a__	 =			prediction_length
				a__	 =			context_length if context_length is not None else 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 is not None and num_static_categorical_features > 0:
							if len(_lowerCamelCase		) != 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 is not None and num_static_categorical_features > 0:
							if len(_lowerCamelCase		) != 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(5_0			,			(cat + 1) // 2		) for cat in self.cardinality]
				a__	 =			num_parallel_samples

				# Transformer architecture configuration
				a__	 =			input_size * len(self.lags_sequence		) + 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

				# Autoformer
				a__	 =			label_length
				a__	 =			moving_average
				a__	 =			autocorrelation_factor

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







	@property
	def     __a (					self      : Union[str, Any]		):




				'''simple docstring'''
				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 collections.abc import Callable
from math import pi, sqrt
from random import uniform
from statistics import mean





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   List[Any]:




						'''simple docstring'''



						def is_in_circle(__lowerCAmelCase  ,       __lowerCAmelCase							) -> bool:
												lowerCamelCase__   =sqrt((x**2) + (y**2)							)
												# Our circle has a radius of 1, so a distance
												# greater than 1 would land outside the circle.
												return distance_from_centre <= 1

						# The proportion of guesses that landed in the circle
						lowerCamelCase__   =mean(
						    int(is_in_circle(uniform(-1.0  ,       1.0							)  ,       uniform(-1.0  ,       1.0							)							)							)
						    for _ in range(__lowerCAmelCase							)							)
						# The ratio of the area for circle to square is pi/4.
						lowerCamelCase__   =proportion * 4
						print(F'''The estimated value of pi is {pi_estimate}'''							)
						print(F'''The numpy value of pi is {pi}'''							)
						print(F'''The total error is {abs(pi - pi_estimate							)}'''							)





def      lowerCamelCase_					(   __lowerCAmelCase  ,       __lowerCAmelCase  ,       __lowerCAmelCase = 0.0  ,       __lowerCAmelCase = 1.0  ,       )				->   float:




						'''simple docstring'''



						return mean(
						    function_to_integrate(uniform(__lowerCAmelCase  ,       __lowerCAmelCase							)							) for _ in range(__lowerCAmelCase							)							) * (max_value - min_value)





def      lowerCamelCase_					(   __lowerCAmelCase  ,       __lowerCAmelCase = 0.0  ,       __lowerCAmelCase = 1.0							)				->   None:




						'''simple docstring'''



						def identity_function(__lowerCAmelCase							) -> float:
												return x

						lowerCamelCase__   =area_under_curve_estimator(
						    __lowerCAmelCase  ,       __lowerCAmelCase  ,       __lowerCAmelCase  ,       __lowerCAmelCase							)
						lowerCamelCase__   =(max_value * max_value - min_value * min_value) / 2

						print("******************"							)
						print(F'''Estimating area under y=x where x varies from {min_value} to {max_value}'''							)
						print(F'''Estimated value is {estimated_value}'''							)
						print(F'''Expected value is {expected_value}'''							)
						print(F'''Total error is {abs(estimated_value - expected_value							)}'''							)
						print("******************"							)





def      lowerCamelCase_					(   __lowerCAmelCase							)				->   None:




						'''simple docstring'''



						def function_to_integrate(__lowerCAmelCase							) -> float:
												return sqrt(4.0 - x * x							)

						lowerCamelCase__   =area_under_curve_estimator(
						    __lowerCAmelCase  ,       __lowerCAmelCase  ,       0.0  ,       2.0							)

						print("******************"							)
						print("Estimating pi using area_under_curve_estimator"							)
						print(F'''Estimated value is {estimated_value}'''							)
						print(F'''Expected value is {pi}'''							)
						print(F'''Total error is {abs(estimated_value - pi							)}'''							)
						print("******************"							)


if __name__ == "__main__":
	import doctest

	doctest.testmod()


