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: Test that callback catches NaN in a tf.dataset map function.
docstr_tok: ["Test","that","callback","catches","NaN","in","a","tf.dataset","map","function","."]
code: def testCatchInfinityInDatasetMapFunction(self):
      """Test that callback catches NaN in a tf.dataset map function."""
      check_numerics_callback.enable_check_numerics()
  
      def generate_nan(x):
          """Intentionally generates NaNs by taking log of negative number."""
          casted_x = math_ops.cast(x, dtypes.float32)
          return math_ops.log([[-1.0, 1.0], [3.0, 5.0]]) + casted_x
  
      dataset = dataset_ops.Dataset.range(10).map(generate_nan)
      iterator = dataset_ops.make_one_shot_iterator(dataset)
  
      message = self._assertRaisesInvalidArgumentErrorAndGetMessage(
          lambda: self.evaluate(iterator.get_next())
      )
  
      # Check the content of the error message.
      self.assertTrue(re.search(r"graph op.*\"Log\"", message))
      self.assertTrue(re.search(r"dtype.*float32", message))
      self.assertIn("shape: (2, 2)\n", message)
      self.assertTrue(
          re.search(r"Input tensor.*Tensor.*Log/x:0", message)
      )
      self.assertIn("generate_nan", 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 11 for calling the CheckNumericsCallbackUnhealthyTest obj's underlying member method code with example usage: obj.testCatchInfinityInDatasetMapFunction() and returns: unknown