human
Here's a good function header given the following:
I wrote the below code

    def _get_indices(expr, ind):
        '\n                                Collects    indices    recursively    in    predictable    order.\n                                '
        result = []
        for arg in expr.args:
            if (arg in ind):
                result.append(arg)
            elif arg.args:
                result.extend(_get_indices(arg, ind))
        return result
    def _choose_one_to_keep(a, b, ind):
        return min(a, b, key=(lambda x: default_sort_key(_get_indices(x, ind))))
    expr = expr.expand()
    if isinstance(expr, Add):
        terms = set(expr.args)
        for P in permutation_operators:
            new_terms = set([])
            on_hold = set([])
            while terms:
                term = terms.pop()
                permuted = P.get_permuted(term)
                if (permuted in (terms | on_hold)):
                    try:
                        terms.remove(permuted)
                    except KeyError:
                        on_hold.remove(permuted)
                    keep = _choose_one_to_keep(term, permuted, P.args)
                    new_terms.add((P * keep))
                else:
                    permuted1 = permuted
                    permuted = substitute_dummies(permuted)
                    if (permuted1 == permuted):
                        on_hold.add(term)
                    elif (permuted in (terms | on_hold)):
                        try:
                            terms.remove(permuted)
                        except KeyError:
                            on_hold.remove(permuted)
                        keep = _choose_one_to_keep(term, permuted, P.args)
                        new_terms.add((P * keep))
                    else:
                        new_terms.add(term)
            terms = (new_terms | on_hold)
        return Add(*terms)
    return expr

What's a good function header?
assistant
#Here's a good function header.

def simplify_index_permutations(expr, permutation_operators):