thank you, I will try that. I cannot believe that this is so difficult to accomplish since it is such a common task.
label = torch.tensor([1, 1, 0, 0])
pred = torch.tensor([1, 0, 1, 0])
result = labels[pred]

yields
result = tensor([1, 1, 1, 1])

why?
result = labels[pred] = 1

does not work either