


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_speech_available,
    is_tf_available,
    is_torch_available,
)


lowerCAmelCase       		=    {
    """configuration_speech_to_text""": ["""SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """Speech2TextConfig"""],
    """processing_speech_to_text""": ["""Speech2TextProcessor"""],
}

try:
				if not is_sentencepiece_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				lowerCAmelCase       		=    ["""Speech2TextTokenizer"""]

try:
				if not is_speech_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				lowerCAmelCase       		=    ["""Speech2TextFeatureExtractor"""]

try:
				if not is_tf_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				lowerCAmelCase       		=    [
				    """TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST""",
				    """TFSpeech2TextForConditionalGeneration""",
				    """TFSpeech2TextModel""",
				    """TFSpeech2TextPreTrainedModel""",
				]

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				lowerCAmelCase       		=    [
				    """SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST""",
				    """Speech2TextForConditionalGeneration""",
				    """Speech2TextModel""",
				    """Speech2TextPreTrainedModel""",
				]


if TYPE_CHECKING:
				from .configuration_speech_to_text import SPEECH_TO_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP, SpeechaTextConfig
				from .processing_speech_to_text import SpeechaTextProcessor

				try:
								if not is_sentencepiece_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .tokenization_speech_to_text import SpeechaTextTokenizer

				try:
								if not is_speech_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .feature_extraction_speech_to_text import SpeechaTextFeatureExtractor

				try:
								if not is_tf_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_tf_speech_to_text import (
								    TF_SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    TFSpeechaTextForConditionalGeneration,
								    TFSpeechaTextModel,
								    TFSpeechaTextPreTrainedModel,
								)

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_speech_to_text import (
								    SPEECH_TO_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
								    SpeechaTextForConditionalGeneration,
								    SpeechaTextModel,
								    SpeechaTextPreTrainedModel,
								)

else:
				import sys

				lowerCAmelCase       		=    _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





from typing import List, Optional

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


lowerCAmelCase       		=    logging.get_logger(__name__)

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




class 							lowerCamelCase   (  _UpperCamelCase ):
	_lowerCAmelCase     :		Optional[int]										=						'''autoformer'''
	_lowerCAmelCase     :		Any										=						{
	    '''hidden_size''': '''d_model''',
	    '''num_attention_heads''': '''encoder_attention_heads''',
	    '''num_hidden_layers''': '''encoder_layers''',
	}


	def __init__(    self				,     lowercase__ = None				,     lowercase__ = None				,     lowercase__ = "student_t"				,     lowercase__ = "nll"				,     lowercase__ = 1				,     lowercase__ = [1, 2, 3, 4, 5, 6, 7]				,     lowercase__ = True				,     lowercase__ = 0				,     lowercase__ = 0				,     lowercase__ = 0				,     lowercase__ = 0				,     lowercase__ = None				,     lowercase__ = None				,     lowercase__ = 6_4				,     lowercase__ = 2				,     lowercase__ = 2				,     lowercase__ = 2				,     lowercase__ = 2				,     lowercase__ = 3_2				,     lowercase__ = 3_2				,     lowercase__ = "gelu"				,     lowercase__ = 0.1				,     lowercase__ = 0.1				,     lowercase__ = 0.1				,     lowercase__ = 0.1				,     lowercase__ = 0.1				,     lowercase__ = 1_0_0				,     lowercase__ = 0.0_2				,     lowercase__ = True				,     lowercase__=True				,     lowercase__ = 1_0				,     lowercase__ = 2_5				,     lowercase__ = 3				,     **lowercase__				,     ):
							# time series specific configuration
							__UpperCAmelCase			:							Optional[int]	    =	prediction_length
							__UpperCAmelCase			:							Tuple	    =	context_length if context_length is not None else prediction_length
							__UpperCAmelCase			:							Tuple	    =	distribution_output
							__UpperCAmelCase			:							Tuple	    =	loss
							__UpperCAmelCase			:							Dict	    =	input_size
							__UpperCAmelCase			:							str	    =	num_time_features
							__UpperCAmelCase			:							str	    =	lags_sequence
							__UpperCAmelCase			:							int	    =	scaling
							__UpperCAmelCase			:							int	    =	num_dynamic_real_features
							__UpperCAmelCase			:							List[str]	    =	num_static_real_features
							__UpperCAmelCase			:							List[str]	    =	num_static_categorical_features
							if cardinality is not None 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`''')
													__UpperCAmelCase			:							Union[str, Any]	    =	cardinality
							else:
													__UpperCAmelCase			:							List[Any]	    =	[0]
							if embedding_dimension is not None 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`''')
													__UpperCAmelCase			:							Union[str, Any]	    =	embedding_dimension
							else:
													__UpperCAmelCase			:							int	    =	[min(5_0				,     (cat + 1) // 2) for cat in self.cardinality]
							__UpperCAmelCase			:							Tuple	    =	num_parallel_samples

							# Transformer architecture configuration
							__UpperCAmelCase			:							Dict	    =	input_size * len(self.lags_sequence) + self._number_of_features
							__UpperCAmelCase			:							Optional[int]	    =	d_model
							__UpperCAmelCase			:							List[Any]	    =	encoder_attention_heads
							__UpperCAmelCase			:							int	    =	decoder_attention_heads
							__UpperCAmelCase			:							str	    =	encoder_ffn_dim
							__UpperCAmelCase			:							int	    =	decoder_ffn_dim
							__UpperCAmelCase			:							List[Any]	    =	encoder_layers
							__UpperCAmelCase			:							Tuple	    =	decoder_layers

							__UpperCAmelCase			:							Union[str, Any]	    =	dropout
							__UpperCAmelCase			:							int	    =	attention_dropout
							__UpperCAmelCase			:							int	    =	activation_dropout
							__UpperCAmelCase			:							str	    =	encoder_layerdrop
							__UpperCAmelCase			:							Dict	    =	decoder_layerdrop

							__UpperCAmelCase			:							int	    =	activation_function
							__UpperCAmelCase			:							Optional[int]	    =	init_std

							__UpperCAmelCase			:							Optional[int]	    =	use_cache

							# Autoformer
							__UpperCAmelCase			:							str	    =	label_length
							__UpperCAmelCase			:							int	    =	moving_average
							__UpperCAmelCase			:							Optional[int]	    =	autocorrelation_factor

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


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

