This shouldn’t happen if you compare the right values and not only their references.
Could you post an executable code snippet using random tensors, which would reproduce this issue so that we could have a loop at it, please?