# Path: torchdiffeq/_impl/rk_common.py
# class _UncheckedAssign(torch.autograd.Function):
# class RKAdaptiveStepsizeODESolver(AdaptiveStepsizeEventODESolver):
#     def forward(ctx, scratch, value, index):
#     def backward(ctx, grad_scratch):
# def _runge_kutta_step(func, y0, f0, t0, dt, t1, tableau):
# def rk4_step_func(func, t0, dt, t1, y0, f0=None, perturb=False):
# def rk4_alt_step_func(func, t0, dt, t1, y0, f0=None, perturb=False):
#     def __init__(self, func, y0, rtol, atol,
#                  first_step=None,
#                  step_t=None,
#                  jump_t=None,
#                  safety=0.9,
#                  ifactor=10.0,
#                  dfactor=0.2,
#                  max_num_steps=2 ** 31 - 1,
#                  dtype=torch.float64,
#                  **kwargs):
#     def _before_integrate(self, t):
#     def _advance(self, next_t):
#     def _advance_until_event(self, event_fn):
#     def _adaptive_step(self, rk_state):
#     def _interp_fit(self, y0, y1, k, dt):
# def _sort_tvals(tvals, t0):


import torch
from .rk_common import _ButcherTableau, RKAdaptiveStepsizeODESolver


A = [1 / 18, 1 / 12, 1 / 8, 5 / 16, 3 / 8, 59 / 400, 93 / 200, 5490023248 / 9719169821, 13 / 20, 1201146811 / 1299019798, 1, 1, 1]

B = [
    [1 / 18],

    [1 / 48, 1 / 16],


# Path: torchdiffeq/_impl/rk_common.py
# class _UncheckedAssign(torch.autograd.Function):
# class RKAdaptiveStepsizeODESolver(AdaptiveStepsizeEventODESolver):
#     def forward(ctx, scratch, value, index):
#     def backward(ctx, grad_scratch):
# def _runge_kutta_step(func, y0, f0, t0, dt, t1, tableau):
# def rk4_step_func(func, t0, dt, t1, y0, f0=None, perturb=False):
# def rk4_alt_step_func(func, t0, dt, t1, y0, f0=None, perturb=False):
#     def __init__(self, func, y0, rtol, atol,
#                  first_step=None,
#                  step_t=None,
#                  jump_t=None,
#                  safety=0.9,
#                  ifactor=10.0,
#                  dfactor=0.2,
#                  max_num_steps=2 ** 31 - 1,
#                  dtype=torch.float64,
#                  **kwargs):
#     def _before_integrate(self, t):
#     def _advance(self, next_t):
#     def _advance_until_event(self, event_fn):
#     def _adaptive_step(self, rk_state):
#     def _interp_fit(self, y0, y1, k, dt):
# def _sort_tvals(tvals, t0):


# Path: torchdiffeq/_impl/dopri8.py
import torch
from .rk_common import _ButcherTableau, RKAdaptiveStepsizeODESolver



A = [1 / 18, 1 / 12, 1 / 8, 5 / 16, 3 / 8, 59 / 400, 93 / 200, 5490023248 / 9719169821, 13 / 20, 1201146811 / 1299019798, 1, 1, 1]

B = [
    [1 / 18],

    [1 / 48, 1 / 16],


    [1 / 32, 0, 3 / 32],