code: def sum_product(
      sum_op,
      prod_op,
      factors,
      eliminate=frozenset(),
      plates=frozenset(),
      pedantic=False,
      pow_op=None,
      plate_to_scale=None,  # dict
  ):
      """
      Performs sum-product contraction of a collection of factors.
  
      :return: a single contracted Funsor.
      :rtype: :class:`~funsor.terms.Funsor`
      """
      factors = partial_sum_product(
          sum_op,
          prod_op,
          factors,
          eliminate,
          plates,
          pedantic,
          pow_op,
          plate_to_scale,
      )
      return reduce(prod_op, factors, Number(UNITS[prod_op]))
  
imports: import re
  from collections import OrderedDict, defaultdict
  from functools import reduce
  from math import gcd
  import funsor
  import funsor.ops
  from funsor.cnf import Contraction
  from funsor.domains import Bint, Reals
  from funsor.interpreter import gensym
  from funsor.ops import PRODUCT_TO_POWER, UNITS, AssociativeOp
  from funsor.terms import Cat, Funsor, FunsorMeta, Number, Slice, Stack, Subs, Variable, eager, substitute, to_funsor
  from funsor.util import quote
label_desc: Use image node_id 7 for calling a global function with example usage: sum_product(sum_op, prod_op, factors, eliminate, plates, pedantic, pow_op, plate_to_scale) and returns: reduce