


"""simple docstring"""







from typing import TYPE_CHECKING

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


lowerCAmelCase__				    =       {
    "configuration_xlm_roberta": [
        "XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "XLMRobertaConfig",
        "XLMRobertaOnnxConfig",
    ],
}

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

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase__				    =       ["XLMRobertaTokenizerFast"]

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase__				    =       [
					    "XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "XLMRobertaForCausalLM",
					    "XLMRobertaForMaskedLM",
					    "XLMRobertaForMultipleChoice",
					    "XLMRobertaForQuestionAnswering",
					    "XLMRobertaForSequenceClassification",
					    "XLMRobertaForTokenClassification",
					    "XLMRobertaModel",
					    "XLMRobertaPreTrainedModel",
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase__				    =       [
					    "TF_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "TFXLMRobertaForCausalLM",
					    "TFXLMRobertaForMaskedLM",
					    "TFXLMRobertaForMultipleChoice",
					    "TFXLMRobertaForQuestionAnswering",
					    "TFXLMRobertaForSequenceClassification",
					    "TFXLMRobertaForTokenClassification",
					    "TFXLMRobertaModel",
					    "TFXLMRobertaPreTrainedModel",
					]

try:
					if not is_flax_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					lowerCAmelCase__				    =       [
					    "FLAX_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST",
					    "FlaxXLMRobertaForMaskedLM",
					    "FlaxXLMRobertaForCausalLM",
					    "FlaxXLMRobertaForMultipleChoice",
					    "FlaxXLMRobertaForQuestionAnswering",
					    "FlaxXLMRobertaForSequenceClassification",
					    "FlaxXLMRobertaForTokenClassification",
					    "FlaxXLMRobertaModel",
					    "FlaxXLMRobertaPreTrainedModel",
					]

if TYPE_CHECKING:
					from .configuration_xlm_roberta import (
					    XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP,
					    XLMRobertaConfig,
					    XLMRobertaOnnxConfig,
					)

					try:
										if not is_sentencepiece_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_xlm_roberta import XLMRobertaTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_xlm_roberta_fast import XLMRobertaTokenizerFast

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_xlm_roberta import (
										    XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
										    XLMRobertaForCausalLM,
										    XLMRobertaForMaskedLM,
										    XLMRobertaForMultipleChoice,
										    XLMRobertaForQuestionAnswering,
										    XLMRobertaForSequenceClassification,
										    XLMRobertaForTokenClassification,
										    XLMRobertaModel,
										    XLMRobertaPreTrainedModel,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_xlm_roberta import (
										    TF_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFXLMRobertaForCausalLM,
										    TFXLMRobertaForMaskedLM,
										    TFXLMRobertaForMultipleChoice,
										    TFXLMRobertaForQuestionAnswering,
										    TFXLMRobertaForSequenceClassification,
										    TFXLMRobertaForTokenClassification,
										    TFXLMRobertaModel,
										    TFXLMRobertaPreTrainedModel,
										)

					try:
										if not is_flax_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_flax_xlm_roberta import (
										    FLAX_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
										    FlaxXLMRobertaForCausalLM,
										    FlaxXLMRobertaForMaskedLM,
										    FlaxXLMRobertaForMultipleChoice,
										    FlaxXLMRobertaForQuestionAnswering,
										    FlaxXLMRobertaForSequenceClassification,
										    FlaxXLMRobertaForTokenClassification,
										    FlaxXLMRobertaModel,
										    FlaxXLMRobertaPreTrainedModel,
										)

else:
					import sys

					lowerCAmelCase__				    =       _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)









"""simple docstring"""







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 				SCREAMING_SNAKE_CASE__    (		lowercase    ):
       """simple docstring"""


       a  :    Dict       ="autoformer"
       a  :    Dict       ={
           "hidden_size": "d_model",
           "num_attention_heads": "encoder_attention_heads",
           "num_hidden_layers": "encoder_layers",
       }

       def __init__(						self		,					snake_case__ = None		,					snake_case__ = None		,					snake_case__ = "student_t"		,					snake_case__ = "nll"		,					snake_case__ = 1		,					snake_case__ = [1, 2, 3, 4, 5, 6, 7]		,					snake_case__ = True		,					snake_case__ = 0		,					snake_case__ = 0		,					snake_case__ = 0		,					snake_case__ = 0		,					snake_case__ = None		,					snake_case__ = None		,					snake_case__ = 64		,					snake_case__ = 2		,					snake_case__ = 2		,					snake_case__ = 2		,					snake_case__ = 2		,					snake_case__ = 32		,					snake_case__ = 32		,					snake_case__ = "gelu"		,					snake_case__ = 0.1		,					snake_case__ = 0.1		,					snake_case__ = 0.1		,					snake_case__ = 0.1		,					snake_case__ = 0.1		,					snake_case__ = 100		,					snake_case__ = 0.02		,					snake_case__ = True		,					snake_case__=True		,					snake_case__ = 10		,					snake_case__ = 25		,					snake_case__ = 3		,					**snake_case__		,					):






         """simple docstring"""





         lowerCAmelCase					:					Any								=							prediction_length
         lowerCAmelCase					:					Dict								=							context_length if context_length is not None else prediction_length
         lowerCAmelCase					:					Tuple								=							distribution_output
         lowerCAmelCase					:					List[Any]								=							loss
         lowerCAmelCase					:					int								=							input_size
         lowerCAmelCase					:					str								=							num_time_features
         lowerCAmelCase					:					str								=							lags_sequence
         lowerCAmelCase					:					List[str]								=							scaling
         lowerCAmelCase					:					List[Any]								=							num_dynamic_real_features
         lowerCAmelCase					:					Tuple								=							num_static_real_features
         lowerCAmelCase					:					Dict								=							num_static_categorical_features
         if cardinality is not None and num_static_categorical_features > 0:
           if len(snake_case__						) != num_static_categorical_features:
             raise ValueError(
                 "The cardinality should be a list of the same length as `num_static_categorical_features`"						)
           lowerCAmelCase					:					Any								=							cardinality
         else:
           lowerCAmelCase					:					Union[str, Any]								=							[0]
         if embedding_dimension is not None and num_static_categorical_features > 0:
           if len(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					:					Tuple								=							embedding_dimension
         else:
           lowerCAmelCase					:					Any								=							[min(50		,					(cat + 1) // 2						) for cat in self.cardinality]
         lowerCAmelCase					:					Any								=							num_parallel_samples

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

         lowerCAmelCase					:					List[Any]								=							dropout
         lowerCAmelCase					:					Optional[int]								=							attention_dropout
         lowerCAmelCase					:					Union[str, Any]								=							activation_dropout
         lowerCAmelCase					:					Optional[int]								=							encoder_layerdrop
         lowerCAmelCase					:					Dict								=							decoder_layerdrop

         lowerCAmelCase					:					Tuple								=							activation_function
         lowerCAmelCase					:					Optional[Any]								=							init_std

         lowerCAmelCase					:					List[Any]								=							use_cache

         # Autoformer
         lowerCAmelCase					:					Any								=							label_length
         lowerCAmelCase					:					Any								=							moving_average
         lowerCAmelCase					:					Optional[Any]								=							autocorrelation_factor

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







       @property
       def 	lowercase__							(						self						):






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





