code: def log_partition_function(natural_params, data):
      if isinstance(data, list):
          return sum(
              map(partial(log_partition_function, natural_params), data)
          )
  
      log_pi, log_A, log_B = natural_params
  
      log_alpha = log_pi
      for y in data:
          log_alpha = (
              logsumexp(log_alpha[:, None] + log_A, axis=0)
              + log_B[:, y]
          )
  
      return logsumexp(log_alpha)
  
file_path: autograd/examples/hmm_em.py
imports: from __future__ import division, print_function
  import autograd.numpy
  import autograd.numpy.random
  from autograd.scipy.special import logsumexp
  from autograd import value_and_grad
  from functools import partial
  from os.path import join, dirname
  import string
label_desc: Use image node_id 3 for calling a global function with example usage: log_partition_function(natural_params, data) and returns: logsumexp, sum