code: def test_grappler_pass_enabled(self):
      opt = gradient_descent_v1.GradientDescentOptimizer(1.0)
      mixed_precision.enable_mixed_precision_graph_rewrite_v1(
          opt, 123.0
      )
  
      var = variables.Variable([[1.0]])
  
      def overflow_in_float16():
          out = var * 2**10
          out = math_ops.matmul(out, out)
          return array_ops.reshape(out, ())
  
      if context.executing_eagerly():
          f = def_function.function(overflow_in_float16)
          self.assertEqual(f().numpy(), float("Inf"))
          # Outside a def_function.function, the grappler pass will not be applied.
          self.assertAlmostEqual(overflow_in_float16().numpy(), 2**20)
  
          # Test disabling mixed precision.
          mixed_precision.disable_mixed_precision_graph_rewrite_v1()
          self.assertEqual(f().numpy(), 2**20)
      else:
          with session.Session() as sess:
              out = overflow_in_float16()
              sess.run(var.initializer)
              self.assertEqual(sess.run(out), float("Inf"))
  
          # Test Session will enable the auto_mixed_precision grappler pass in a
          # ConfigProto passed by the user
          with session.Session(config=config_pb2.ConfigProto()) as sess:
              out = overflow_in_float16()
              sess.run(var.initializer)
              self.assertEqual(sess.run(out), float("Inf"))
  
          # Test disabling mixed precision.
          mixed_precision.disable_mixed_precision_graph_rewrite_v1()
          with session.Session() as sess:
              out = overflow_in_float16()
              sess.run(var.initializer)
              self.assertAlmostEqual(sess.run(out), 2**20)
  
imports: import os
  from absl.testing import parameterized
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import config
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.training import gradient_descent
  from tensorflow.python.training.experimental import loss_scale_optimizer
  from tensorflow.python.training.experimental import mixed_precision
  from tensorflow.python.training.experimental import mixed_precision_global_state
label_desc: Use image node_id 7 for calling the MixedPrecisionTest obj's underlying member method code with example usage: obj.test_grappler_pass_enabled() and returns: array_ops