def _map_authorhip_to_paragraphs(labels_paragraph_author):
    """Map authorship labels per document to a binary label determining whether two paragraphs have
    the same author. Return a list of labels per document and tuples per document, containing the
    indices of the compared paragraphs. Used in task 3."""

    paragraph_pairs = []
    labels = []
    for author_list in labels_paragraph_author:
        curr_para_pairs = []
        curr_labels = []
        n_para = len(author_list)

        for i in range(n_para - 1):
            for j in range(i + 1, n_para):
                curr_para_pairs.append((i, j))

                if author_list[i] == author_list[j]:
                    curr_labels.append(1)
                else:
                    curr_labels.append(0)

        paragraph_pairs.append(curr_para_pairs)
        labels.append(curr_labels)
    return labels, paragraph_pairs