code: def EM(init_params, data, callback=None):
      def EM_update(params):
          natural_params = list(map(np.log, params))
          loglike, E_stats = vgrad(log_partition_function)(
              natural_params, data
          )  # E step
          if callback:
              callback(loglike, params)
          return list(map(normalize, E_stats))  # M step
  
      def fixed_point(f, x0):
          x1 = f(x0)
          while different(x0, x1):
              x0, x1 = x1, f(x1)
          return x1
  
      def different(params1, params2):
          allclose = partial(np.allclose, atol=1e-3, rtol=1e-3)
          return not all(map(allclose, params1, params2))
  
      return fixed_point(EM_update, init_params)
  
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 1 for calling a global function with example usage: EM(init_params, data, callback) and returns: fixed_point, list, x1, unknown