code: def test_sum_product():
      factors = [
          Variable("f", Reals[5])["x"],
          Variable("g", Reals[5, 4])["x", "y"],
          Variable("h", Reals[4, 3, 2])["y", "z", "i"],
      ]
      eliminate = frozenset({"x", "y", "z", "i"})
      plates = frozenset({"i"})
      with reflect:
          expr = sum_product(
              ops.logaddexp, ops.add, factors, eliminate, plates
          )
          expr = apply_optimizer(expr)
      assert set(expr.inputs) == {"f", "g", "h"}
  
      check_compiler(expr)
  
imports: import functools
  import pytest
  import funsor.ops
  from funsor.compiler import compile_funsor
  from funsor.domains import Real, Reals
  from funsor.interpretations import reflect
  from funsor.optimizer import apply_optimizer
  from funsor.sum_product import sum_product
  from funsor.tensor import Tensor
  from funsor.terms import Number, Tuple, Variable
  from funsor.testing import assert_close, randn
label_desc: Use image node_id 9 for calling a global function with example usage: test_sum_product() without return types