docstr: Sample a trajectory of interval-size pairs from the model given past
  target.
  
  Parameters
  ----------
  past_target
      (batch_size, history_length, 2) shaped tensor containing the past
      time series in an interval-size representation.
  time_remaining
      (batch_size, 1) shaped tensor containing the number of time steps
      that were zero before the start of the forecast horizon
  
  Returns
  -------
  samples
      samples of shape (batch_size, num_parallel_samples, 2,
      sequence_length)
docstr_tok: ["Sample","a","trajectory","of","interval-size","pairs","from","the","model","given","past","target",".","Parameters","--","--","--","--","--","past_target","(","batch_size",",","history_length",",","2",")","shaped","tensor","containing","the","past","time","series","in","an","interval-size","representation",".","time_remaining","(","batch_size",",","1",")","shaped","tensor","containing","the","number","of","time","steps","that","were","zero","before","the","start","of","the","forecast","horizon","Returns","--","--","--","-","samples","samples","of","shape","(","batch_size",",","num_parallel_samples",",","2",",","sequence_length",")"]
code: def sampling_decoder(
      self,
      F,
      past_target: Tensor,
      interval_alpha_bias: Optional[Tensor] = None,
      size_alpha_bias: Optional[Tensor] = None,
      time_remaining: Optional[Tensor] = None,
  ) -> Tensor:
      """
      Sample a trajectory of interval-size pairs from the model given past
      target.
  
      Parameters
      ----------
      past_target
          (batch_size, history_length, 2) shaped tensor containing the past
          time series in an interval-size representation.
      time_remaining
          (batch_size, 1) shaped tensor containing the number of time steps
          that were zero before the start of the forecast horizon
  
      Returns
      -------
      samples
          samples of shape (batch_size, num_parallel_samples, 2,
          sequence_length)
      """
      if time_remaining is None:
          time_remaining = F.broadcast_like(
              F.zeros((1,)), past_target, lhs_axes=(0,), rhs_axes=(0,)
          )
  
      # if no valid points in the past_target, override time remaining with
      # zero
      batch_sum = F.sum(past_target, axis=1).sum(-1).expand_dims(-1)
      time_remaining = F.where(
          batch_sum > 0, time_remaining, F.zeros_like(time_remaining)
      )
  
      repeated_past_target = past_target.repeat(
          repeats=self.num_parallel_samples, axis=0
      )  # (N * samples, T, 2)
      repeated_time_remaining = time_remaining.repeat(
          repeats=self.num_parallel_samples, axis=0
      )  # (N * samples, 1)
  
      interval_samples = []
      size_samples = []
  
      for t in range(self.prediction_length):
          cond_mean = self.mu_map(repeated_past_target, shift=False)
          cond_mean_last = F.slice_axis(
              cond_mean, axis=1, begin=-1, end=None
          ).squeeze(1)
  
          dist_interval, dist_size = self.distribution(
              cond_mean_last, interval_alpha_bias, size_alpha_bias
          )
  
          # initial samples for interval should be taken conditionally
          # we achieve this via (leaky) rejection sampling
          if t == 0:
              interval_sample = F.zeros_like(repeated_time_remaining)
              for j in range(50):
                  interval_sample = F.where(
                      interval_sample > repeated_time_remaining,
                      interval_sample,
                      dist_interval.sample(),
                  )
              interval_sample = (
                  F.where(
                      interval_sample <= repeated_time_remaining,
                      repeated_time_remaining,
                      interval_sample,
                  )
                  + 1
              )
          else:
              interval_sample = dist_interval.sample() + 1
          size_sample = dist_size.sample() + 1
  
          interval_samples.append(interval_sample)
          size_samples.append(size_sample)
  
          repeated_past_target = F.concat(
              repeated_past_target,
              F.concat(
                  interval_sample, size_sample, dim=-1
              ).expand_dims(1),
              dim=1,
          )
  
      interval_samples[0] = (
          interval_samples[0] - repeated_time_remaining
      )
      samples = F.concat(
          *[
              F.concat(x, y, dim=-1).expand_dims(1)
              for x, y in zip(interval_samples, size_samples)
          ],
          dim=1,
      )
  
      return samples.reshape(
          shape=(-1, self.num_parallel_samples) + samples.shape[1:]
      ).swapaxes(2, 3)
  
imports: from typing import Optional, Tuple
  import mxnet
  from gluonts.core.component import validated
  from gluonts.mx import Tensor
  from gluonts.mx.distribution import Distribution, DistributionOutput
  from gluonts.mx.distribution.distribution import getF
  from mxnet import gluon
label_desc: Use image node_id 2 for calling the DeepRenewalPredictionNetwork obj's underlying member method code with example usage: obj.sampling_decoder(F, past_target, interval_alpha_bias, size_alpha_bias, time_remaining) and returns: samples