code: def test_sarkka_bilmes_generic(
      time_input, global_inputs, local_inputs, num_periods
  ):
      lags = {
          kk: reduce(
              max,
              [
                  len(re.search("^(_PREV_)*", k).group(0)) // 6
                  for k, v in local_inputs
                  if k.strip("_PREV_") == kk
              ],
              0,
          )
          for kk, vv in local_inputs
          if not kk.startswith("_PREV_")
      }
      expected_inputs = dict(
          global_inputs
          + tuple(
              set(
                  ((t * "_PREV_" + k), v)
                  for k, v in local_inputs
                  if not k.startswith("_PREV_")
                  for t in range(0, lags[k] + 1)
              )
          )
      )
  
      trans_inputs = OrderedDict(
          global_inputs + (time_input,) + local_inputs
      )
      global_vars = frozenset(k for k, v in global_inputs)
  
      if any(v.dtype == "real" for v in trans_inputs.values()):
          trans = random_gaussian(trans_inputs)
      else:
          trans = random_tensor(trans_inputs)
  
      _check_sarkka_bilmes(
          trans, expected_inputs, global_vars, num_periods
      )
  
imports: import os
  import re
  from collections import OrderedDict
  from functools import partial, reduce
  import pytest
  import funsor.ops
  from funsor.domains import Bint, Real, Reals
  from funsor.interpretations import compress_gaussians, eager, eager_or_die, lazy, moment_matching, reflect
  from funsor.interpreter import reinterpret
  from funsor.optimizer import apply_optimizer
  from funsor.sum_product import MarkovProduct, _partition, dynamic_partial_sum_product, mixed_sequential_sum_product, modified_partial_sum_product, naive_sarkka_bilmes_product, naive_sequential_sum_product, partial_sum_product, partial_unroll, sarkka_bilmes_product, sequential_sum_product, sum_product
  from funsor.tensor import Tensor, get_default_prototype
  from funsor.terms import Cat, Variable
  from funsor.testing import assert_close, random_gaussian, random_tensor
  from funsor.util import get_backend
label_desc: Use image node_id 41 for calling a global function with example usage: test_sarkka_bilmes_generic(time_input, global_inputs, local_inputs, num_periods) without return types