Thank you for your answer, maybe I was not clear. Let me try again

Both A and B are in the same tensor
When I compare, I want the actual values and their indices as well. Please be kind enough to check my 5 lines of code above. Thank you