def get_multiclass_thresholds(
    scores: np.ndarray, labels: np.ndarray, objective: METRIC_FN
) -> Tuple[List[float], List[float]]:
    """Finds best thresholds for multiclass classification task.

    Args:
        scores: estimated per-class scores/probabilities predicted by the model,
            numpy array with shape [num_examples, num_classes]
        labels: ground truth labels, numpy array with shape [num_examples, num_classes]
        objective: callable function, metric which we want to maximize

    Returns:
        tuple with best found objective score and per-class thresholds
    """
    num_classes = scores.shape[1]
    metrics = [0.0] * num_classes
    thresholds = [0.0] * num_classes

    # score threshold -> classes with such score
    classes_by_threshold = defaultdict(list)
    for class_index in range(num_classes):
        for score in np.unique(scores[:, class_index]):
            classes_by_threshold[score].append(class_index)

    for threshold in sorted(classes_by_threshold):
        for class_index in classes_by_threshold[threshold]:
            metric_value = objective(
                labels[:, class_index], scores[:, class_index] >= threshold
            )
            if metric_value > metrics[class_index]:
                metrics[class_index] = metric_value
                thresholds[class_index] = threshold

    return metrics, thresholds
Finds best thresholds for multiclass classification task.

    Args:
        scores: estimated per-class scores/probabilities predicted by the model,
            numpy array with shape [num_examples, num_classes]
        labels: ground truth labels, numpy array with shape [num_examples, num_classes]
        objective: callable function, metric which we want to maximize

    Returns:
        tuple with best found objective score and per-class thresholds
    
catalyst/contrib/utils/thresholds.py