def METHOD_NAME(self, node_labels: Tensor, edge_scores: Tensor,
                 edge_labels: Tensor) -> Tuple[Tensor, Tensor]:
    """Reconstruct the edges and update edge scores according to
    ``link_type``.
    Args:
        data_sample (KIEDataSample): A datasample containing prediction
            results.
    Returns:
        tuple(Tensor, Tensor):
        - edge_scores (Tensor): A float tensor of shape (N, N)
            indicating the confidence scores for edge predictions.
        - edge_labels (Tensor): An integer tensor of shape (N, N)
            indicating the connection between nodes. Options are 0, 1.
    """
    # Obtain the scores of the existence of edges.
    pos_edges_scores = edge_scores.clone()
    edge_labels_mask = edge_labels.bool()
    pos_edges_scores[
        ~edge_labels_mask] = 1 - pos_edges_scores[~edge_labels_mask]
    # Temporarily convert the directed graph to undirected by adding
    # reversed edges to every pair of nodes if they were already connected
    # by an directed edge before.
    edge_labels = torch.max(edge_labels, edge_labels.T)
    # Maximize edge scores
    edge_labels_mask = edge_labels.bool()
    edge_scores[~edge_labels_mask] = pos_edges_scores[~edge_labels_mask]
    new_edge_scores = torch.max(edge_scores, edge_scores.T)
    # Only reconstruct the edges from key nodes to value nodes.
    key_nodes_mask = node_labels == self.key_node_idx
    value_nodes_mask = node_labels == self.value_node_idx
    key2value_mask = key_nodes_mask[:, None] * value_nodes_mask[None, :]
    if self.link_type == 'many-to-many':
        new_edge_labels = (key2value_mask * edge_labels).int()
    else:
        new_edge_labels = torch.zeros_like(edge_labels).int()
        tmp_edge_scores = new_edge_scores.clone().cpu()
        tmp_edge_scores[~edge_labels_mask] = -1
        tmp_edge_scores[~key2value_mask] = -1
        # Greedily extract valid edges
        while (tmp_edge_scores > -1).any():
            i, j = np.unravel_index(
                torch.argmax(tmp_edge_scores), tmp_edge_scores.shape)
            new_edge_labels[i, j] = 1
            if self.link_type == 'one-to-one':
                tmp_edge_scores[i, :] = -1
                tmp_edge_scores[:, j] = -1
            elif self.link_type == 'one-to-many':
                tmp_edge_scores[:, j] = -1
            elif self.link_type == 'many-to-one':
                tmp_edge_scores[i, :] = -1
    return new_edge_scores.cpu(), new_edge_labels.cpu()