import torch


def remove_double_edges(edge_index):
    """In undirected graphs you have both (i, j) and (j, i) for every edge. 
    This method removes (j, i)."""
    row, col = edge_index
    mask = row <= col
    row, col = row[mask], col[mask]
    ei_without_double_edges = torch.stack([row, col], dim=0).long()
    return ei_without_double_edges