code: def test_kl_independent_normal_mvn(batch_shape, size):
      loc = torch.randn(batch_shape + (size,))
      scale = torch.randn(batch_shape + (size,)).exp()
      p1 = dist.Normal(loc, scale).to_event(1)
      p2 = dist.MultivariateNormal(loc, scale_tril=scale.diag_embed())
  
      loc = torch.randn(batch_shape + (size,))
      cov = torch.randn(batch_shape + (size, size))
      cov = cov @ cov.transpose(-1, -2) + 0.01 * torch.eye(size)
      q = dist.MultivariateNormal(loc, covariance_matrix=cov)
  
      actual = kl_divergence(p1, q)
      expected = kl_divergence(p2, q)
      assert_close(actual, expected)
  
file_path: pyro/tests/distributions/test_kl.py
imports: import pytest
  import torch
  from torch.distributions import kl_divergence, transforms
  import pyro.distributions
  from pyro.distributions.util import sum_rightmost
  from tests.common import assert_close
label_desc: Use image node_id 5 for calling a global function with example usage: test_kl_independent_normal_mvn(batch_shape, size) without return types