code: def _inv_hessian_control_inputs(inv_hessian):
      """Computes control inputs to validate a provided inverse Hessian.
  
      These ensure that the provided inverse Hessian is positive definite and
      symmetric.
  
      Args:
        inv_hessian: The starting estimate for the inverse of the Hessian at the
          initial point.
  
      Returns:
        A list of tf.Assert ops suitable for use with tf.control_dependencies.
      """
      # The easiest way to validate if the inverse Hessian is positive definite is
      # to compute its Cholesky decomposition.
      try:
          is_positive_definite = tf.reduce_all(
              tf.math.is_finite(tf.linalg.cholesky(inv_hessian))
          )
      except tf.errors.InvalidArgumentError:
          is_positive_definite = False
  
      # Then check that the supplied inverse Hessian is symmetric.
      is_symmetric = tf.reduce_all(
          tf.equal(
              bfgs_utils.norm(
                  inv_hessian - _batch_transpose(inv_hessian), dims=2
              ),
              0,
          )
      )
  
      # Simply adding a control dependencies on these results is not enough to
      # trigger them, we need to add asserts on the results.
      return [
          tf.debugging.Assert(
              is_positive_definite,
              [
                  "Initial inverse Hessian is not positive definite.",
                  inv_hessian,
              ],
          ),
          tf.debugging.Assert(
              is_symmetric,
              ["Initial inverse Hessian is not symmetric", inv_hessian],
          ),
      ]
  
file_path: probability/tensorflow_probability/python/optimizer/bfgs.py
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import distribution_util
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow_probability.python.internal import prefer_static
  from tensorflow_probability.python.optimizer import bfgs_utils
label_desc: Use image node_id 2 for calling a global function with example usage: _inv_hessian_control_inputs(inv_hessian) and returns: list