code: def test_affine_normal(batch_shape, x_dim, y_dim):
      matrix = torch.randn(batch_shape + (x_dim, y_dim))
      loc = torch.randn(batch_shape + (y_dim,))
      scale = torch.randn(batch_shape + (y_dim,)).exp()
      y = torch.randn(batch_shape + (y_dim,))
  
      normal = dist.Normal(loc, scale).to_event(1)
      actual = matrix_and_mvn_to_gaussian(matrix, normal)
      assert isinstance(actual, AffineNormal)
      actual_like = actual.condition(y)
      assert isinstance(actual_like, Gaussian)
  
      mvn = dist.MultivariateNormal(loc, scale_tril=scale.diag_embed())
      expected = matrix_and_mvn_to_gaussian(matrix, mvn)
      assert isinstance(expected, Gaussian)
      expected_like = expected.condition(y)
      assert isinstance(expected_like, Gaussian)
  
      assert_close(
          actual_like.log_normalizer, expected_like.log_normalizer
      )
      assert_close(actual_like.info_vec, expected_like.info_vec)
      assert_close(actual_like.precision, expected_like.precision)
  
      x = torch.randn(batch_shape + (x_dim,))
      permute_actual = actual.left_condition(x)
      assert isinstance(permute_actual, AffineNormal)
      permute_actual = permute_actual.to_gaussian()
  
      permute_expected = expected.left_condition(y)
      assert isinstance(permute_expected, Gaussian)
  
      assert_close(
          permute_actual.log_normalizer, permute_actual.log_normalizer
      )
      assert_close(permute_actual.info_vec, permute_actual.info_vec)
      assert_close(permute_actual.precision, permute_actual.precision)
  
imports: import math
  from collections import OrderedDict
  import pytest
  import torch
  from torch.distributions import constraints, transform_to
  from torch.nn.functional import pad
  import pyro.distributions
  from pyro.distributions.util import broadcast_shape
  from pyro.ops.gaussian import AffineNormal, Gaussian, gaussian_tensordot, matrix_and_gaussian_to_gaussian, matrix_and_mvn_to_gaussian, mvn_to_gaussian, sequential_gaussian_filter_sample, sequential_gaussian_tensordot
  from tests.common import assert_close
  from tests.ops.gaussian import assert_close_gaussian, random_gaussian, random_mvn
label_desc: Use image node_id 13 for calling a global function with example usage: test_affine_normal(batch_shape, x_dim, y_dim) without return types