from typing import Dict
from typing import List
from typing import Counter


def _get_best_class_names(
    class_names_to_probabilities: Dict[str, float], num_best_classes: int
) -> List[str]:
    """Returns 'num_best_classes' class names with the best probabilities.

    Args:
        class_names_to_probabilities (Dict[str, float]): A dictionary mapping predicted readable class names to their corresponding probabilites.
        num_best_classes (int): The number of classes with the highest probability to be returned.

    Returns:
        List[str]: A List of size 'num_best_classes' of the best predicted class names.
    """
    best_class_names_to_probabilities = {
        class_name: probability
        for class_name, probability in Counter(
            class_names_to_probabilities
        ).most_common()[:num_best_classes]
    }
    return list(best_class_names_to_probabilities.keys())