code: def _trace_has_converged(trace_fn, batch_convergence_reduce_fn):
      """Augments a trace_fn to record whether the optimization has converged."""
      return lambda tq: (
          trace_fn(tq),
          batch_convergence_reduce_fn(tq.has_converged),
      )
  
file_path: probability/tensorflow_probability/python/math/minimize.py
imports: import collections
  import functools
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import loop_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.internal import samplers
  from tensorflow_probability.python.math.gradient import value_and_gradient
label_desc: Use image node_id 1 for calling a global function with example usage: _trace_has_converged(trace_fn, batch_convergence_reduce_fn) and returns: function