class_docstr: Distribution class for the Incremental (Spline) Quantile Function in the
  paper ``Learning Quantile Functions without Quantile Crossing for
  Distribution-free Time Series Forecasting``
  by Park, Robinson, Aubet, Kan, Gasthaus, Wang
  Parameters
  ----------
  spline_knots, spline_heights
      Tensor parametrizing the x-positions (y-positions) of the spline knots
      Shape: (*batch_shape, (num_qk-1), num_pieces)
  qk_x, qk_y
      Tensor containing the increasing x-positions (y-positions) of the
      quantile knots, Shape: (*batch_shape, num_qk)
  beta_l, beta_r
      Tensor containing the non-negative learnable parameter of the
      left (right) tail, Shape: (*batch_shape,)
class_docstr_tok: ["Distribution","class","for","the","Incremental","(","Spline",")","Quantile","Function","in","the","paper","``","Learning","Quantile","Functions","without","Quantile","Crossing","for","Distribution-free","Time","Series","Forecasting","``","by","Park",",","Robinson",",","Aubet",",","Kan",",","Gasthaus",",","Wang","Parameters","--","--","--","--","--","spline_knots",",","spline_heights","Tensor","parametrizing","the","x-positions","(","y-positions",")","of","the","spline","knots","Shape",":","(","*","batch_shape",",","(","num_qk-1",")",",","num_pieces",")","qk_x",",","qk_y","Tensor","containing","the","increasing","x-positions","(","y-positions",")","of","the","quantile","knots",",","Shape",":","(","*","batch_shape",",","num_qk",")","beta_l",",","beta_r","Tensor","containing","the","non-negative","learnable","parameter","of","the","left","(","right",")","tail",",","Shape",":","(","*","batch_shape",",",")"]
docstr: Function used to draw random samples
  Parameters
  ----------
  num_samples
      number of samples
  dtype
      data type
  Returns
  -------
  Tensor
      Tensor of shape (*batch_shape,) if num_samples = None
      else (num_samples, *batch_shape)
docstr_tok: ["Function","used","to","draw","random","samples","Parameters","--","--","--","--","--","num_samples","number","of","samples","dtype","data","type","Returns","--","--","--","-","Tensor","Tensor","of","shape","(","*","batch_shape",",",")","if","num_samples","=","None","else","(","num_samples",",","*","batch_shape",")"]
code: def rsample(
      self, sample_shape: torch.Size = torch.Size()
  ) -> torch.Tensor:
      r"""
      Function used to draw random samples
      Parameters
      ----------
      num_samples
          number of samples
      dtype
          data type
      Returns
      -------
      Tensor
          Tensor of shape (*batch_shape,) if num_samples = None
          else (num_samples, *batch_shape)
      """
  
      # if sample_shape=()) then input_alpha should have the same shape
      # as beta_l, i.e., (*batch_shape,)
      # else u should be (*sample_shape, *batch_shape)
      target_shape = (
          self.beta_l.shape
          if sample_shape == torch.Size()
          else torch.Size(sample_shape) + self.beta_l.shape
      )
  
      alpha = torch.rand(
          target_shape,
          dtype=self.beta_l.dtype,
          device=self.beta_l.device,
          layout=self.beta_l.layout,
      )
  
      sample = self.quantile(alpha)
  
      if sample_shape == torch.Size():
          sample = sample.squeeze(dim=0)
  
      return sample
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn.functional
  from torch.distributions import AffineTransform, TransformedDistribution
  from gluonts.core.component import validated
  from .distribution_output import DistributionOutput
label_desc: Use image node_id 16 for calling the ISQF obj's underlying member method code with example usage: obj.rsample(sample_shape) and returns: sample