def l2_normalize(F, data, axis=-1, eps=1E-6):
    """Normalize the data by L2 normalization.

    Parameters
    ----------
    F : mx.sym or mx.nd
    data : symbol or ndarray
    axis : int, default -1
    eps : float, default 1E-6

    Returns
    -------
    ret : mx.sym or mx.nd
    """
    ret = data / (F.np.linalg.norm(data, axis=axis, keepdims=True) + eps)
    return ret