def adam_sparse_update_numpy_amsgrad(param, indices, g_t, t, m, v, vhat, lr=0.001, beta1=0.9, beta2=0.999, epsilon=1e-07):
    (m_t, v_t, vhat_t, param_t) = (np.copy(m), np.copy(v), np.copy(vhat), np.copy(param))
    lr_t = ((lr * np.sqrt((1 - (beta2 ** (t + 1))))) / (1 - (beta1 ** (t + 1))))
    m_t_slice = ((beta1 * m[indices]) + ((1 - beta1) * g_t))
    v_t_slice = ((beta2 * v[indices]) + (((1 - beta2) * g_t) * g_t))
    m_t[indices] = m_t_slice
    v_t[indices] = v_t_slice
    v_hat_t = np.maximum(vhat_t, v_t)
    v_hat_t_slice = v_hat_t[indices]
    param_t_slice = (param[indices] - (lr_t * (m_t_slice / (np.sqrt(v_hat_t_slice) + epsilon))))
    param_t[indices] = param_t_slice
    return (param_t, m_t, v_t, vhat_t)
def adam_sparse_update_numpy_amsgrad(param, indices, g_t, t, m, v, vhat, lr=0.001, beta1=0.9, beta2=0.999, epsilon=1e-07):
    (m_t, v_t, vhat_t, param_t) = (np.copy(m), np.copy(v), np.copy(vhat), np.copy(param))
    lr_t = ((lr * np.sqrt((1 - (beta2 ** (t + 1))))) / (1 - (beta1 ** (t + 1))))
    m_t_slice = ((beta1 * m[indices]) + ((1 - beta1) * g_t))
    v_t_slice = ((beta2 * v[indices]) + (((1 - beta2) * g_t) * g_t))
    m_t[indices] = m_t_slice
    v_t[indices] = v_t_slice
    v_hat_t = np.maximum(vhat_t, v_t)
    v_hat_t_slice = v_hat_t[indices]
    param_t_slice = (param[indices] - (lr_t * (m_t_slice / (np.sqrt(v_hat_t_slice) + epsilon))))
    param_t[indices] = param_t_slice
    return (param_t, m_t, v_t, vhat_t)