@parameterized.named_parameters(({'testcase_name': '_{}'.format(scan_name), 'scan': scan_impl} for (scan_impl, scan_name) in SCAN_IMPLS))
def testScanHigherOrderDifferentiation(self, scan):
    d = 0.75

    def f(c, a):
        b = jnp.sin((c * jnp.sum(jnp.cos((d * a)))))
        c = (0.9 * jnp.cos((d * jnp.sum(jnp.sin((c * a))))))
        return (c, b)
    as_ = jnp.arange(6.0).reshape((3, 2))
    c = 1.0
    jtu.check_grads((lambda c, as_: scan(f, c, as_)), (c, as_), modes=['rev'], order=2, rtol={np.float32: 0.006})
@parameterized.named_parameters(({'testcase_name': '_{}'.format(scan_name), 'scan': scan_impl} for (scan_impl, scan_name) in SCAN_IMPLS))
def testScanHigherOrderDifferentiation(self, scan):
    d = 0.75

    def f(c, a):
        b = jnp.sin((c * jnp.sum(jnp.cos((d * a)))))
        c = (0.9 * jnp.cos((d * jnp.sum(jnp.sin((c * a))))))
        return (c, b)
    as_ = jnp.arange(6.0).reshape((3, 2))
    c = 1.0
    jtu.check_grads((lambda c, as_: scan(f, c, as_)), (c, as_), modes=['rev'], order=2, rtol={np.float32: 0.006})