docstr: Computes sample paths by unrolling the RNN starting with a initial
  input and state.
  
  Parameters
  ----------
  past_target_cdf
      Past marginal CDF transformed target values (batch_size,
      history_length, target_dim)
  feat_static_cat
  
  feat_static_real
  
  time_feat
      Dynamic features of future time series (batch_size, history_length,
      num_features)
  scale
      Mean scale for each time series (batch_size, 1, target_dim)
  begin_states
      List of initial states for the RNN layers (batch_size, num_cells)
  Returns
  --------
  sample_paths : Tensor
      A tensor containing sampled paths. Shape: (1, num_sample_paths,
      prediction_length, target_dim).
docstr_tok: ["Computes","sample","paths","by","unrolling","the","RNN","starting","with","a","initial","input","and","state",".","Parameters","--","--","--","--","--","past_target_cdf","Past","marginal","CDF","transformed","target","values","(","batch_size",",","history_length",",","target_dim",")","feat_static_cat","feat_static_real","time_feat","Dynamic","features","of","future","time","series","(","batch_size",",","history_length",",","num_features",")","scale","Mean","scale","for","each","time","series","(","batch_size",",","1",",","target_dim",")","begin_states","List","of","initial","states","for","the","RNN","layers","(","batch_size",",","num_cells",")","Returns","--","--","--","--","sample_paths",":","Tensor","A","tensor","containing","sampled","paths",".","Shape",":","(","1",",","num_sample_paths",",","prediction_length",",","target_dim",")","."]
code: def sampling_decoder(
      self,
      past_target_cdf: torch.Tensor,
      feat_static_cat: torch.Tensor,
      feat_static_real: torch.Tensor,
      time_feat: torch.Tensor,
      scale: torch.Tensor,
      begin_states: Union[List[torch.Tensor], torch.Tensor],
  ) -> torch.Tensor:
      """
      Computes sample paths by unrolling the RNN starting with a initial
      input and state.
  
      Parameters
      ----------
      past_target_cdf
          Past marginal CDF transformed target values (batch_size,
          history_length, target_dim)
      feat_static_cat
  
      feat_static_real
  
      time_feat
          Dynamic features of future time series (batch_size, history_length,
          num_features)
      scale
          Mean scale for each time series (batch_size, 1, target_dim)
      begin_states
          List of initial states for the RNN layers (batch_size, num_cells)
      Returns
      --------
      sample_paths : Tensor
          A tensor containing sampled paths. Shape: (1, num_sample_paths,
          prediction_length, target_dim).
      """
  
      def repeat(tensor, dim=0):
          return tensor.repeat_interleave(
              repeats=self.num_parallel_samples, dim=dim
          )
  
      # blows-up the dimension of each tensor to
      # batch_size * self.num_sample_paths for increasing parallelism
      repeated_past_target_cdf = repeat(past_target_cdf)
      repeated_time_feat = repeat(time_feat)
      repeated_scale = repeat(scale)
      repeated_feat_static_cat = repeat(feat_static_cat)
      repeated_feat_static_real = repeat(feat_static_real)
  
      # slight difference for GPVAR and DeepVAR, in GPVAR, its a list
      if self.cell_type == "LSTM":
          repeated_states = [repeat(s, dim=1) for s in begin_states]
      else:
          repeated_states = repeat(begin_states, dim=1)
  
      future_samples = []
  
      # for each future time-units we draw new samples for this time-unit
      # and update the state
      loc = []
      for k in range(self.prediction_length):
          lags = self.get_lagged_subsequences(
              sequence=repeated_past_target_cdf,
              sequence_length=self.history_length + k,
              indices=self.shifted_lags,
              subsequences_length=1,
          )
  
          rnn_outputs, repeated_states, _, _ = self.unroll(
              begin_state=repeated_states,
              lags=lags,
              scale=repeated_scale,
              time_feat=repeated_time_feat[:, k : k + 1, ...],
              feat_static_cat=repeated_feat_static_cat,
              feat_static_real=repeated_feat_static_real,
              unroll_length=1,
          )
  
          distr, distr_args = self.distr(
              rnn_outputs=rnn_outputs,
              scale=repeated_scale,
          )
          # print(distr_args[0].shape) 700 x 1 x 10
          # print(distr_args[1].shape) 700 x 1 x 10 x 10
          # (batch_size, 1, target_dim)
          new_samples = distr.rsample()
          loc.append(distr.base_dist.loc)
          # transforms = [
          #         AffineTransform(
          #             loc=0.0 if loc is None else loc,
          #             scale=repeated_scale,
          #         )
          #     ]
          # for transform in transforms:
          #     loc = transform(loc)
  
          # (batch_size, seq_len, target_dim)
          future_samples.append(new_samples)
          repeated_past_target_cdf = torch.cat(
              (repeated_past_target_cdf, new_samples), dim=1
          )
  
      # (batch_size * num_samples, prediction_length, target_dim)
      samples = torch.cat(future_samples, dim=1)
      locs = torch.cat(loc, dim=1)
      # (batch_size, num_samples, prediction_length, target_dim)
      return samples.reshape(
          (
              -1,
              self.num_parallel_samples,
              self.prediction_length,
              self.target_dim,
          )
      )
  
imports: from turtle import distance
  from typing import List, Optional, Tuple, Union
  from matplotlib.pyplot import sca
  import torch
  import torch.nn
  from gluonts.core.component import validated
  from gluonts.torch.modules.distribution_output import DistributionOutput
  from pts.model import weighted_average
  from pts.modules import MeanScaler, NOPScaler, FeatureEmbedder
  from torch.distributions import AffineTransform, Beta, Distribution, Gamma, NegativeBinomial, Normal, Poisson, StudentT, TransformedDistribution
label_desc: Use image node_id 2 for calling the DeepVARPredictionNetwork obj's underlying member method code with example usage: obj.sampling_decoder(past_target_cdf, feat_static_cat, feat_static_real, time_feat, scale, begin_states) and returns: samples, tensor