Remove attributes and method of submodules in frozen module (#34787)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34787
This is a follow up patch of freezing of TorchScript modules. This patch
enables removal of constant attributes and unused method in submodules.
The clean up logic is generalized to handle attributes that share their class
type.
Test Plan: Imported from OSS
Differential Revision: D21004990
Pulled By: bzinodev
fbshipit-source-id: 84778aa9ae1a96d23db29c051031f9995ed3ac90