from typing import Counter


def small_class(raw_data, labels, threshold=20):
    """Removes samples and classes for classes that have less than
    `threshold` number of samples."""
    counts = Counter(labels)
    data, n_labels = [], []
    for i, l in enumerate(labels):
        if counts[l] >= threshold:
            data.append(raw_data[i])
            n_labels.append(l)
    return data, n_labels