code: def testCompilationInGradient(self):
      with self.cached_session():
          x = constant_op.constant([[3.0]])
          y_nc = math_ops.matmul(x, x, name="not_compiled")
          with jit.experimental_jit_scope():
              y_c = math_ops.matmul(y_nc, y_nc, name="compiled")
          x_grads = gradients.gradients([y_c], [x])[0]
          operations = x.graph.get_operations()
          c_grad_ops = [
              op for op in operations if "gradients/compiled" in op.name
          ]
          nc_grad_ops = [
              op
              for op in operations
              if "gradients/not_compiled" in op.name
          ]
          self.assertGreater(len(c_grad_ops), 0)
          self.assertGreater(len(nc_grad_ops), 0)
          for cg in c_grad_ops:
              self.assertTrue(cg.get_attr("_XlaCompile"))
          for ncg in nc_grad_ops:
              with self.assertRaisesRegex(
                  ValueError, "[Nn]o attr named"
              ):
                  ncg.get_attr("_XlaCompile")
  
          # d/dx (x ** 4) = 4 * (x ** 3)
          self.assertAllClose([[108]], x_grads)
  
imports: from absl.testing import parameterized
  from tensorflow.python.compiler.xla import jit
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import function
  from tensorflow.python.framework import op_def_registry
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import gradients
  from tensorflow.python.ops import init_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 1 for calling the CompilationEnabledInGradientTest obj's underlying member method code with example usage: obj.testCompilationInGradient() without return types