class_docstr: Implementaion of Deep AR model
class_docstr_tok: ["Implementaion","of","Deep","AR","model"]
code: def __init__(self, config: DeepARConfig):
      super().__init__(config)
  
      assert len(config.lags_seq) > 0, "lags_seq must not be empty!"
      self.lags_seq = config.lags_seq
      self.n_past = config.n_past
      self.n_context = config.n_past - max(self.lags_seq)
      self.max_forecast_steps = config.max_forecast_steps
      self.output_size = config.dim
  
      freq_map = {
          "h": 4,
          "t": 5,
          "s": 6,
          "m": 1,
          "a": 1,
          "w": 2,
          "d": 3,
          "b": 3,
      }
  
      input_size = (
          len(self.lags_seq) * self.output_size
          + freq_map[config.ts_encoding]
      )
  
      # for decoding the lags are shifted by one, at the first time-step
      # of the decoder a lag of one corresponds to the last target value
      self.shifted_lags = [l - 1 for l in self.lags_seq]
      self.num_prediction_samples = config.num_prediction_samples
  
      if config.hidden_size is None:
          hidden_size = int(4 * (1 + math.pow(math.log(config.dim), 4)))
      else:
          hidden_size = config.hidden_size
  
      self.rnn = nn.LSTM(
          input_size,
          hidden_size=hidden_size,
          num_layers=config.num_hidden_layers,
          batch_first=True,
      )
  
      self.distr_proj = nn.Sequential(
          nn.Linear(hidden_size, hidden_size),
          nn.ReLU(),
          nn.Linear(hidden_size, self.output_size * 2),
      )
  
      self.loss_fn = self.config.loss_fn.value()
  
imports: import copy
  import logging
  import math
  import numpy
  import pandas
  from typing import List, Optional, Tuple, Union
  from merlion.utils.misc import initializer
  from merlion.models.base import NormalizingConfig
  from merlion.models.deep_base import TorchModel, LossFunction
  from merlion.models.forecast.deep_base import DeepForecasterConfig, DeepForecaster
label_desc: Use image node_id 1 to create a new DeepARModel object from inherited base classes: TorchModel with example: obj = DeepARModel(config)