def METHOD_NAME(self, grad, args, tol):
    """
    Test that the gradient can be applied correctly to a set of parameters
    and that accumulation works correctly.
    """
    stepsize, gamma, delta, eps = 0.1, 0.5, 0.8, 1e-8
    sgd_opt = AdamOptimizer(stepsize, beta1=gamma, beta2=delta, eps=eps)
    grad, args = np.array(grad), np.array(args, requires_grad=True)
    a1 = (1 - gamma) * grad
    b1 = (1 - delta) * grad**2
    a1_corrected = a1 / (1 - gamma)
    b1_corrected = b1 / (1 - delta)
    expected = args - stepsize * a1_corrected / (np.sqrt(b1_corrected) + eps)
    res = sgd_opt.apply_grad(grad, args)
    assert np.allclose(res, expected, atol=tol)
    # Simulate a new step
    grad = grad + args
    args = expected
    a2 = gamma * a1 + (1 - gamma) * grad
    b2 = delta * b1 + (1 - delta) * grad**2
    a2_corrected = a2 / (1 - gamma**2)
    b2_corrected = b2 / (1 - delta**2)
    expected = args - stepsize * a2_corrected / (np.sqrt(b2_corrected) + eps)
    res = sgd_opt.apply_grad(grad, args)
    assert np.allclose(res, expected, atol=tol)