import torch


def set_intersection(tensor1, tensor2):
    """Intersection of elements present in tensor1 and tensor2.
    Note: it only works if elements are unique in each tensor.
    """
    aux = torch.cat((tensor1, tensor2), dim=0)
    aux = aux.sort()[0]
    return aux[:-1][(aux[1:] == aux[:-1]).detach()]