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",",",")","``","."]
code: def condition(self, value):
      if value.size(-1) == self.loc.size(-1):
          prec_sqrt = self.matrix / self.scale.unsqueeze(-2)
          precision = matmul(prec_sqrt, prec_sqrt.transpose(-1, -2))
          delta = (value - self.loc) / self.scale
          info_vec = matvecmul(prec_sqrt, delta)
          log_normalizer = (
              -0.5 * self.loc.size(-1) * math.log(2 * math.pi)
              - 0.5 * delta.pow(2).sum(-1)
              - self.scale.log().sum(-1)
          )
          return Gaussian(log_normalizer, info_vec, precision)
      else:
          return self.to_gaussian().condition(value)
  
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 3 for calling the AffineNormal obj's underlying member method code with example usage: obj.condition(value) and returns: Gaussian, self