code: def testMemoryLeakInGlobalGradientRegistry(self):
      # Past leak: b/139819011
  
      if not memory_test_util.memory_profiler_is_available():
          self.skipTest("memory_profiler required to run this test")
  
      def f():
          @def_function.function(autograph=False)
          def graph(x):
              @def_function.function(autograph=False)
              def cubed(a):
                  return a * a * a
  
              y = cubed(x)
              # To ensure deleting the function does not affect the gradient
              # computation.
              del cubed
              return gradient_ops.gradients(
                  gradient_ops.gradients(y, x), x
              )
  
          return graph(constant_op.constant(1.5))[0].numpy()
  
      memory_test_util.assert_no_leak(
          f, num_iters=300, increase_threshold_absolute_mb=50
      )
  
file_path: tensorflow/tensorflow/python/eager/memory_tests/memory_test.py
imports: from tensorflow.python.eager import backprop
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import test
  from tensorflow.python.eager.memory_tests import memory_test_util
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradients
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.variables import Variable
label_desc: Use image node_id 4 for calling the MemoryTest obj's underlying member method code with example usage: obj.testMemoryLeakInGlobalGradientRegistry() and returns: graph, gradient_ops, unknown