def METHOD_NAME(
        model: BaseModel,
        dataset: Dataset,
        slicing_function: Optional[SlicingFunction] = None,
        threshold: Optional[float] = 0.10,
        p_threshold: float = 0.90,
        debug: bool = False
):
    """Tests that the rate of underconfident predictions is below a threshold.
    Underconfident predictions are defined as predictions where the two most
    probable labels have very similar probabilities. In this case, slight
    changes can make the model flip its predicted label. By default, we mark a
    prediction as underconfident when the second most probable prediction has a
    probability which is only less than 10% smaller than the predicted label
    (`p_threshold=0.90`).
    We then calculate the rate of underconfident predictions as the number of
    underconfident samples divided by the total number of samples, and check
    that it is below the user-specified threshold.
    Arguments:
        model(BaseModel): The model to test.
        dataset(Dataset): The dataset to test the model on.
        slicing_function(SlicingFunction, optional): An optional slicing
            function used to slice the dataset before testing. If not provided,
            the whole dataset will be considered in calculating the
            underconfidence rate.
        threshold(float, optional): The threshold for underconfident prediction
            rate. Default is 0.10 (10%).
        p_threshold(float, optional): The threshold for the relative value of
            the second most-probable prediction and the max probability. If
            greater that this value, the prediction is considered
            underconfident. Default is 0.90, i.e. when the second most probable
            prediction is 90% or more with respect to the highest probability,
            the sample prediction is considered underconfident.
        debug(bool):
            If True and the test fails,
            a dataset will be provided containing the rows that have an underconfidence score larger than p_threshold.
    """
    if not model.is_classification:
        raise ValueError("This test is only applicable to classification models.")
    if slicing_function is not None:
        dataset = dataset.slice(slicing_function)
    underconfidence_score = _calculate_underconfidence_score(model, dataset)
    underconfidence_mask = underconfidence_score.dropna() > p_threshold
    rate = (underconfidence_mask).mean()
    passed = rate < threshold
    # --- debug ---
    output_ds = None
    if not passed and debug:
        output_ds = dataset.copy()
        output_ds.df = dataset.df.loc[underconfidence_mask[underconfidence_mask].index]
        test_name = inspect.stack()[0][3]
        output_ds.name = debug_prefix + test_name
    # ---
    return TestResult(
        passed=bool(passed),
        metric=rate,
        output_df=output_ds
    )