


'''simple docstring'''



from typing import List, Optional, Union

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


A__						:   Optional[Any]				=    logging.get_logger(__name__)

A__						:   Dict				=    {
    """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   UpperCAmelCase_    (_UpperCAmelCase    ):





    """simple docstring"""






    lowerCamelCase    :   List[Any]					=     'time_series_transformer'
    lowerCamelCase    :   Union[str, Any]					=     {
        'hidden_size': 'd_model',
        'num_attention_heads': 'encoder_attention_heads',
        'num_hidden_layers': 'encoder_layers',
    }







    def __init__(				self     ,	SCREAMING_SNAKE_CASE_ = None     ,	SCREAMING_SNAKE_CASE_ = None     ,	SCREAMING_SNAKE_CASE_ = "student_t"     ,	SCREAMING_SNAKE_CASE_ = "nll"     ,	SCREAMING_SNAKE_CASE_ = 1     ,	SCREAMING_SNAKE_CASE_ = [1, 2, 3, 4, 5, 6, 7]     ,	SCREAMING_SNAKE_CASE_ = "mean"     ,	SCREAMING_SNAKE_CASE_ = 0     ,	SCREAMING_SNAKE_CASE_ = 0     ,	SCREAMING_SNAKE_CASE_ = 0     ,	SCREAMING_SNAKE_CASE_ = 0     ,	SCREAMING_SNAKE_CASE_ = None     ,	SCREAMING_SNAKE_CASE_ = None     ,	SCREAMING_SNAKE_CASE_ = 32     ,	SCREAMING_SNAKE_CASE_ = 32     ,	SCREAMING_SNAKE_CASE_ = 2     ,	SCREAMING_SNAKE_CASE_ = 2     ,	SCREAMING_SNAKE_CASE_ = 2     ,	SCREAMING_SNAKE_CASE_ = 2     ,	SCREAMING_SNAKE_CASE_ = True     ,	SCREAMING_SNAKE_CASE_ = "gelu"     ,	SCREAMING_SNAKE_CASE_ = 64     ,	SCREAMING_SNAKE_CASE_ = 0.1     ,	SCREAMING_SNAKE_CASE_ = 0.1     ,	SCREAMING_SNAKE_CASE_ = 0.1     ,	SCREAMING_SNAKE_CASE_ = 0.1     ,	SCREAMING_SNAKE_CASE_ = 0.1     ,	SCREAMING_SNAKE_CASE_ = 1_00     ,	SCREAMING_SNAKE_CASE_ = 0.0_2     ,	SCREAMING_SNAKE_CASE_=True     ,	**SCREAMING_SNAKE_CASE_     ,	)							->	Any:
         # time series specific configuration
         __lowerCamelCase  :      Tuple														=						prediction_length
         __lowerCamelCase  :      List[str]														=						context_length or prediction_length
         __lowerCamelCase  :      str														=						distribution_output
         __lowerCamelCase  :      Any														=						loss
         __lowerCamelCase  :      List[str]														=						input_size
         __lowerCamelCase  :      List[str]														=						num_time_features
         __lowerCamelCase  :      str														=						lags_sequence
         __lowerCamelCase  :      List[Any]														=						scaling
         __lowerCamelCase  :      Dict														=						num_dynamic_real_features
         __lowerCamelCase  :      Optional[Any]														=						num_static_real_features
         __lowerCamelCase  :      Optional[Any]														=						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  :      Union[str, Any]														=						cardinality
         else:
              __lowerCamelCase  :      int														=						[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  :      Optional[int]														=						embedding_dimension
         else:
              __lowerCamelCase  :      int														=						[min(50     ,	(cat + 1) // 2      ) for cat in self.cardinality]
         __lowerCamelCase  :      List[Any]														=						num_parallel_samples

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

         __lowerCamelCase  :      Any														=						dropout
         __lowerCamelCase  :      str														=						attention_dropout
         __lowerCamelCase  :      Tuple														=						activation_dropout
         __lowerCamelCase  :      Tuple														=						encoder_layerdrop
         __lowerCamelCase  :      Optional[Any]														=						decoder_layerdrop

         __lowerCamelCase  :      Optional[int]														=						activation_function
         __lowerCamelCase  :      Dict														=						init_std

         __lowerCamelCase  :      Any														=						use_cache

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







    @property
    def  lowercase_							(				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
         )










from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


SCREAMING_SNAKE_CASE							    =							{
    'configuration_tapas': ['TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP', 'TapasConfig'],
    'tokenization_tapas': ['TapasTokenizer'],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE							    =							[
      'TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST',
      'TapasForMaskedLM',
      'TapasForQuestionAnswering',
      'TapasForSequenceClassification',
      'TapasModel',
      'TapasPreTrainedModel',
      'load_tf_weights_in_tapas',
  ]
try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  SCREAMING_SNAKE_CASE							    =							[
      'TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST',
      'TFTapasForMaskedLM',
      'TFTapasForQuestionAnswering',
      'TFTapasForSequenceClassification',
      'TFTapasModel',
      'TFTapasPreTrainedModel',
  ]


if TYPE_CHECKING:
  from .configuration_tapas import TAPAS_PRETRAINED_CONFIG_ARCHIVE_MAP, TapasConfig
  from .tokenization_tapas import TapasTokenizer

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tapas import (
        TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST,
        TapasForMaskedLM,
        TapasForQuestionAnswering,
        TapasForSequenceClassification,
        TapasModel,
        TapasPreTrainedModel,
        load_tf_weights_in_tapas,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_tapas import (
        TF_TAPAS_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFTapasForMaskedLM,
        TFTapasForQuestionAnswering,
        TFTapasForSequenceClassification,
        TFTapasModel,
        TFTapasPreTrainedModel,
    )


else:
  import sys

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



