I used np.intersect1d 140 like:
>>> import torch
>>> import numpy as np
>>> a = torch.tensor([1, 2, 3, 6])
>>> b = torch.tensor([0, 2, 3, 7])
>>> np.intersect1d(a, b)
array([2, 3])

It seems that tensorflow 2.0 has a function named tf.sets.intersection 151