from typing import List


def causality_idxs2mask(causality_idxs: List[List[int]]) -> List[List[int]]:
    """
    Creates a causality adjacency matrix from the node causality information.
    :param causality_idxs: Causality information, expressed as a list where
                 at each position there is a list of integers representing
                 the indexes of the heads, where the indexes are
                 the positions in the first list nesting level.
    :return: an adjacency matrix represented as a nested list with 1's
             representing the connectivity between nodes (and 0's for the
             lack of connectivity).
    """
    num_elems = len(causality_idxs)
    causality_matrix = []
    for elem_idx in range(num_elems):
        elem_deps = causality_idxs[elem_idx]
        elem_causality = [1 if idx in elem_deps or idx == elem_idx else 0
                          for idx in range(num_elems)]
        causality_matrix.append(elem_causality)
    return causality_matrix