




"""simple docstring"""

from typing import TYPE_CHECKING

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


a							      =     {
    "configuration_bloom": ["BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP", "BloomConfig", "BloomOnnxConfig"],
}
try:
       if not is_tokenizers_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       a							      =     ["BloomTokenizerFast"]

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       a							      =     [
           "BLOOM_PRETRAINED_MODEL_ARCHIVE_LIST",
           "BloomForCausalLM",
           "BloomModel",
           "BloomPreTrainedModel",
           "BloomForSequenceClassification",
           "BloomForTokenClassification",
           "BloomForQuestionAnswering",
       ]

if TYPE_CHECKING:
       from .configuration_bloom import BLOOM_PRETRAINED_CONFIG_ARCHIVE_MAP, BloomConfig, BloomOnnxConfig

       try:
              if not is_tokenizers_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .tokenization_bloom_fast import BloomTokenizerFast

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_bloom import (
                  BLOOM_PRETRAINED_MODEL_ARCHIVE_LIST,
                  BloomForCausalLM,
                  BloomForQuestionAnswering,
                  BloomForSequenceClassification,
                  BloomForTokenClassification,
                  BloomModel,
                  BloomPreTrainedModel,
              )

else:
       import sys

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


'''simple docstring'''


from typing import List, Optional, Union

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


__lowerCAmelCase						:							Union[str, Any]    							=						logging.get_logger(__name__)

__lowerCAmelCase						:							Optional[int]    							=						{
    "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     A ( UpperCAmelCase ):
							a_										=   '''time_series_transformer'''
							a_										=   {
							    '''hidden_size''': '''d_model''',
							    '''num_attention_heads''': '''encoder_attention_heads''',
							    '''num_hidden_layers''': '''encoder_layers''',
							}





							def __init__(   self					:				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					:				Optional[Union[str, bool]] = "mean"  ,		__a					:				int = 0  ,		__a					:				int = 0  ,		__a					:				int = 0  ,		__a					:				int = 0  ,		__a					:				Optional[List[int]] = None  ,		__a					:				Optional[List[int]] = None  ,		__a					:				int = 3_2  ,		__a					:				int = 3_2  ,		__a					:				int = 2  ,		__a					:				int = 2  ,		__a					:				int = 2  ,		__a					:				int = 2  ,		__a					:				bool = True  ,		__a					:				str = "gelu"  ,		__a					:				int = 6_4  ,		__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					:				Optional[int]=True  ,		**__a					:				str  ,		)				->						int:
								# time series specific configuration
								__UpperCAmelCase      					=      prediction_length
								__UpperCAmelCase      					=      context_length or prediction_length
								__UpperCAmelCase      					=      distribution_output
								__UpperCAmelCase      					=      loss
								__UpperCAmelCase      					=      input_size
								__UpperCAmelCase      					=      num_time_features
								__UpperCAmelCase      					=      lags_sequence
								__UpperCAmelCase      					=      scaling
								__UpperCAmelCase      					=      num_dynamic_real_features
								__UpperCAmelCase      					=      num_static_real_features
								__UpperCAmelCase      					=      num_static_categorical_features
								if cardinality and num_static_categorical_features > 0:
									if len(__a						) != num_static_categorical_features:
										raise ValueError(
										    '''The cardinality should be a list of the same length as `num_static_categorical_features`'''						)
									__UpperCAmelCase      					=      cardinality
								else:
									__UpperCAmelCase      					=      [0]
								if embedding_dimension and num_static_categorical_features > 0:
									if len(__a						) != num_static_categorical_features:
										raise ValueError(
										    '''The embedding dimension should be a list of the same length as `num_static_categorical_features`'''						)
									__UpperCAmelCase      					=      embedding_dimension
								else:
									__UpperCAmelCase      					=      [min(5_0  ,		(cat + 1) // 2						) for cat in self.cardinality]
								__UpperCAmelCase      					=      num_parallel_samples

								# Transformer architecture configuration
								__UpperCAmelCase      					=      input_size * len(__a						) + self._number_of_features
								__UpperCAmelCase      					=      d_model
								__UpperCAmelCase      					=      encoder_attention_heads
								__UpperCAmelCase      					=      decoder_attention_heads
								__UpperCAmelCase      					=      encoder_ffn_dim
								__UpperCAmelCase      					=      decoder_ffn_dim
								__UpperCAmelCase      					=      encoder_layers
								__UpperCAmelCase      					=      decoder_layers

								__UpperCAmelCase      					=      dropout
								__UpperCAmelCase      					=      attention_dropout
								__UpperCAmelCase      					=      activation_dropout
								__UpperCAmelCase      					=      encoder_layerdrop
								__UpperCAmelCase      					=      decoder_layerdrop

								__UpperCAmelCase      					=      activation_function
								__UpperCAmelCase      					=      init_std

								__UpperCAmelCase      					=      use_cache

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






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