Fixes https://github.com/pytorch/pytorch/issues/81223 Pull Request resolved: https://github.com/pytorch/pytorch/pull/81340 Approved by: https://github.com/albanD