def get_beta(gradk, gradk_1, cgradk_1):
    """compute the coefficient beta required to update CG direction"""
    _batch_size = gradk.shape[0]
    _cgradk_1 = cgradk_1.reshape(_batch_size, -1)
    _gradk = -gradk.reshape(_batch_size, -1)
    _gradk_1 = -gradk_1.reshape(_batch_size, -1)
    delta_gradk = _gradk - _gradk_1
    betak = -(_gradk * delta_gradk).sum(axis=1) / (
        (_cgradk_1 * delta_gradk).sum(axis=1) + np.finfo(ART_NUMPY_DTYPE).eps
    )
    return betak.reshape((_batch_size,) + (1,) * (len(gradk.shape) - 1))
compute the coefficient beta required to update CG direction
art/attacks/evasion/auto_conjugate_gradient.py