code: def testGradient(self):
      if context.executing_eagerly():
          return
      # rt1.shape == rt2.shape == [2, (D2), (D3), 2].
      rt1 = ragged_factory_ops.constant(
          [[[[1.0, 2.0], [3.0, 4.0]], [[5.0, 6.0]]]], ragged_rank=2
      )
      rt2 = ragged_factory_ops.constant(
          [[[[9.0, 8.0], [7.0, 6.0]], [[5.0, 4.0]]]], ragged_rank=2
      )
      rt = ragged_functional_ops.map_flat_values(
          math_ops.add, rt1, rt2 * 2.0
      )
      st = rt.to_sparse()
  
      g1, g2 = gradients_impl.gradients(
          st.values, [rt1.flat_values, rt2.flat_values]
      )
      self.assertAllEqual(g1, [[1.0, 1.0], [1.0, 1.0], [1.0, 1.0]])
      self.assertAllEqual(g2, [[2.0, 2.0], [2.0, 2.0], [2.0, 2.0]])
  
imports: from tensorflow.python.eager import context
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.ops.ragged import ragged_functional_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 8 for calling the RaggedTensorToSparseOpTest obj's underlying member method code with example usage: obj.testGradient() without return types