Renames the tokens of a graph (``docgraph_with_old_names``) in-place,
    using the token names of another document graph
    (``docgraph_with_new_names``). Also updates the ``.tokens`` list of the old
    graph.

    This will only work, iff both graphs have the same tokenization.

def rename_tokens(docgraph_with_old_names, docgraph_with_new_names, verbose=False):
    """
    Renames the tokens of a graph (``docgraph_with_old_names``) in-place,
    using the token names of another document graph
    (``docgraph_with_new_names``). Also updates the ``.tokens`` list of the old
    graph.

    This will only work, iff both graphs have the same tokenization.
    """
    old2new = create_token_mapping(docgraph_with_old_names,
                                   docgraph_with_new_names, verbose=verbose)

    # save the mappings from old to new token node IDs in the `renamed_nodes`
    # attribute of the merged graph
    if hasattr(docgraph_with_new_names, 'renamed_nodes'):
        docgraph_with_new_names.renamed_nodes.update(old2new)
    else:
        docgraph_with_new_names.renamed_nodes = old2new

    relabel_nodes(docgraph_with_old_names, old2new, copy=False)
    new_token_ids = old2new.values()

    # new_token_ids could be empty (if docgraph_with_new_names is still empty)
    if new_token_ids:
        docgraph_with_old_names.tokens = new_token_ids