code: def random_gaussian(
      batch_shape, dim, rank=None, *, requires_grad=False
  ):
      """
      Generate a random Gaussian for testing.
      """
      if rank is None:
          rank = dim + dim
      log_normalizer = torch.randn(
          batch_shape, requires_grad=requires_grad
      )
      info_vec = torch.randn(
          batch_shape + (dim,), requires_grad=requires_grad
      )
      samples = torch.randn(batch_shape + (dim, rank))
      precision = torch.matmul(samples, samples.transpose(-2, -1))
      precision.requires_grad_(requires_grad)
      result = Gaussian(log_normalizer, info_vec, precision)
      assert result.dim() == dim
      assert result.batch_shape == batch_shape
      return result
  
imports: import torch
  import pyro.distributions
  from pyro.ops.gaussian import Gaussian
  from tests.common import assert_close
label_desc: Use image node_id 1 for calling a global function with example usage: random_gaussian(batch_shape, dim, rank) and returns: result