def METHOD_NAME(sorting, delta_time: float = 0.4, agreement_threshold=0.2, duplicate_threshold=0.8):
    """
    Finds redundant or duplicate units by comparing the sorting output with itself.
    Parameters
    ----------
    sorting : BaseSorting
        The input sorting object
    delta_time : float, optional
        The time in ms to consider matching spikes, by default 0.4
    agreement_threshold : float, optional
        Threshold on the agreement scores to flag possible redundant/duplicate units, by default 0.2
    duplicate_threshold : float, optional
        Final threshold on the portion of coincident events over the number of spikes above which the
        unit is flagged as duplicate/redundant, by default 0.8
    Returns
    -------
    list
        The list of duplicate units
    list of 2-element lists
        The list of duplicate pairs
    """
    from spikeinterface.comparison import compare_two_sorters
    comparison = compare_two_sorters(sorting, sorting, delta_time=delta_time)
    # make agreement triangular and exclude diagonal
    agreement_scores_cleaned = np.tril(comparison.agreement_scores.values, k=-1)
    possible_pairs = np.where(agreement_scores_cleaned >= agreement_threshold)
    rows, cols = possible_pairs
    redundant_unit_pairs = []
    for r, c in zip(rows, cols):
        unit_i = sorting.unit_ids[r]
        unit_j = sorting.unit_ids[c]
        n_coincidents = comparison.match_event_count.at[unit_i, unit_j]
        event_counts = comparison.event_counts1
        shared = max(n_coincidents / event_counts[unit_i], n_coincidents / event_counts[unit_j])
        if shared > duplicate_threshold:
            redundant_unit_pairs.append([unit_i, unit_j])
    return redundant_unit_pairs