def seq_to_arch(seq, num_nodes):
    """
    Translates given sequential representation of an architecture sampled by
    the controller to an architecture

    Arguments:
        seq: sequential representation of architecture
        num_nodes: number of nodes in cell including the two input nodes

    Returns:
        a list of 4-tuples (n0 op0 n1 op1), where n0 and n1 are two previous
        nodes and op0 and op1 are operations to be applied to n0 and n1,
        respectively. 
        e.g. [(0, 1, 0, 1), (0, 1, 0, 1), (0, 1, 0, 1), (0, 1, 0, 1), (0, 4, 0, 4)]
    """
    arch = []
    for i in range(0, len(seq), 4):
        arch.append(
            (
                seq[i].item() - 1,
                seq[i + 1].item() - (num_nodes - 1) - 1,
                seq[i + 2].item() - 1,
                seq[i + 3].item() - (num_nodes - 1) - 1,
            )
        )
    return arch