fix dict size change during iteration (#111267)
Summary:
_wrapped_fns_to_patch points to f_globals which might change during iteration due to factors like lazy imports. This diff fixes potential runtime errors like:
```
RuntimeError: dictionary changed size during iteration
```
Test Plan: CI
Reviewed By: Kronuz
Differential Revision: D50283983
Pull Request resolved: https://github.com/pytorch/pytorch/pull/111267
Approved by: https://github.com/yanboliang