I think the link answers 2D as well. Does this answer?
a = torch.FloatTensor([[1,2,3],[4,5,6]])
b = torch.FloatTensor([[1,2,9],[8,7,6]]) 
(a==b).nonzero()
 → tensor([[0, 0],         [0, 1],         [1, 2]])