class_docstr: Extension of the Distribution class, which applies a sequence of Transforms
  to a base distribution.  Let f be the composition of transforms applied::
  
      X ~ BaseDistribution
      Y = f(X) ~ TransformedDistribution(BaseDistribution, f)
      log p(Y) = log p(X) + log |det (dX/dY)|
  
  Note that the ``.event_shape`` of a :class:`TransformedDistribution` is the
  maximum shape of its base distribution and its transforms, since transforms
  can introduce correlations among events.
  
  An example for the usage of :class:`TransformedDistribution` would be::
  
      # Building a Logistic Distribution
      # X ~ Uniform(0, 1)
      # f = a + b * logit(X)
      # Y ~ f(X) ~ Logistic(a, b)
      base_distribution = Uniform(0, 1)
      transforms = [SigmoidTransform().inv, AffineTransform(loc=a, scale=b)]
      logistic = TransformedDistribution(base_distribution, transforms)
  
  For more examples, please look at the implementations of
  :class:`~torch.distributions.gumbel.Gumbel`,
  :class:`~torch.distributions.half_cauchy.HalfCauchy`,
  :class:`~torch.distributions.half_normal.HalfNormal`,
  :class:`~torch.distributions.log_normal.LogNormal`,
  :class:`~torch.distributions.pareto.Pareto`,
  :class:`~torch.distributions.weibull.Weibull`,
  :class:`~torch.distributions.relaxed_bernoulli.RelaxedBernoulli` and
  :class:`~torch.distributions.relaxed_categorical.RelaxedOneHotCategorical`
class_docstr_tok: ["Extension","of","the","Distribution","class",",","which","applies","a","sequence","of","Transforms","to","a","base","distribution",".","Let","f","be","the","composition","of","transforms","applied",":",":","X","~","BaseDistribution","Y","=","f","(","X",")","~","TransformedDistribution","(","BaseDistribution",",","f",")","log","p","(","Y",")","=","log","p","(","X",")","+","log","|det","(","dX\/dY",")","|","Note","that","the","``",".event_shape","``","of","a",":","class",":","`","TransformedDistribution","`","is","the","maximum","shape","of","its","base","distribution","and","its","transforms",",","since","transforms","can","introduce","correlations","among","events",".","An","example","for","the","usage","of",":","class",":","`","TransformedDistribution","`","would","be",":",":","#","Building","a","Logistic","Distribution","#","X","~","Uniform","(","0",",","1",")","#","f","=","a","+","b","*","logit","(","X",")","#","Y","~","f","(","X",")","~","Logistic","(","a",",","b",")","base_distribution","=","Uniform","(","0",",","1",")","transforms","=","[","SigmoidTransform","(",")",".inv",",","AffineTransform","(","loc=a",",","scale=b",")","]","logistic","=","TransformedDistribution","(","base_distribution",",","transforms",")","For","more","examples",",","please","look","at","the","implementations","of",":","class",":","`","~torch.distributions.gumbel.Gumbel","`",",",":","class",":","`","~torch.distributions.half_cauchy.HalfCauchy","`",",",":","class",":","`","~torch.distributions.half_normal.HalfNormal","`",",",":","class",":","`","~torch.distributions.log_normal.LogNormal","`",",",":","class",":","`","~torch.distributions.pareto.Pareto","`",",",":","class",":","`","~torch.distributions.weibull.Weibull","`",",",":","class",":","`","~torch.distributions.relaxed_bernoulli.RelaxedBernoulli","`","and",":","class",":","`","~torch.distributions.relaxed_categorical.RelaxedOneHotCategorical","`"]
docstr: Generates a sample_shape shaped reparameterized sample or sample_shape
  shaped batch of reparameterized samples if the distribution parameters
  are batched. Samples first from base distribution and applies
  `transform()` for every transform in the list.
docstr_tok: ["Generates","a","sample_shape","shaped","reparameterized","sample","or","sample_shape","shaped","batch","of","reparameterized","samples","if","the","distribution","parameters","are","batched",".","Samples","first","from","base","distribution","and","applies","`","transform","(",")","`","for","every","transform","in","the","list","."]
code: def rsample(self, sample_shape=torch.Size()):
      """
      Generates a sample_shape shaped reparameterized sample or sample_shape
      shaped batch of reparameterized samples if the distribution parameters
      are batched. Samples first from base distribution and applies
      `transform()` for every transform in the list.
      """
      x = self.base_dist.rsample(sample_shape)
      for transform in self.transforms:
          x = transform(x)
      return x
  
file_path: pytorch/torch/distributions/transformed_distribution.py
imports: from typing import Dict
  import torch
  from torch.distributions import constraints
  from torch.distributions.distribution import Distribution
  from torch.distributions.independent import Independent
  from torch.distributions.transforms import ComposeTransform, Transform
  from torch.distributions.utils import _sum_rightmost
label_desc: Use image node_id 6 for calling the TransformedDistribution obj's underlying member method code with example usage: obj.rsample(sample_shape) and returns: x