[JIT] Refactor SchemaCheckMode to check for mutated metadata (#79991)
- Refactored SchemaCheckMode so that arguments and outputs are only unflattened/unwrapped a single time
- Added cloned_metadata variable inside torch_dispatch which accounts for ops that mutate stride or storage()._cdata
- Fixed aliasing check to compare with any iterable outputs (ie list of tensor output)
- Fixed aliasing check to check ops with an (a -> *) notation argument correctly
- Changed order of mutation and aliasing checks to optimize error message usefulness (generally something incorrectly aliasing implies that something is also incorrectly mutating so an aliasing error gives more information)
- Added tests for resize_, as_strided to ensure that mutated metadata checking works as intended
Pull Request resolved: https://github.com/pytorch/pytorch/pull/79991
Approved by: https://github.com/davidberard98