code: def test_matrix_and_mvn_to_gamma_gaussian(
      sample_shape, batch_shape, x_dim, y_dim
  ):
      matrix = torch.randn(batch_shape + (x_dim, y_dim))
      y_mvn = random_mvn(batch_shape, y_dim)
      g = matrix_and_mvn_to_gamma_gaussian(matrix, y_mvn)
      xy = torch.randn(sample_shape + batch_shape + (x_dim + y_dim,))
      s = torch.rand(sample_shape + batch_shape)
      actual_log_prob = g.log_density(xy, s)
  
      x, y = xy[..., :x_dim], xy[..., x_dim:]
      y_pred = x.unsqueeze(-2).matmul(matrix).squeeze(-2)
      loc = y_pred + y_mvn.loc
      scaled_prec = y_mvn.precision_matrix * s.unsqueeze(-1).unsqueeze(
          -1
      )
      expected_log_prob = dist.MultivariateNormal(
          loc, precision_matrix=scaled_prec
      ).log_prob(y)
      assert_close(actual_log_prob, expected_log_prob)
  
imports: import math
  import pytest
  import torch
  from torch.nn.functional import pad
  import pyro.distributions
  from pyro.distributions.util import broadcast_shape
  from pyro.ops.gamma_gaussian import GammaGaussian, gamma_and_mvn_to_gamma_gaussian, gamma_gaussian_tensordot, matrix_and_mvn_to_gamma_gaussian
  from tests.common import assert_close
  from tests.ops.gamma_gaussian import assert_close_gamma_gaussian, random_gamma, random_gamma_gaussian
  from tests.ops.gaussian import random_mvn
label_desc: Use image node_id 12 for calling a global function with example usage: test_matrix_and_mvn_to_gamma_gaussian(sample_shape, batch_shape, x_dim, y_dim) without return types