docstr: See arXiv: 1806.06923
  Once the model has learned how to predict a given quantile tau, one can sample from the
  distribution of the target, by sampling tau values.
docstr_tok: ["See","arXiv",":","1806.06923","Once","the","model","has","learned","how","to","predict","a","given","quantile","tau",",","one","can","sample","from","the","distribution","of","the","target",",","by","sampling","tau","values","."]
code: def sample(self, sample_shape=torch.Size()):
      """See arXiv: 1806.06923
      Once the model has learned how to predict a given quantile tau, one can sample from the
      distribution of the target, by sampling tau values.
      """
      if len(sample_shape) == 0:
          num_parallel_samples = 1
      else:
          num_parallel_samples = sample_shape[0]
      input_data = torch.repeat_interleave(
          self.input_data, repeats=num_parallel_samples, dim=0
      )
      batch_size = input_data.shape[0]
      forecast_length = input_data.shape[1]
      device = input_data.device
  
      taus = torch.rand(
          size=(batch_size, forecast_length), device=device
      )
      samples = self.quantile_function(input_data, taus)
      if len(sample_shape) == 0:
          return samples
      else:
          return samples.reshape(
              (num_parallel_samples, -1, forecast_length)
          )
  
file_path: gluonts/src/gluonts/nursery/robust-mts-attack/pts/distributions/implicit_quantile.py
imports: import torch
  from torch.distributions import Distribution, TransformedDistribution, AffineTransform
label_desc: Use image node_id 2 for calling the ImplicitQuantile obj's underlying member method code with example usage: obj.sample(sample_shape) and returns: samples, samples