code: def naive_sarkka_bilmes_product(
      sum_op, prod_op, trans, time_var, global_vars=frozenset()
  ):
      assert isinstance(global_vars, frozenset)
  
      time = time_var.name
      global_vars |= {time}
  
      lags = {_get_shift(name) for name in trans.inputs if name != time}
      lags.discard(0)
      if not lags:
          return naive_sequential_sum_product(
              sum_op, prod_op, trans, time_var, {}
          )
  
      original_names = frozenset(
          name
          for name in trans.inputs
          if name not in global_vars and not name.startswith("_PREV_")
      )
  
      duration = trans.inputs[time].size
  
      result = trans(**{time: duration - 1})
      for t in range(duration - 2, -1, -1):
          result = prod_op(
              _shift_funsor(
                  trans(**{time: t}), duration - t - 1, global_vars
              ),
              result,
          )
          sum_vars = frozenset(
              _shift_name(name, duration - t - 1)
              for name in original_names
          )
          result = result.reduce(sum_op, sum_vars)
  
      result = result(
          **{
              name: _shift_name(name, -duration + 1)
              for name in result.inputs
          }
      )
      return result
  
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 14 for calling a global function with example usage: naive_sarkka_bilmes_product(sum_op, prod_op, trans, time_var, global_vars) and returns: result, naive_sequential_sum_product