human
I wrote the below code

    def extract_middle_names(first):
        return split_tex_string(first, 1)
    def extract_name_prefix(last):
        names = split_tex_string(last, 1)
        if (len(names) == 1):
            return names
        result = [names[0]]
        new_names = split_tex_string(names[1], 1)
        while ((len(new_names) > 1) and new_names[0].islower()):
            result[0] = u'    '.join((result[0], new_names[0]))
            names = new_names
            new_names = split_tex_string(names[1], 1)
        result.append(names[1])
        return result
    name_str = name_str.strip()
    parts = split_tex_string(name_str, sep=',[\\s~]*')
    if (len(parts) == 1):
        try:
            (last, first) = [part[::(-1)] for part in split_tex_string(parts[0][::(-1)], 1)]
        except ValueError:
            return NameResult(parts[0], '', '', '', '')
        first_parts = split_tex_string(first)
        first_parts_len = len(first_parts)
        if (first_parts_len > 1):
            lower_name_index = None
            for (i, part) in enumerate(first_parts[::(-1)], 1):
                if part.islower():
                    if ((lower_name_index is None) or (lower_name_index == (i - 1))):
                        lower_name_index = i
                    else:
                        break
            if (lower_name_index is not None):
                last = u'    '.join((u'    '.join(first_parts[(- lower_name_index):]), last))
                first = u'    '.join(first_parts[:(- lower_name_index)])
        forenames = extract_middle_names(first)
        lastnames = extract_name_prefix(last)
        return NameResult((forenames[0] if (len(forenames) > 0) else ''), (forenames[1] if (len(forenames) > 1) else ''), (lastnames[0] if (len(lastnames) > 1) else ''), (lastnames[1] if (len(lastnames) > 1) else lastnames[0]), '')
    elif (len(parts) == 2):
        (last, first) = parts
        first = u'    '.join((s for s in split_tex_string(first)))
        last = u'    '.join((s for s in split_tex_string(last)))
       ...

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

def tokenize_name(name_str):