[package] patch inspect.getfile to work with PackageImporter (#51568)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/51568
The default behavior of inspect.getfile doesn't work on classes imported
from PackageImporter, because it returns the following.
sys.modules[kls.__module__].__file__
Looking in `sys.modules` is hard-coded behavior. So, patch it to first
check a similar registry of PackageImported modules we maintain.
Test Plan: Imported from OSS
Reviewed By: yf225
Differential Revision: D26201236
Pulled By: suo
fbshipit-source-id: aaf5d7ee8ca0155619c8185e64f70a30152ac567