import torch


def active(loss, threshold=1e-5):
    """
    Counts how many samples contribute to the loss.
    Args:
        loss
    Returns:
        The percentage of active samples.
    """
    return (loss > threshold).sum().to(torch.float) / len(loss)