Remove attributes and method of submodules in frozen module
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.
ghstack-source-id: 9a779e07af0af086e7032c015937c898ac231709
Pull Request resolved: https://github.com/pytorch/pytorch/pull/34787