Change ParameterList and ParameterDict to be able to contain any kind of objects (#70499)
Change ParameterList and ParameterDict to be able to contain any kind of objects (#70499)

Summary:
The only difference with plain list/dict now is that nn.Parameters are
handled specially and registered as parameters properly.

test_nn and parametrization works locally.
Will see in CI if DP is fixed as well.

Tentative fix for https://github.com/pytorch/pytorch/issues/36035

Pull Request resolved: https://github.com/pytorch/pytorch/pull/70499

Reviewed By: jbschlosser, alexeib

Differential Revision: D34005332

Pulled By: albanD

fbshipit-source-id: 7e76b0873d0fec345cb537e2a6ecba0258e662b9

pytorch/fairseq,pytorch/fairseq,pytorch/fairseq