code: def test_riccati(self, solver, solution_times_fn):
      ode_fn = lambda time, state: (state - time) ** 2 + 1.0
      initial_time = 0.0
      initial_state_value = 0.5
      initial_state = tf.constant(initial_state_value, dtype=tf.float64)
      final_time = 1.0
      jacobian_fn = lambda time, state: 2.0 * (state - time)
      solver_instance = solver(rtol=_RTOL, atol=_ATOL)
  
      def grad_fn(initial_state):
          results = solver_instance.solve(
              ode_fn,
              initial_time,
              initial_state,
              solution_times=solution_times_fn(final_time),
              jacobian_fn=jacobian_fn,
          )
          return results.states[-1]
  
      grad = self.evaluate(
          tfp_gradient.value_and_gradient(grad_fn, initial_state)[1]
      )
      grad_exact = 1.0 / (1.0 - initial_state_value * final_time) ** 2
      self.assertAllClose(grad, grad_exact, rtol=1e-3, atol=1e-3)
  
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import test_util
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.math.ode import base
  from tensorflow_probability.python.math.ode import bdf
  from tensorflow_probability.python.math.ode import dormand_prince
label_desc: Use image node_id 1 for calling the GradientTest obj's underlying member method code with example usage: obj.test_riccati(solver, solution_times_fn) and returns: results