code: def test_ubersum_3(impl):
      #       z {b,c}
      #           |
      # w {a}  y {b}  <--- target
      #      \  /
      #     x {}
      a, b, c, d, e = 2, 3, 4, 5, 6
      w = torch.randn(a, e)
      x = torch.randn(d)
      y = torch.randn(b, d)
      z = torch.randn(b, c, d, e)
      (actual,) = impl(
          "ae,d,bd,bcde->be",
          w,
          x,
          y,
          z,
          plates="abc",
          modulo_total=True,
      )
      yz = y.reshape(b, d, 1) + z.sum(-3)  # eliminate c
      assert yz.shape == (b, d, e)
      yz = yz.sum(0)  # eliminate b
      assert yz.shape == (d, e)
      wxyz = w.sum(0) + x.reshape(d, 1) + yz  # eliminate a
      assert wxyz.shape == (d, e)
      wxyz = logsumexp(wxyz, 0)  # eliminate d
      assert wxyz.shape == (e,)
      expected = wxyz.expand(b, e)  # broadcast to b
      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 18 for calling a global function with example usage: test_ubersum_3(impl) without return types