code: def is_finite(val_1, val_2=None):
      """Checks if the supplied values are finite.
  
      Args:
        val_1: A namedtuple instance with the function value and derivative,
          as returned e.g. by value_and_gradients_function evaluations.
        val_2: (Optional) A namedtuple instance with the function value and
          derivative, as returned e.g. by value_and_gradients_function evaluations.
  
      Returns:
        is_finite: Scalar boolean `Tensor` indicating whether the function value
          and the derivative in `val_1` (and optionally in `val_2`) are all finite.
      """
      val_1_finite = tf.math.is_finite(val_1.f) & tf.math.is_finite(
          val_1.df
      )
      if val_2 is not None:
          return (
              val_1_finite
              & tf.math.is_finite(val_2.f)
              & tf.math.is_finite(val_2.df)
          )
      return val_1_finite
  
file_path: probability/tensorflow_probability/python/optimizer/linesearch/internal/hager_zhang_lib.py
imports: import collections
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import broadcast_util
  from tensorflow_probability.python.internal import prefer_static
label_desc: Use image node_id 12 for calling a global function with example usage: is_finite(val_1, val_2) and returns: val_1_finite, unknown