class_docstr: Represents a conditional diagonal normal distribution over a random
  variable ``Y`` whose mean is an affine function of a random variable ``X``.
  The likelihood of ``X`` is thus::
  
      AffineNormal(matrix, loc, scale).condition(y).log_density(x)
  
  which is equivalent to::
  
      Normal(x @ matrix + loc, scale).to_event(1).log_prob(y)
  
  :param torch.Tensor matrix: A transformation from ``X`` to ``Y``.
      Should have rightmost shape ``(x_dim, y_dim)``.
  :param torch.Tensor loc: A constant offset for ``Y``'s mean.
      Should have rightmost shape ``(y_dim,)``.
  :param torch.Tensor scale: Standard deviation for ``Y``.
      Should have rightmost shape ``(y_dim,)``.
class_docstr_tok: ["Represents","a","conditional","diagonal","normal","distribution","over","a","random","variable","``","Y","``","whose","mean","is","an","affine","function","of","a","random","variable","``","X","``",".","The","likelihood","of","``","X","``","is","thus",":",":","AffineNormal","(","matrix",",","loc",",","scale",")",".condition","(","y",")",".log_density","(","x",")","which","is","equivalent","to",":",":","Normal","(","x","@","matrix","+","loc",",","scale",")",".to_event","(","1",")",".log_prob","(","y",")",":","param","torch.Tensor","matrix",":","A","transformation","from","``","X","``","to","``","Y","``",".","Should","have","rightmost","shape","``","(","x_dim",",","y_dim",")","``",".",":","param","torch.Tensor","loc",":","A","constant","offset","for","``","Y","``","'s","mean",".","Should","have","rightmost","shape","``","(","y_dim",",",")","``",".",":","param","torch.Tensor","scale",":","Standard","deviation","for","``","Y","``",".","Should","have","rightmost","shape","``","(","y_dim",",",")","``","."]
docstr: Reparameterized sampler.
code: def rsample(
      self,
      sample_shape=torch.Size(),
      noise: Optional[torch.Tensor] = None,
  ) -> torch.Tensor:
      """
      Reparameterized sampler.
      """
      if self.matrix.size(-2) > 0:
          raise NotImplementedError
      shape = sample_shape + self.batch_shape + self.loc.shape[-1:]
      if noise is None:
          noise = torch.randn(
              shape, dtype=self.loc.dtype, device=self.loc.device
          )
      else:
          noise = noise.reshape(shape)
      sample: torch.Tensor = self.loc + noise * self.scale
      return sample
  
imports: import math
  from typing import Optional, Tuple, Union
  import torch
  from torch.distributions.utils import lazy_property
  from torch.nn.functional import pad
  from pyro.distributions.util import broadcast_shape
  from pyro.ops.tensor_utils import matmul, matvecmul, safe_cholesky, triangular_solve
label_desc: Use image node_id 5 for calling the AffineNormal obj's underlying member method code with example usage: obj.rsample(sample_shape, noise) and returns: sample