code: def test_ubersum_5(impl):
      # z {ij}  <--- target
      #     |
      #  y {i}
      #     |
      #  x {}
      i, j, a, b, c = 2, 3, 6, 5, 4
      x = torch.randn(a)
      y = torch.randn(a, b, i)
      z = torch.randn(b, c, i, j)
      (actual,) = impl(
          "a,abi,bcij->cij", x, y, z, plates="ij", modulo_total=True
      )
  
      # contract plate j
      s1 = logsumexp(z, 1)
      assert s1.shape == (b, i, j)
      p1 = s1.sum(2)
      assert p1.shape == (b, i)
      q1 = z - s1.unsqueeze(-3)
      assert q1.shape == (b, c, i, j)
  
      # contract plate i
      x2 = y + p1
      assert x2.shape == (a, b, i)
      s2 = logsumexp(x2, 1)
      assert s2.shape == (a, i)
      p2 = s2.sum(1)
      assert p2.shape == (a,)
      q2 = x2 - s2.unsqueeze(-2)
      assert q2.shape == (a, b, i)
  
      expected = opt_einsum.contract(
          "a,a,abi,bcij->cij",
          x,
          p2,
          q2,
          q1,
          backend="pyro.ops.einsum.torch_log",
      )
      assert_equal(actual, expected)
  
imports: import itertools
  import numbers
  from collections import OrderedDict
  import opt_einsum
  import pytest
  import torch
  import pyro.ops.jit
  from pyro.distributions.util import logsumexp
  from pyro.ops.contract import _partition_terms, contract_tensor_tree, contract_to_tensor, einsum, naive_ubersum, ubersum
  from pyro.ops.einsum.adjoint import require_backward
  from pyro.ops.rings import LogRing
  from pyro.poutine.indep_messenger import CondIndepStackFrame
  from pyro.util import optional
  from tests.common import assert_equal
label_desc: Use image node_id 20 for calling a global function with example usage: test_ubersum_5(impl) without return types