It is not possible to do this exactly.
Well, you apparently don’t want (a == b).all().item().
What you could do is to see whether they point to the exact same memory range - i.e. .data_ptr(), .storage_offset(), .shape and .strides() are the same.
I’m not sure I recommend that. My impression is that you’re trying to do something that will end up not working well.
Best regards
Thomas