


"""simple docstring"""







from collections import OrderedDict
from typing import Any, List, Mapping, Optional

from ... import PreTrainedTokenizer, TensorType, is_torch_available
from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfigWithPast, PatchingSpec
from ...utils import logging


lowerCAmelCase__      				=   logging.get_logger(__name__)

lowerCAmelCase__      				=   {
    '''EleutherAI/gpt-j-6B''': '''https://huggingface.co/EleutherAI/gpt-j-6B/resolve/main/config.json''',
    # See all GPT-J models at https://huggingface.co/models?filter=gpt_j
}


class       SCREAMING_SNAKE_CASE__				(		lowercase				):
       """simple docstring"""


       a  :				Any   ="gptj"
       a  :				Any   ={
           "max_position_embeddings": "n_positions",
           "hidden_size": "n_embd",
           "num_attention_heads": "n_head",
           "num_hidden_layers": "n_layer",
       }

       def __init__(						self		,     snake_case__=50_400		,     snake_case__=2_048		,     snake_case__=4_096		,     snake_case__=28		,     snake_case__=16		,     snake_case__=64		,     snake_case__=None		,     snake_case__="gelu_new"		,     snake_case__=0.0		,     snake_case__=0.0		,     snake_case__=0.0		,     snake_case__=1e-5		,     snake_case__=0.02		,     snake_case__=True		,     snake_case__=50_256		,     snake_case__=50_256		,     snake_case__=False		,     **snake_case__		,     ):






         """simple docstring"""





         lowerCAmelCase     :     Any								=							vocab_size
         lowerCAmelCase     :     Tuple								=							n_positions
         lowerCAmelCase     :     List[Any]								=							n_embd
         lowerCAmelCase     :     Any								=							n_layer
         lowerCAmelCase     :     List[Any]								=							n_head
         lowerCAmelCase     :     Optional[int]								=							n_inner
         lowerCAmelCase     :     List[str]								=							rotary_dim
         lowerCAmelCase     :     Dict								=							activation_function
         lowerCAmelCase     :     Dict								=							resid_pdrop
         lowerCAmelCase     :     List[Any]								=							embd_pdrop
         lowerCAmelCase     :     List[str]								=							attn_pdrop
         lowerCAmelCase     :     Optional[int]								=							layer_norm_epsilon
         lowerCAmelCase     :     Optional[int]								=							initializer_range
         lowerCAmelCase     :     int								=							use_cache

         lowerCAmelCase     :     Dict								=							bos_token_id
         lowerCAmelCase     :     List[str]								=							eos_token_id

         super().__init__(
             bos_token_id=snake_case__		,     eos_token_id=snake_case__		,     tie_word_embeddings=snake_case__		,     **snake_case__						)


class       SCREAMING_SNAKE_CASE__				(		lowercase				):
       """simple docstring"""


       def __init__(						self		,     snake_case__		,     snake_case__ = "default"		,     snake_case__ = None		,     snake_case__ = False		,     ):






         """simple docstring"""





         super().__init__(snake_case__		,     task=snake_case__		,     patching_specs=snake_case__		,     use_past=snake_case__						)
         if not getattr(self._config		,     "pad_token_id"		,     snake_case__						):
           # TODO: how to do that better?
           lowerCAmelCase     :     Any								=							0

       @property
       def        lowercase__							(						self						):






         """simple docstring"""





         lowerCAmelCase     :     Dict								=							OrderedDict({"input_ids": {0: "batch", 1: "sequence"}}						)
         if self.use_past:
           self.fill_with_past_key_values_(snake_case__		,     direction="inputs"						)
           lowerCAmelCase     :     int								=							{0: "batch", 1: "past_sequence + sequence"}
         else:
           lowerCAmelCase     :     Optional[int]								=							{0: "batch", 1: "sequence"}

         return common_inputs

       @property
       def        lowercase__							(						self						):






         """simple docstring"""





         return self._config.n_layer

       @property
       def        lowercase__							(						self						):






         """simple docstring"""





         return self._config.n_head

       def        lowercase__							(						self		,     snake_case__		,     snake_case__ = -1		,     snake_case__ = -1		,     snake_case__ = False		,     snake_case__ = None		,     ):






         """simple docstring"""





         lowerCAmelCase     :     Tuple								=							super(snake_case__		,     self						).generate_dummy_inputs(
             snake_case__		,     batch_size=snake_case__		,     seq_length=snake_case__		,     is_pair=snake_case__		,     framework=snake_case__						)

         # We need to order the input in the way they appears in the forward()
         lowerCAmelCase     :     List[str]								=							OrderedDict({"input_ids": common_inputs["input_ids"]}						)

         # Need to add the past_keys
         if self.use_past:
           if not is_torch_available():
             raise ValueError("Cannot generate dummy past_keys inputs without PyTorch installed."						)
           else:
             import torch

             lowerCAmelCase						,  lowerCAmelCase     :     Dict								=							common_inputs["input_ids"].shape
             # Not using the same length for past_key_values
             lowerCAmelCase     :     Dict								=							seqlen + 2
             lowerCAmelCase     :     Dict								=							(
                 batch,
                 self.num_attention_heads,
                 past_key_values_length,
                 self._config.hidden_size // self.num_attention_heads,
             )
             lowerCAmelCase     :     Union[str, Any]								=							[
                 (torch.zeros(snake_case__						), torch.zeros(snake_case__						)) for _ in range(self.num_layers						)
             ]

         lowerCAmelCase     :     Optional[Any]								=							common_inputs["attention_mask"]
         if self.use_past:
           lowerCAmelCase     :     Optional[Any]								=							ordered_inputs["attention_mask"].dtype
           lowerCAmelCase     :     Union[str, Any]								=							torch.cat(
               [ordered_inputs["attention_mask"], torch.ones(snake_case__		,     snake_case__		,     dtype=snake_case__						)]		,     dim=1						)

         return ordered_inputs







       @property
       def        lowercase__							(						self						):






         """simple docstring"""





         return 13








