Refactor codegen file sharding (#62184)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/62184
File sharding is currently implemented twice, once for VariableType and once for
TraceType. This refactors the implementation into `FileManager` and also changes
it so template substitution is only done once and shared between the sharded
file and the "Everything" file.
Test Plan: Imported from OSS
Reviewed By: bdhirsh
Differential Revision: D29962050
Pulled By: albanD
fbshipit-source-id: 7858c3ca9f6e674ad036febd2d1a4ed2323a2861