import tensorflow as tf

      self.assertFalse(has_nan_or_inf.eval())
      self.assertEqual(1.0, grad_scale.eval())
      # The final gradient must be finite.
      self.assertFalse(tf.is_nan(final_var_grads.a[1]).eval())
      self.assertTrue(tf.is_finite(final_var_grads.a[1]).eval())

  def testScaleGradientsInf(self):
    FLAGS.enable_check_numerics = False
