def get_multilabel_thresholds_cv(
    scores: np.ndarray,
    labels: np.ndarray,
    objective: METRIC_FN,
    num_splits: int = 5,
    num_repeats: int = 1,
    random_state: int = 42,
):
    """Finds best thresholds for multilabel classification task
    based on cross-validation estimates.

    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
        num_splits: number of splits to use for cross-validation
        num_repeats: number of repeats to use for cross-validation
        random_state: random state to use for cross-validation

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

    for class_index in range(num_classes):
        best_metric, best_threshold = get_binary_threshold_cv(
            labels=labels[:, class_index],
            scores=scores[:, class_index],
            objective=objective,
            num_splits=num_splits,
            num_repeats=num_repeats,
            random_state=random_state,
        )
        metrics[class_index] = best_metric
        thresholds[class_index] = best_threshold

    return metrics, thresholds
Finds best thresholds for multilabel classification task
    based on cross-validation estimates.

    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
        num_splits: number of splits to use for cross-validation
        num_repeats: number of repeats to use for cross-validation
        random_state: random state to use for cross-validation

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