[package] Add dependency tracing function (#55167)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55167
**Summary**
This commit adds a function that uses `sys.setprofile` to trace the
execution of a callable in order to determine which modules it really
uses. The result of this trace can inform packaging decisions.
**Test Plan**
This commit adds a unit test to `test_analyze.py` that tests this
feature.
Test Plan: Imported from OSS
Reviewed By: jbschlosser
Differential Revision: D27730805
Pulled By: SplitInfinity
fbshipit-source-id: 11802625564513da9a0144904be0d34dbae0f601