from typing import Counter


def get_number_per_class_label(arr):
    """
    Function that returns the total number of images per (cloud) class labels,
    ignoring the missing entries.

    Parameters
    ----------
    arr : array-like
        The Image_Label column of the training.csv (after dropping the missing
        entries, where the entries are str dtype in the form "XXX.jpg_(class_name)".
        Here class_name is {Fish, Flower, Gravel, Sugar}

    Returns
    -------
    number_per_labels : Counter
        A Counter object with the total number of images per (cloud) class labels.

    Examples
    --------
    >>> arr = pd.DataFrame({'A': ["1.jpg_Fish", "1.jpg_Sugar", "2.jpg_Flower"]})
    >>> get_number_per_class_label(arr.A)
    Counter({'Fish': 1, 'Sugar': 1, 'Flower': 1})

    """
    class_per_entries = arr.apply(lambda x: str.split(x, '_')[1])
    number_per_labels = Counter(class_per_entries)
    return number_per_labels