code: def test_against_dopri5(self):
      method_eps = {
          "dopri5": (3e-4, 1e-4, 2e-3),
          "scipy_solver": (3e-4, 1e-4, 2e-3),
      }
      for device in DEVICES:
          for method, eps in method_eps.items():
              for t_grad in (True, False):
                  with self.subTest(device=device, method=method):
                      func, y0, t_points = self.problem(device=device)
                      t_points.requires_grad_(t_grad)
  
                      ys = torchdiffeq.odeint_adjoint(
                          func, y0, t_points, method=method
                      )
                      gradys = torch.rand_like(ys) * 0.1
                      ys.backward(gradys)
  
                      adj_y0_grad = y0.grad
                      adj_t_grad = t_points.grad if t_grad else None
                      adj_A_grad = func.A.grad
                      self.assertEqual(
                          max_abs(func.unused_module.weight.grad), 0
                      )
                      self.assertEqual(
                          max_abs(func.unused_module.bias.grad), 0
                      )
  
                      func, y0, t_points = self.problem(device=device)
                      ys = torchdiffeq.odeint(
                          func, y0, t_points, method="dopri5"
                      )
                      ys.backward(gradys)
  
                      self.assertLess(
                          max_abs(y0.grad - adj_y0_grad), eps[0]
                      )
                      if t_grad:
                          self.assertLess(
                              max_abs(t_points.grad - adj_t_grad),
                              eps[1],
                          )
                      self.assertLess(
                          max_abs(func.A.grad - adj_A_grad), eps[2]
                      )
  
file_path: torchdiffeq/tests/gradient_tests.py
imports: import unittest
  import torch
  import torchdiffeq
  from problems import construct_problem, PROBLEMS, DEVICES, METHODS
label_desc: Use image node_id 2 for calling the TestCompareAdjointGradient obj's underlying member method code with example usage: obj.test_against_dopri5() without return types