@parameterized.named_parameters(({'testcase_name': f'_{name}', 'cond': cond} for (cond, name) in COND_IMPLS))
def testCondGrad3(self, cond):

    def fun_ref(x):
        if (x < 3):
            return 2.0
        else:
            return (2.0 * x)

    def fun(x):
        return cond((x < 3), (), (lambda _: 2.0), x, (lambda x: (2.0 * x)))
    x = 3.14
    ans = api.grad(fun)(x)
    expected = api.grad(fun_ref)(x)
    self.assertAllClose(ans, expected, check_dtypes=False)
    jtu.check_grads(fun, (x,), order=2, modes=['fwd', 'rev'])
    x = 2.72
    ans = api.grad(fun)(x)
    expected = api.grad(fun_ref)(x)
    self.assertAllClose(ans, expected, check_dtypes=False)
    jtu.check_grads(fun, (x,), order=2, modes=['fwd', 'rev'])
@parameterized.named_parameters(({'testcase_name': f'_{name}', 'cond': cond} for (cond, name) in COND_IMPLS))
def testCondGrad3(self, cond):

    def fun_ref(x):
        if (x < 3):
            return 2.0
        else:
            return (2.0 * x)

    def fun(x):
        return cond((x < 3), (), (lambda _: 2.0), x, (lambda x: (2.0 * x)))
    x = 3.14
    ans = api.grad(fun)(x)
    expected = api.grad(fun_ref)(x)
    self.assertAllClose(ans, expected, check_dtypes=False)
    jtu.check_grads(fun, (x,), order=2, modes=['fwd', 'rev'])
    x = 2.72
    ans = api.grad(fun)(x)
    expected = api.grad(fun_ref)(x)
    self.assertAllClose(ans, expected, check_dtypes=False)
    jtu.check_grads(fun, (x,), order=2, modes=['fwd', 'rev'])