code: def test_matrix_and_mvn_to_funsor_diag(batch_shape, x_size, y_size):
      matrix = torch.randn(batch_shape + (x_size, y_size))
      loc = torch.randn(batch_shape + (y_size,))
      scale = torch.randn(batch_shape + (y_size,)).exp()
  
      normal = dist.Normal(loc, scale).to_event(1)
      actual = matrix_and_mvn_to_funsor(matrix, normal)
  
      mvn = dist.MultivariateNormal(loc, scale_tril=scale.diag_embed())
      expected = matrix_and_mvn_to_funsor(matrix, mvn)
  
      y = tensor_to_funsor(torch.randn(batch_shape + (y_size,)), (), 1)
      actual_like = actual(value_y=y)
      expected_like = expected(value_y=y)
      assert_close(actual_like, expected_like, atol=1e-4, rtol=1e-4)
  
      x = tensor_to_funsor(torch.randn(batch_shape + (x_size,)), (), 1)
      actual_norm = actual_like(value_x=x)
      expected_norm = expected_like(value_x=x)
      assert_close(actual_norm, expected_norm, atol=1e-4, rtol=1e-4)
  
imports: from collections import OrderedDict
  import pyro.distributions
  import pytest
  import torch
  from pyro.distributions.torch_distribution import MaskedDistribution
  from funsor.domains import Bint, Reals
  from funsor.pyro.convert import dist_to_funsor, funsor_to_cat_and_mvn, funsor_to_mvn, funsor_to_tensor, matrix_and_mvn_to_funsor, mvn_to_funsor, tensor_to_funsor
  from funsor.tensor import Tensor
  from funsor.terms import Funsor
  from funsor.testing import assert_close, random_mvn
label_desc: Use image node_id 4 for calling a global function with example usage: test_matrix_and_mvn_to_funsor_diag(batch_shape, x_size, y_size) without return types