code: def test_ubersum_4(impl):
      # x,y {b}  <--- target
      #      |
      #     {}
      a, b, c, d = 2, 3, 4, 5
      x = torch.randn(a, b)
      y = torch.randn(d, b, c)
      (actual,) = impl(
          "ab,dbc->dc", x, y, plates="d", modulo_total=True
      )
      x_b1 = logsumexp(x, 0).unsqueeze(-1)
      assert x_b1.shape == (b, 1)
      y_db1 = logsumexp(y, 2, keepdim=True)
      assert y_db1.shape == (d, b, 1)
      y_dbc = y_db1.sum(0) - y_db1 + y  # inclusion-exclusion
      assert y_dbc.shape == (d, b, c)
      xy_dc = logsumexp(x_b1 + y_dbc, 1)
      assert xy_dc.shape == (d, c)
      expected = xy_dc
      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 19 for calling a global function with example usage: test_ubersum_4(impl) without return types