def METHOD_NAME(p, grad, m, s, s_max, t,
                      alpha, beta1, beta2, eps, wd,
                      amsgrad, weight_decouple, fixed_decay, rectify):
    beta1_t = beta1 ** t
    beta2_t = beta2 ** t
    bias_correction1 = (1. - beta1_t)
    bias_correction2 = np.sqrt(1. - beta2_t)
    m[...] = beta1 * m + (1 - beta1) * grad
    s[...] = beta2 * s + (1 - beta2) * (grad - m) * (grad - m)
    if amsgrad:
        s_max[...] = np.maximum(s_max, s)
        s_max += eps
        denominator = np.sqrt(s_max) / bias_correction2
    else:
        s += eps
        denominator = np.sqrt(s) / bias_correction2
    if weight_decouple:
        if fixed_decay:
            p[...] = p - p * wd
        else:
            p[...] = p - p * wd * alpha
    if rectify:
        rho_inf = 2.0 / (1.0 - beta2) - 1.0
        rho_t = rho_inf - 2.0 * t * beta2_t / (1.0 - beta2_t)
        if rho_t > 4.0:
            r_t_numerator = (rho_t - 4.0) * (rho_t - 2.0) * rho_inf
            r_t_denominator = (rho_inf - 4.0) * (rho_inf - 2.0) * rho_t
            r_t = np.sqrt(r_t_numerator / r_t_denominator)
            alpha_t = alpha * r_t / bias_correction1
            p[...] = p - alpha_t * m / (denominator + eps)
        else:
            p[...] = p - alpha * m
    else:
        alpha_t = alpha / bias_correction1
        p[...] = p - alpha_t * m / (denominator + eps)