r"""
    Args:
        items (?):
        min_thresh (int): (default = 0)
        Kstart (int): (default = 2)

    Returns:
        ?: prev_subset_idx

    CommandLine:
        python -m utool.util_alg --exec-max_size_max_distance_subset

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_alg import *  # NOQA
        >>> items = [1, 2, 3, 4, 5, 6, 7, 8, 9]
        >>> min_thresh = 3
        >>> Kstart = 2
        >>> verbose = True
        >>> prev_subset_idx = max_size_max_distance_subset(items, min_thresh,
        >>>                                                Kstart, verbose=verbose)
        >>> result = ('prev_subset_idx = %s' % (str(prev_subset_idx),))
        >>> print(result)

def max_size_max_distance_subset(items, min_thresh=0, Kstart=2, verbose=False):
    r"""
    Args:
        items (?):
        min_thresh (int): (default = 0)
        Kstart (int): (default = 2)

    Returns:
        ?: prev_subset_idx

    CommandLine:
        python -m utool.util_alg --exec-max_size_max_distance_subset

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_alg import *  # NOQA
        >>> items = [1, 2, 3, 4, 5, 6, 7, 8, 9]
        >>> min_thresh = 3
        >>> Kstart = 2
        >>> verbose = True
        >>> prev_subset_idx = max_size_max_distance_subset(items, min_thresh,
        >>>                                                Kstart, verbose=verbose)
        >>> result = ('prev_subset_idx = %s' % (str(prev_subset_idx),))
        >>> print(result)
    """
    import utool as ut
    assert Kstart >= 2, 'must start with group of size 2'
    best_idxs = []
    for K in range(Kstart, len(items)):
        if verbose:
            print('Running subset chooser')
        value, subset_idx, subset = ut.maximum_distance_subset(items, K=K,
                                                               verbose=verbose)
        if verbose:
            print('subset = %r' % (subset,))
            print('subset_idx = %r' % (subset_idx,))
            print('value = %r' % (value,))
        distances = ut.safe_pdist(subset[:, None])
        if np.any(distances < min_thresh):
            break
        best_idxs = subset_idx
    return best_idxs