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

    (abuckets, bbuckets, nabuckets, nbbuckets) = [sift(params, _mod1) for params in (target.ap, target.bq, origin.ap, origin.bq)]
    if ((len(list(abuckets.keys())) != len(list(nabuckets.keys()))) or (len(list(bbuckets.keys())) != len(list(nbbuckets.keys())))):
        raise ValueError(('%s    not    reachable    from    %s' % (target, origin)))
    ops = []
    def do_shifts(fro, to, inc, dec):
        ops = []
        for i in range(len(fro)):
            if ((to[i] - fro[i]) > 0):
                sh = inc
                ch = 1
            else:
                sh = dec
                ch = (-1)
            while (to[i] != fro[i]):
                ops += [sh(fro, i)]
                fro[i] += ch
        return ops
    def do_shifts_a(nal, nbk, al, aother, bother):
        '    Shift    us    from    (nal,    nbk)    to    (al,    nbk).    '
        return do_shifts(nal, al, (lambda p, i: ShiftA(p[i])), (lambda p, i: UnShiftA((p + aother), (nbk + bother), i, z)))
    def do_shifts_b(nal, nbk, bk, aother, bother):
        '    Shift    us    from    (nal,    nbk)    to    (nal,    bk).    '
        return do_shifts(nbk, bk, (lambda p, i: UnShiftB((nal + aother), (p + bother), i, z)), (lambda p, i: ShiftB(p[i])))
    for r in sorted((list(abuckets.keys()) + list(bbuckets.keys())), key=default_sort_key):
        al = ()
        nal = ()
        bk = ()
        nbk = ()
        if (r in abuckets):
            al = abuckets[r]
            nal = nabuckets[r]
        if (r in bbuckets):
            bk = bbuckets[r]
            nbk = nbbuckets[r]
        if ((len(al) != len(nal)) or (len(bk) != len(nbk))):
            raise ValueError(('%s    not    reachable    from    %s' % (target, origin)))
        (al, nal, bk, nbk) = [sorted(list(w), key=default_sort_key) for w in [al, nal, bk, nbk]]
        def others(dic, key):
            l = []
            for (k, value) in dic.items():
                if (k != key):
                    l += list(dic[k])
            return l
        aother = others(nabuckets, r)
       ...

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

def devise_plan(target, origin, z):