human
I wrote the below code

    if (not nx.is_directed_acyclic_graph(G)):
        raise nx.NetworkXError('LCA    only    defined    on    directed    acyclic    graphs.')
    elif (len(G) == 0):
        raise nx.NetworkXPointlessConcept('LCA    meaningless    on    null    graphs.')
    elif (None in G):
        raise nx.NetworkXError('None    is    not    a    valid    node.')
    if ((not isinstance(pairs, (Mapping, Set))) and (pairs is not None)):
        pairs = set(pairs)
    sources = [n for (n, deg) in G.in_degree if (deg == 0)]
    if (len(sources) == 1):
        root = sources[0]
        super_root = None
    else:
        G = G.copy()
        super_root = root = generate_unique_node()
        for source in sources:
            G.add_edge(root, source)
    spanning_tree = nx.dfs_tree(G, root)
    dag = nx.DiGraph(((u, v) for (u, v) in G.edges if ((u not in spanning_tree) or (v not in spanning_tree[u]))))
    spanning_tree.add_nodes_from(G)
    dag.add_nodes_from(G)
    counter = count()
    root_distance = {root: next(counter)}
    for edge in nx.bfs_edges(spanning_tree, root):
        for node in edge:
            if (node not in root_distance):
                root_distance[node] = next(counter)
    euler_tour_pos = {}
    for node in nx.depth_first_search.dfs_preorder_nodes(G, root):
        if (node not in euler_tour_pos):
            euler_tour_pos[node] = next(counter)
    pairset = set()
    if (pairs is not None):
        pairset = set(chain.from_iterable(pairs))
    for n in pairset:
        if (n not in G):
            msg = ('The    node    %s    is    not    in    the    digraph.' % str(n))
            raise nx.NodeNotFound(msg)
    ancestors = {}
    for v in dag:
        if ((pairs is None) or (v in pairset)):
            my_ancestors = nx.dag.ancestors(dag, v)
            my_ancestors.add(v)
            ancestors[v] = sorted(my_ancestors, key=euler_tour_pos.get)
    def _compute_dag_lca_from_tree_values(tree_lca, dry_run):
        "Iterate    through    the    in-order    merge    for    each    pair    of   ...

What's a good function header?

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

@not_implemented_for('multigraph', 'undirected')
def all_pairs_lowest_common_ancestor(G, pairs=None):