code: def testGradientsChained(self):
      @polymorphic_function.function
      def _forward(z):
          return math_ops.cos(z)
  
      f = _forward
      x = constant_op.constant(1.0)
      with backprop.GradientTape() as t:
          t.watch(x)
          y = f(x)
      with backprop.GradientTape() as tt:
          doutputs = constant_op.constant(2.0)
          tt.watch(doutputs)
          g = t.gradient(y, x, doutputs)
      self.assertAllClose(-2.0 * math_ops.sin(x), g)
      gg = tt.gradient(g, doutputs)
      # We're taking gradients with respect to doutputs, which is just a linear
      # function of the gradient.
      self.assertAllClose(-math_ops.sin(x), gg)
  
imports: from absl.testing import parameterized
  from tensorflow.python.eager import backprop
  from tensorflow.python.eager import context
  from tensorflow.python.eager.polymorphic_function import polymorphic_function
  from tensorflow.python.framework import config
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import indexed_slices
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_grad
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variables
  from tensorflow.python.ops import while_loop
  from tensorflow.python.platform import test
label_desc: Use image node_id 10 for calling the FunctionGradientsTest obj's underlying member method code with example usage: obj.testGradientsChained() and returns: math_ops