"""simple docstring"""





from typing import List, Optional, Union

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


_a       =							logging.get_logger(__name__)

_a       =							{
    '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  (	lowercase   ):







 """simple docstring"""







 __UpperCAmelCase	:					int   		=	"time_series_transformer"
 __UpperCAmelCase	:					Any   		=	{
     "hidden_size": "d_model",
     "num_attention_heads": "encoder_attention_heads",
     "num_hidden_layers": "encoder_layers",
 }


 def __init__(			self							:			int,					UpperCAmelCase__							:			Optional[int] = None,					UpperCAmelCase__							:			Optional[int] = None,					UpperCAmelCase__							:			str = "student_t",					UpperCAmelCase__							:			str = "nll",					UpperCAmelCase__							:			int = 1,					UpperCAmelCase__							:			List[int] = [1, 2, 3, 4, 5, 6, 7],					UpperCAmelCase__							:			Optional[Union[str, bool]] = "mean",					UpperCAmelCase__							:			int = 0,					UpperCAmelCase__							:			int = 0,					UpperCAmelCase__							:			int = 0,					UpperCAmelCase__							:			int = 0,					UpperCAmelCase__							:			Optional[List[int]] = None,					UpperCAmelCase__							:			Optional[List[int]] = None,					UpperCAmelCase__							:			int = 3_2,					UpperCAmelCase__							:			int = 3_2,					UpperCAmelCase__							:			int = 2,					UpperCAmelCase__							:			int = 2,					UpperCAmelCase__							:			int = 2,					UpperCAmelCase__							:			int = 2,					UpperCAmelCase__							:			bool = True,					UpperCAmelCase__							:			str = "gelu",					UpperCAmelCase__							:			int = 6_4,					UpperCAmelCase__							:			float = 0.1,					UpperCAmelCase__							:			float = 0.1,					UpperCAmelCase__							:			float = 0.1,					UpperCAmelCase__							:			float = 0.1,					UpperCAmelCase__							:			float = 0.1,					UpperCAmelCase__							:			int = 1_0_0,					UpperCAmelCase__							:			float = 0.02,					UpperCAmelCase__							:			Any=True,					**UpperCAmelCase__							:			List[str],					):
    # time series specific configuration
    __lowercase								=						prediction_length
    __lowercase								=						context_length or prediction_length
    __lowercase								=						distribution_output
    __lowercase								=						loss
    __lowercase								=						input_size
    __lowercase								=						num_time_features
    __lowercase								=						lags_sequence
    __lowercase								=						scaling
    __lowercase								=						num_dynamic_real_features
    __lowercase								=						num_static_real_features
    __lowercase								=						num_static_categorical_features
    if cardinality 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`"	)
       __lowercase								=						cardinality
    else:
       __lowercase								=						[0]
    if embedding_dimension 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`"	)
       __lowercase								=						embedding_dimension
    else:
       __lowercase								=						[min(5_0,					(cat + 1) // 2	) for cat in self.cardinality]
    __lowercase								=						num_parallel_samples

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

    __lowercase								=						dropout
    __lowercase								=						attention_dropout
    __lowercase								=						activation_dropout
    __lowercase								=						encoder_layerdrop
    __lowercase								=						decoder_layerdrop

    __lowercase								=						activation_function
    __lowercase								=						init_std

    __lowercase								=						use_cache

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



 @property
 def 					_lowercase (			self							:			Optional[Any]	):
    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
    )




