Reland #87025 and fix periodic tests (#87084)
- Relands #87025
- disables failing tests related to https://github.com/pytorch/torchdynamo/issues/1697
- Reverts https://github.com/pytorch/pytorch/commit/d01eea6027c26bf100fc99a705669f60648964ae
cc @lezcano @fdrocha @mlazos @soumith @voznesenskym @yanboliang
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87084
Approved by: https://github.com/malfet, https://github.com/voznesenskym