code: def make_backoff_cholesky(alternate_cholesky, name="BackoffCholesky"):
      """Make a function that tries Cholesky then the user-specified function.
  
      Warning: This function uses an XLA-compiled `tf.linalg.cholesky` to capture
      factorization failures.
  
      Args:
        alternate_cholesky: A callable with the same signature as
          `tf.linalg.cholesky`.
        name: Python `str` name prefixed to Ops created by this function.
          Default value: 'BackoffCholesky'.
  
      Returns:
        run_backoff: An function that attempts a standard Cholesky, and then tries
          `alternate_cholesky` on failure.
      """
  
      def run_backoff(covariance):
          with tf.name_scope(name):
              chol = tf.linalg.cholesky(covariance)
              ok = tf.reduce_all(tf.math.is_finite(chol))
              return tf.cond(
                  ok,
                  lambda: chol,
                  lambda: alternate_cholesky(covariance),
              )
  
      return run_backoff
  
file_path: probability/tensorflow_probability/python/experimental/distributions/marginal_fns.py
imports: import tensorflow.compat.v2
  from tensorflow_probability.python.distributions import mvn_linear_operator
  from tensorflow_probability.python.internal import custom_gradient
  from tensorflow_probability.python.internal import prefer_static
label_desc: Use image node_id 1 for calling a global function with example usage: make_backoff_cholesky(alternate_cholesky, name) and returns: run_backoff, tf