docstr: Unrolls the RNN encoder over past and, if present, future data. Returns
  outputs and state of the encoder, plus the scale of past_target_cdf and
  a vector of static features that was constructed and fed as input to
  the encoder. All tensor arguments should have NTC layout.
  
  Parameters
  ----------
  F
  past_time_feat
      Past time features (batch_size, history_length, num_features)
  past_target_cdf
      Past marginal CDF transformed target values (batch_size,
      history_length, target_dim)
  past_observed_values
      Indicator whether or not the values were observed (batch_size,
      history_length, target_dim)
  past_is_pad
      Indicator whether the past target values have been padded
      (batch_size, history_length)
  future_time_feat
      Future time features (batch_size, prediction_length, num_features)
  future_target_cdf
      Future marginal CDF transformed target values (batch_size,
      prediction_length, target_dim)
  target_dimension_indicator
      Dimensionality of the time series (batch_size, target_dim)
  
  Returns
  -------
  outputs
      RNN outputs (batch_size, seq_len, num_cells)
  states
      RNN states. Nested list with (batch_size, num_cells) tensors with
  dimensions target_dim x num_layers x (batch_size, num_cells)
  scale
      Mean scales for the time series (batch_size, 1, target_dim)
  lags_scaled
      Scaled lags(batch_size, sub_seq_len, target_dim, num_lags)
  inputs
      inputs to the RNN
docstr_tok: ["Unrolls","the","RNN","encoder","over","past","and",",","if","present",",","future","data",".","Returns","outputs","and","state","of","the","encoder",",","plus","the","scale","of","past_target_cdf","and","a","vector","of","static","features","that","was","constructed","and","fed","as","input","to","the","encoder",".","All","tensor","arguments","should","have","NTC","layout",".","Parameters","--","--","--","--","--","F","past_time_feat","Past","time","features","(","batch_size",",","history_length",",","num_features",")","past_target_cdf","Past","marginal","CDF","transformed","target","values","(","batch_size",",","history_length",",","target_dim",")","past_observed_values","Indicator","whether","or","not","the","values","were","observed","(","batch_size",",","history_length",",","target_dim",")","past_is_pad","Indicator","whether","the","past","target","values","have","been","padded","(","batch_size",",","history_length",")","future_time_feat","Future","time","features","(","batch_size",",","prediction_length",",","num_features",")","future_target_cdf","Future","marginal","CDF","transformed","target","values","(","batch_size",",","prediction_length",",","target_dim",")","target_dimension_indicator","Dimensionality","of","the","time","series","(","batch_size",",","target_dim",")","Returns","--","--","--","-","outputs","RNN","outputs","(","batch_size",",","seq_len",",","num_cells",")","states","RNN","states",".","Nested","list","with","(","batch_size",",","num_cells",")","tensors","with","dimensions","target_dim","x","num_layers","x","(","batch_size",",","num_cells",")","scale","Mean","scales","for","the","time","series","(","batch_size",",","1",",","target_dim",")","lags_scaled","Scaled","lags","(","batch_size",",","sub_seq_len",",","target_dim",",","num_lags",")","inputs","inputs","to","the","RNN"]
code: def unroll_encoder(
      self,
      F,
      past_time_feat: Tensor,
      past_target_cdf: Tensor,
      past_observed_values: Tensor,
      past_is_pad: Tensor,
      future_time_feat: Optional[Tensor],
      future_target_cdf: Optional[Tensor],
      target_dimension_indicator: Tensor,
  ) -> Tuple[Tensor, List[Tensor], Tensor, Tensor, Tensor]:
      """
      Unrolls the RNN encoder over past and, if present, future data. Returns
      outputs and state of the encoder, plus the scale of past_target_cdf and
      a vector of static features that was constructed and fed as input to
      the encoder. All tensor arguments should have NTC layout.
  
      Parameters
      ----------
      F
      past_time_feat
          Past time features (batch_size, history_length, num_features)
      past_target_cdf
          Past marginal CDF transformed target values (batch_size,
          history_length, target_dim)
      past_observed_values
          Indicator whether or not the values were observed (batch_size,
          history_length, target_dim)
      past_is_pad
          Indicator whether the past target values have been padded
          (batch_size, history_length)
      future_time_feat
          Future time features (batch_size, prediction_length, num_features)
      future_target_cdf
          Future marginal CDF transformed target values (batch_size,
          prediction_length, target_dim)
      target_dimension_indicator
          Dimensionality of the time series (batch_size, target_dim)
  
      Returns
      -------
      outputs
          RNN outputs (batch_size, seq_len, num_cells)
      states
          RNN states. Nested list with (batch_size, num_cells) tensors with
      dimensions target_dim x num_layers x (batch_size, num_cells)
      scale
          Mean scales for the time series (batch_size, 1, target_dim)
      lags_scaled
          Scaled lags(batch_size, sub_seq_len, target_dim, num_lags)
      inputs
          inputs to the RNN
      """
  
      past_observed_values = F.broadcast_minimum(
          past_observed_values, 1 - past_is_pad.expand_dims(axis=-1)
      )
  
      if future_time_feat is None or future_target_cdf is None:
          time_feat = past_time_feat.slice_axis(
              axis=1, begin=-self.context_length, end=None
          )
          sequence = past_target_cdf
          sequence_length = self.history_length
          subsequences_length = self.context_length
      else:
          time_feat = F.concat(
              past_time_feat.slice_axis(
                  axis=1, begin=-self.context_length, end=None
              ),
              future_time_feat,
              dim=1,
          )
          sequence = F.concat(past_target_cdf, future_target_cdf, dim=1)
          sequence_length = self.history_length + self.prediction_length
          subsequences_length = (
              self.context_length + self.prediction_length
          )
  
      # (batch_size, sub_seq_len, target_dim, num_lags)
      lags = self.get_lagged_subsequences(
          F=F,
          sequence=sequence,
          sequence_length=sequence_length,
          indices=self.lags_seq,
          subsequences_length=subsequences_length,
      )
  
      # scale is computed on the context length last units of the past target
      # scale shape is (batch_size, 1, target_dim)
      _, scale = self.scaler(
          past_target_cdf.slice_axis(
              axis=1, begin=-self.context_length, end=None
          ),
          past_observed_values.slice_axis(
              axis=1, begin=-self.context_length, end=None
          ),
      )
  
      outputs, states, lags_scaled, inputs = self.unroll(
          F=F,
          lags=lags,
          scale=scale,
          time_feat=time_feat,
          target_dimension_indicator=target_dimension_indicator,
          unroll_length=subsequences_length,
          begin_state=None,
      )
  
      return outputs, states, scale, lags_scaled, inputs
  
imports: from typing import List, Optional, Tuple
  import mxnet
  from gluonts.core.component import validated
  from gluonts.mx import Tensor
  from gluonts.mx.block.scaler import MeanScaler, NOPScaler
  from gluonts.mx.distribution import Distribution, DistributionOutput
  from gluonts.mx.util import assert_shape, weighted_average
label_desc: Use image node_id 4 for calling the DeepVARNetwork obj's underlying member method code with example usage: obj.unroll_encoder(F, past_time_feat, past_target_cdf, past_observed_values, past_is_pad, future_time_feat, future_target_cdf, target_dimension_indicator) and returns: outputs,  states,  scale,  lags_scaled,  inputs