class_docstr: Implementaion of Deep AR model
class_docstr_tok: ["Implementaion","of","Deep","AR","model"]
code: def calculate_loss(
      self, past, past_timestamp, future, future_timestamp
  ):
      rnn_outputs, _ = self.unroll_encoder(
          past, past_timestamp, future_timestamp, future
      )
      distr_proj_out = self.distr_proj(rnn_outputs)
  
      mu, log_sigma = torch.split(
          distr_proj_out, self.config.dim, dim=-1
      )
      sigma = torch.log(1 + torch.exp(log_sigma)) + 1e-07
  
      target_future = torch.cat(
          (past[:, (self.n_past - self.n_context) :, :], future), dim=1
      )
  
      loss = self.loss_fn(mu, target_future, torch.square(sigma))
  
      return loss
  
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 4 for calling the DeepARModel obj's underlying member method code with example usage: obj.calculate_loss(past, past_timestamp, future, future_timestamp) and returns: loss