code: def test_logsumexp(batch_shape, dim):
      gaussian = random_gaussian(batch_shape, dim)
      gaussian.info_vec *= 0.1  # approximately centered
      gaussian.precision += torch.eye(dim) * 0.1
  
      num_samples = 200000
      scale = 10
      samples = (
          torch.rand((num_samples,) + (1,) * len(batch_shape) + (dim,))
          * scale
          - scale / 2
      )
      expected = gaussian.log_density(samples).logsumexp(0) + math.log(
          scale**dim / num_samples
      )
      actual = gaussian.event_logsumexp()
      assert_close(actual, expected, atol=0.05, rtol=0.05)
  
imports: import math
  from collections import OrderedDict
  import pytest
  import torch
  from torch.distributions import constraints, transform_to
  from torch.nn.functional import pad
  import pyro.distributions
  from pyro.distributions.util import broadcast_shape
  from pyro.ops.gaussian import AffineNormal, Gaussian, gaussian_tensordot, matrix_and_gaussian_to_gaussian, matrix_and_mvn_to_gaussian, mvn_to_gaussian, sequential_gaussian_filter_sample, sequential_gaussian_tensordot
  from tests.common import assert_close
  from tests.ops.gaussian import assert_close_gaussian, random_gaussian, random_mvn
label_desc: Use image node_id 12 for calling a global function with example usage: test_logsumexp(batch_shape, dim) without return types