def zero_norm(preds, thr=1e-7):
    """
    Numpy implementation of the L0 norm.

    Parameters
    ----------
    preds: array-like, shape=(n_samples, n_clusters)
        Soft-assignments extracted from a DM-Encoder
    thr: float
        Threshold used to compute the L0 norm.

    Returns
    -------
    L0: float
        L0 norm of the soft-assignments.
    """
    
    counts = (preds>thr).astype("float32").sum(axis=1)
    return counts