class_docstr: LightningModule class for the model MQF2 proposed in the paper
  ``Multivariate Quantile Function Forecaster``
  by Kan, Aubet, Januschowski, Park, Benidis, Ruthotto, Gasthaus
  
  This is the multi-horizon (multivariate in time step) variant of MQF2
  
  This class is based on
  gluonts.torch.model.deepar.lightning_module.DeepARLightningModule
  
  Parameters
  ----------
  model_kwargs
      Keyword arguments to construct the ``MQF2MultiHorizonModel`` to be trained.
  loss
      Distribution loss.
  lr
      Learning rate.
  weight_decay
      Weight decay during training.
  patience
      Patience parameter for learning rate scheduler, default: ``10``.
docstr: Function to compute loss.
  
  Given time series, unroll the RNN over the context window
  and pass the hidden states to the forecaster
  then the loss with respect to the prediction is computed
  
  Parameters
  ----------
  batch
      Dictionary containing the (past and future) features
      and target values in a batch
  
  Returns
  -------
  loss
      Mean of the loss values
docstr_tok: ["Function","to","compute","loss",".","Given","time","series",",","unroll","the","RNN","over","the","context","window","and","pass","the","hidden","states","to","the","forecaster","then","the","loss","with","respect","to","the","prediction","is","computed","Parameters","--","--","--","--","--","batch","Dictionary","containing","the","(","past","and","future",")","features","and","target","values","in","a","batch","Returns","--","--","--","-","loss","Mean","of","the","loss","values"]
code: def _compute_loss(
      self, batch: Dict[str, torch.Tensor]
  ) -> torch.Tensor:
      """
      Function to compute loss.
  
      Given time series, unroll the RNN over the context window
      and pass the hidden states to the forecaster
      then the loss with respect to the prediction is computed
  
      Parameters
      ----------
      batch
          Dictionary containing the (past and future) features
          and target values in a batch
  
      Returns
      -------
      loss
          Mean of the loss values
      """
  
      feat_static_cat = batch["feat_static_cat"]
      feat_static_real = batch["feat_static_real"]
      past_time_feat = batch["past_time_feat"]
      past_target = batch["past_target"]
      future_time_feat = batch["future_time_feat"]
      future_target = batch["future_target"]
      past_observed_values = batch["past_observed_values"]
  
      picnn = self.model.picnn
  
      _, scale, hidden_state, _, _ = self.model.unroll_lagged_rnn(
          feat_static_cat,
          feat_static_real,
          past_time_feat,
          past_target,
          past_observed_values,
          future_time_feat,
          future_target,
      )
  
      hidden_state = hidden_state[:, : self.model.context_length]
  
      distr = self.model.output_distribution(picnn, hidden_state, scale)
  
      context_target = past_target[:, -self.model.context_length + 1 :]
      target = torch.cat(
          (context_target, future_target),
          dim=1,
      )
  
      loss_values = self.loss(distr, target)
  
      return loss_values.mean()
  
file_path: gluonts/src/gluonts/torch/model/mqf2/lightning_module.py
imports: from typing import Dict
  import lightning.pytorch
  import torch
  from torch.optim.lr_scheduler import ReduceLROnPlateau
  from gluonts.core.component import validated
  from gluonts.itertools import select
  from .module import MQF2MultiHorizonModel
label_desc: Use image node_id 3 for calling the MQF2MultiHorizonLightningModule obj's underlying member method code with example usage: obj._compute_loss(batch) and returns: loss_values