def _find_data_between_ranges(data, ranges, top_k):
    """Finds the rows of the data that fall between each range.

    Args:
        data (pd.Series): The predicted probability values for the postive class.
        ranges (list): The threshold ranges defining the bins. Should include 0 and 1 as the first and last value.
        top_k (int): The number of row indices per bin to include as samples.

    Returns:
        list(list): Each list corresponds to the row indices that fall in the range provided.
    """
    results = []
    for i in range(1, len(ranges)):
        mask = data[(data >= ranges[i - 1]) & (data < ranges[i])]
        if top_k != -1:
            results.append(mask.index.tolist()[: min(len(mask), top_k)])
        else:
            results.append(mask.index.tolist())
    return results