code: def test_logsumexp(batch_shape, dim):
      g = random_gamma_gaussian(batch_shape, dim)
      g.info_vec *= 0.1  # approximately centered
      g.precision += torch.eye(dim) * 0.1
      s = torch.randn(batch_shape).exp() + 0.2
  
      num_samples = 200000
      scale = 10
      samples = (
          torch.rand((num_samples,) + (1,) * len(batch_shape) + (dim,))
          * scale
          - scale / 2
      )
      expected = g.log_density(samples, s).logsumexp(0) + math.log(
          scale**dim / num_samples
      )
      actual = g.event_logsumexp().log_density(s)
      assert_close(actual, expected, atol=0.05, rtol=0.05)
  
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 10 for calling a global function with example usage: test_logsumexp(batch_shape, dim) without return types