



'''simple docstring'''

from timeit import timeit

UpperCAmelCase     		=   {
    'MALAYALAM': True,
    'String': False,
    'rotor': True,
    'level': True,
    'A': True,
    'BB': True,
    'ABC': False,
    'amanaplanacanalpanama': True,  # "a man a plan a canal panama"
}
# Ensure our test data is valid
assert all((key == key[::-1]) is value for key, value in test_data.items())






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						str							)      ->						bool:







	"""simple docstring"""
	lowerCAmelCase   =     0
	lowerCAmelCase   =     len(_SCREAMING_SNAKE_CASE							) - 1
	while start_i < end_i:
		if s[start_i] == s[end_i]:
			start_i += 1
			end_i -= 1
		else:
			return False
	return True






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						str							)      ->						bool:







	"""simple docstring"""
	lowerCAmelCase   =     len(_SCREAMING_SNAKE_CASE							) // 2
	lowerCAmelCase   =     len(_SCREAMING_SNAKE_CASE							)

	# We need to traverse till half of the length of string
	# as we can get access of the i'th last element from
	# i'th index.
	# eg: [0,1,2,3,4,5] => 4th index can be accessed
	# with the help of 1st index (i==n-i-1)
	# where n is length of string
	return all(s[i] == s[n - i - 1] for i in range(_SCREAMING_SNAKE_CASE							)							)






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						str							)      ->						bool:







	"""simple docstring"""
	if len(_SCREAMING_SNAKE_CASE							) <= 2:
		return True
	if s[0] == s[len(_SCREAMING_SNAKE_CASE							) - 1]:
		return is_palindrome_recursive(s[1:-1]							)
	else:
		return False






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						str							)      ->						bool:







	"""simple docstring"""
	return s == s[::-1]






def 		_snake_case		( _SCREAMING_SNAKE_CASE					:						str							)      ->						None:







	"""simple docstring"""
	lowerCAmelCase   =     f'all({name}(key) is value for key, value in test_data.items())'
	lowerCAmelCase   =     f'from __main__ import test_data, {name}'
	lowerCAmelCase   =     500_000
	lowerCAmelCase   =     timeit(stmt=_SCREAMING_SNAKE_CASE							,		setup=_SCREAMING_SNAKE_CASE							,		number=_SCREAMING_SNAKE_CASE							)
	print(f'{name:<35} finished {number:,} runs in {result:.5f} seconds'							)


if __name__ == "__main__":
				for key, value in test_data.items():
								assert is_palindrome(key) is is_palindrome_recursive(key)
								assert is_palindrome(key) is is_palindrome_slice(key)
								print(F'''{key:21} {value}''')
				print('a man a plan a canal panama')

				# finished 500,000 runs in 0.46793 seconds
				benchmark_function('is_palindrome_slice')
				# finished 500,000 runs in 0.85234 seconds
				benchmark_function('is_palindrome')
				# finished 500,000 runs in 1.32028 seconds
				benchmark_function('is_palindrome_recursive')
				# finished 500,000 runs in 2.08679 seconds
				benchmark_function('is_palindrome_traversal')




'''simple docstring'''

from typing import List, Optional, Union

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


UpperCAmelCase     		=   logging.get_logger(__name__)

UpperCAmelCase     		=   {
    '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 __snake_case(				_lowerCAmelCase ):


						'''simple docstring'''



						UpperCAmelCase							:   List[Any]									=		"time_series_transformer"
						UpperCAmelCase							:   int									=		{
						    "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_ = [1, 2, 3, 4, 5, 6, 7]     ,	A_ = "mean"     ,	A_ = 0     ,	A_ = 0     ,	A_ = 0     ,	A_ = 0     ,	A_ = None     ,	A_ = None     ,	A_ = 32     ,	A_ = 32     ,	A_ = 2     ,	A_ = 2     ,	A_ = 2     ,	A_ = 2     ,	A_ = True     ,	A_ = "gelu"     ,	A_ = 64     ,	A_ = 0.1     ,	A_ = 0.1     ,	A_ = 0.1     ,	A_ = 0.1     ,	A_ = 0.1     ,	A_ = 100     ,	A_ = 0.0_2     ,	A_=True     ,	**A_     ,	)     ->     Optional[Any]:
							# time series specific configuration
							lowerCAmelCase   =     prediction_length
							lowerCAmelCase   =     context_length or 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 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 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(50     ,	(cat + 1) // 2				) for cat in self.cardinality]
							lowerCAmelCase   =     num_parallel_samples

							# Transformer architecture configuration
							lowerCAmelCase   =     input_size * len(A_				) + 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

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




						@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
							)