

from typing import List, Optional

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


_lowerCamelCase				:   Dict					   =							logging.get_logger(__name__)

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





class 					__UpperCAmelCase     (       UpperCAmelCase_						):
   UpperCamelCase        =     'autoformer'
   UpperCamelCase        =     {
       'hidden_size': 'd_model',
       'num_attention_heads': 'encoder_attention_heads',
       'num_hidden_layers': 'encoder_layers',
   }



   def __init__(							self							:     List[str],		__A							:     Optional[int] = None,		__A							:     Optional[int] = None,		__A							:     str = "student_t",		__A							:     str = "nll",		__A							:     int = 1,		__A							:     List[int] = [1, 2, 3, 4, 5, 6, 7],		__A							:     bool = True,		__A							:     int = 0,		__A							:     int = 0,		__A							:     int = 0,		__A							:     int = 0,		__A							:     Optional[List[int]] = None,		__A							:     Optional[List[int]] = None,		__A							:     int = 6_4,		__A							:     int = 2,		__A							:     int = 2,		__A							:     int = 2,		__A							:     int = 2,		__A							:     int = 3_2,		__A							:     int = 3_2,		__A							:     str = "gelu",		__A							:     float = 0.1,		__A							:     float = 0.1,		__A							:     float = 0.1,		__A							:     float = 0.1,		__A							:     float = 0.1,		__A							:     int = 1_0_0,		__A							:     float = 0.0_2,		__A							:     bool = True,		__A							:     int=True,		__A							:     int = 1_0,		__A							:     int = 2_5,		__A							:     int = 3,		**__A							:     str,		):
     UpperCAmelCase       :							Optional[int]  = prediction_length
     UpperCAmelCase       :							Dict  = context_length if context_length is not None else prediction_length
     UpperCAmelCase       :							str  = distribution_output
     UpperCAmelCase       :							List[str]  = loss
     UpperCAmelCase       :							Dict  = input_size
     UpperCAmelCase       :							str  = num_time_features
     UpperCAmelCase       :							List[str]  = lags_sequence
     UpperCAmelCase       :							Tuple  = scaling
     UpperCAmelCase       :							Dict  = num_dynamic_real_features
     UpperCAmelCase       :							List[Any]  = num_static_real_features
     UpperCAmelCase       :							Tuple  = num_static_categorical_features
     if cardinality is not None and num_static_categorical_features > 0:
       if len(__UpperCAmelCase						) != num_static_categorical_features:
         raise ValueError(
             '''The cardinality should be a list of the same length as `num_static_categorical_features`'''						)
       UpperCAmelCase       :							Any  = cardinality
     else:
       UpperCAmelCase       :							List[str]  = [0]
     if embedding_dimension is not None and num_static_categorical_features > 0:
       if len(__UpperCAmelCase						) != num_static_categorical_features:
         raise ValueError(
             '''The embedding dimension should be a list of the same length as `num_static_categorical_features`'''						)
       UpperCAmelCase       :							Tuple  = embedding_dimension
     else:
       UpperCAmelCase       :							Optional[int]  = [min(5_0,		(cat + 1) // 2						) for cat in self.cardinality]
     UpperCAmelCase       :							Optional[int]  = num_parallel_samples

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

     UpperCAmelCase       :							int  = dropout
     UpperCAmelCase       :							int  = attention_dropout
     UpperCAmelCase       :							Dict  = activation_dropout
     UpperCAmelCase       :							List[Any]  = encoder_layerdrop
     UpperCAmelCase       :							Tuple  = decoder_layerdrop

     UpperCAmelCase       :							Any  = activation_function
     UpperCAmelCase       :							Union[str, Any]  = init_std

     UpperCAmelCase       :							Union[str, Any]  = use_cache

     # Autoformer
     UpperCAmelCase       :							int  = label_length
     UpperCAmelCase       :							str  = moving_average
     UpperCAmelCase       :							Union[str, Any]  = autocorrelation_factor

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





   @property
   def        __magic_name__    (							self							:     List[str]						):
     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 os
import tempfile
import unittest

from transformers.models.marian.convert_marian_tatoeba_to_pytorch import DEFAULT_REPO, TatoebaConverter
from transformers.testing_utils import slow
from transformers.utils import cached_property





@unittest.skipUnless(os.path.exists(UpperCAmelCase_     )		,				'Tatoeba directory does not exist.'     )
class      A							(				unittest.TestCase     ):


   @cached_property
   def 			lowercase_      (self     :						Optional[int]		)						->				List[Any]:
         """simple docstring"""



         UpperCAmelCase__								=  tempfile.mkdtemp()
         return TatoebaConverter(save_dir=__UpperCAmelCase		)


   @slow
   def 			lowercase_      (self     :						List[Any]		)						->				Optional[int]:
         """simple docstring"""



         self.resolver.convert_models(["heb-eng"]		)





   @slow
   def 			lowercase_      (self     :						Dict		)						->				List[str]:
         """simple docstring"""



         UpperCAmelCase__		,      UpperCAmelCase__								=  self.resolver.write_model_card("opus-mt-he-en"       ,  dry_run=__UpperCAmelCase		)
         assert mmeta["long_pair"] == "heb-eng"



