




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 			__lowerCamelCase	(   UpperCamelCase__   ):




    """simple docstring"""

    snake_case__ =				"time_series_transformer"
    snake_case__ =				{
        "hidden_size": "d_model",
        "num_attention_heads": "encoder_attention_heads",
        "num_hidden_layers": "encoder_layers",
    }


    def __init__(	self					:					int       ,     SCREAMING_SNAKE_CASE__					:					Optional[int] = None       ,     SCREAMING_SNAKE_CASE__					:					Optional[int] = None       ,     SCREAMING_SNAKE_CASE__					:					str = "student_t"       ,     SCREAMING_SNAKE_CASE__					:					str = "nll"       ,     SCREAMING_SNAKE_CASE__					:					int = 1       ,     SCREAMING_SNAKE_CASE__					:					List[int] = [1, 2, 3, 4, 5, 6, 7]       ,     SCREAMING_SNAKE_CASE__					:					Optional[Union[str, bool]] = "mean"       ,     SCREAMING_SNAKE_CASE__					:					int = 0       ,     SCREAMING_SNAKE_CASE__					:					int = 0       ,     SCREAMING_SNAKE_CASE__					:					int = 0       ,     SCREAMING_SNAKE_CASE__					:					int = 0       ,     SCREAMING_SNAKE_CASE__					:					Optional[List[int]] = None       ,     SCREAMING_SNAKE_CASE__					:					Optional[List[int]] = None       ,     SCREAMING_SNAKE_CASE__					:					int = 32       ,     SCREAMING_SNAKE_CASE__					:					int = 32       ,     SCREAMING_SNAKE_CASE__					:					int = 2       ,     SCREAMING_SNAKE_CASE__					:					int = 2       ,     SCREAMING_SNAKE_CASE__					:					int = 2       ,     SCREAMING_SNAKE_CASE__					:					int = 2       ,     SCREAMING_SNAKE_CASE__					:					bool = True       ,     SCREAMING_SNAKE_CASE__					:					str = "gelu"       ,     SCREAMING_SNAKE_CASE__					:					int = 64       ,     SCREAMING_SNAKE_CASE__					:					float = 0.1       ,     SCREAMING_SNAKE_CASE__					:					float = 0.1       ,     SCREAMING_SNAKE_CASE__					:					float = 0.1       ,     SCREAMING_SNAKE_CASE__					:					float = 0.1       ,     SCREAMING_SNAKE_CASE__					:					float = 0.1       ,     SCREAMING_SNAKE_CASE__					:					int = 100       ,     SCREAMING_SNAKE_CASE__					:					float = 0.02       ,     SCREAMING_SNAKE_CASE__					:					Any=True       ,     **SCREAMING_SNAKE_CASE__					:					Optional[int]       ,     )				->	Union[str, 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(SCREAMING_SNAKE_CASE__       ) != 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(SCREAMING_SNAKE_CASE__       ) != 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(SCREAMING_SNAKE_CASE__       ) + 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=SCREAMING_SNAKE_CASE__       ,     **SCREAMING_SNAKE_CASE__       )


    @property
    def        a				(	self					:					List[Any]       )				->	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 warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin





class 			__lowerCamelCase	(   UpperCamelCase__   ):




    """simple docstring"""

    snake_case__ =				"Speech2TextFeatureExtractor"
    snake_case__ =				"Speech2TextTokenizer"


    def __init__(	self					:					int       ,     SCREAMING_SNAKE_CASE__					:					Dict       ,     SCREAMING_SNAKE_CASE__					:					Tuple       )				->	Optional[Any]:
         super().__init__(SCREAMING_SNAKE_CASE__       ,     SCREAMING_SNAKE_CASE__       )
         lowerCAmelCase__          =			self.feature_extractor
         lowerCAmelCase__          =			False


    def __call__(	self					:					str       ,     *SCREAMING_SNAKE_CASE__					:					int       ,     **SCREAMING_SNAKE_CASE__					:					int       )				->	Optional[Any]:
         # For backward compatibility
         if self._in_target_context_manager:
              return self.current_processor(*SCREAMING_SNAKE_CASE__       ,     **SCREAMING_SNAKE_CASE__       )

         if "raw_speech" in kwargs:
              warnings.warn("Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."       )
              lowerCAmelCase__          =			kwargs.pop("raw_speech"       )
         else:
              lowerCAmelCase__          =			kwargs.pop("audio"       ,     SCREAMING_SNAKE_CASE__       )
         lowerCAmelCase__          =			kwargs.pop("sampling_rate"       ,     SCREAMING_SNAKE_CASE__       )
         lowerCAmelCase__          =			kwargs.pop("text"       ,     SCREAMING_SNAKE_CASE__       )
         if len(SCREAMING_SNAKE_CASE__       ) > 0:
              lowerCAmelCase__          =			args[0]
              lowerCAmelCase__          =			args[1:]

         if audio is None and text is None:
              raise ValueError("You need to specify either an `audio` or `text` input to process."       )

         if audio is not None:
              lowerCAmelCase__          =			self.feature_extractor(SCREAMING_SNAKE_CASE__       ,     *SCREAMING_SNAKE_CASE__       ,     sampling_rate=SCREAMING_SNAKE_CASE__       ,     **SCREAMING_SNAKE_CASE__       )
         if text is not None:
              lowerCAmelCase__          =			self.tokenizer(SCREAMING_SNAKE_CASE__       ,     **SCREAMING_SNAKE_CASE__       )

         if text is None:
              return inputs
         elif audio is None:
              return encodings
         else:
              lowerCAmelCase__          =			encodings["input_ids"]
              return inputs


    def        a				(	self					:					str       ,     *SCREAMING_SNAKE_CASE__					:					Dict       ,     **SCREAMING_SNAKE_CASE__					:					int       )				->	Union[str, Any]:
         return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE__       ,     **SCREAMING_SNAKE_CASE__       )


    def        a				(	self					:					Dict       ,     *SCREAMING_SNAKE_CASE__					:					Optional[int]       ,     **SCREAMING_SNAKE_CASE__					:					Optional[int]       )				->	Optional[Any]:
         return self.tokenizer.decode(*SCREAMING_SNAKE_CASE__       ,     **SCREAMING_SNAKE_CASE__       )


    @contextmanager
    def        a				(	self					:					Union[str, Any]       )				->	Any:
         warnings.warn(
             "`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your "
             "labels by using the argument `text` of the regular `__call__` method (either in the same call as "
             "your audio inputs, or in a separate call."       )
         lowerCAmelCase__          =			True
         lowerCAmelCase__          =			self.tokenizer
         yield
         lowerCAmelCase__          =			self.feature_extractor
         lowerCAmelCase__          =			False
