fix is_ and is_not (#118978)
Fix issue https://github.com/pytorch/pytorch/issues/118805
Note: this was a refresh PR of https://github.com/pytorch/pytorch/pull/118806
discussion there is relevant
Pull Request resolved: https://github.com/pytorch/pytorch/pull/118978
Approved by: https://github.com/lezcano