[torch.package] add utility for determining where bad modules may come from (#74998)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/74998
this is a cleaned-up version of a util that I commonly use to figure out where new transitive (surprise!) dependencies come from when a model breaks, since it can be difficult in large models to tell exactly what code change indirectly added the depdendency. I tried to keep the opinionated bits out of OSS as much as possible.
Reviewed By: PaliC
Differential Revision: D35265017
fbshipit-source-id: e126e03aa113db6ab79d32d86a69bcbba844875e
(cherry picked from commit ffa0f4b0a294cbcf7413b176d0d2fa0a605b3b9e)