class_docstr: Test for cases in which enable_check_numerics() catches infs or nans.
class_docstr_tok: ["Test","for","cases","in","which","enable_check_numerics","(",")","catches","infs","or","nans","."]
docstr: Catching inf in the inner nested tf.function during backprop.
docstr_tok: ["Catching","inf","in","the","inner","nested","tf.function","during","backprop","."]
code: def testNestedFunctionGradientCall(self):
      """Catching inf in the inner nested tf.function during backprop."""
      check_numerics_callback.enable_check_numerics()
  
      x = constant_op.constant(1.0 - 1e-8, dtype=dtypes.float32)
  
      @def_function.function
      def asinp1(x):
          # asin()'s gradient overflows at the value close to 1.0.
          return math_ops.asin(x) + 1.0
  
      @def_function.function
      def loss(x):
          return math_ops.square(asinp1(x))
  
      with backprop.GradientTape() as tape:
          tape.watch(x)
          y = loss(x)
          message = self._assertRaisesInvalidArgumentErrorAndGetMessage(
              lambda: self.evaluate(tape.gradient(y, x))
          )
          self.assertTrue(re.search(r"gradient", message))
  
imports: import re
  import numpy
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.debug.lib import check_numerics_callback
  from tensorflow.python.eager import backprop
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_grad
  from tensorflow.python.ops import custom_gradient
  from tensorflow.python.ops import gen_nn_ops
  from tensorflow.python.ops import gradient_checker_v2
  from tensorflow.python.ops import math_grad
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import googletest
  from tensorflow.python.platform import test
label_desc: Use image node_id 13 for calling the CheckNumericsCallbackUnhealthyTest obj's underlying member method code with example usage: obj.testNestedFunctionGradientCall() and returns: unknown, math_ops