Ensure all modules in the dict are instance instead of class (#72615)
Summary:
1. Add unit test to ensure the key in `ALL_MODULES` is an instance
2. In `generate_models.py`, add a check to ensure the key is an instance of `torch.nn.Module`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/72615
ghstack-source-id: 148771575
Test Plan:
```
buck test mode/opt //caffe2/test/jit/fixtures_srcs:test_upgrader_models_generation
```
Reviewed By: tugsbayasgalan
Differential Revision: D34116938
fbshipit-source-id: 36b32e00215bf26d471d984653dda5c866eaebc6
(cherry picked from commit 3a178bafc6e033ce6779b5b96fb7eafac70c9308)