Added option to update parameters using state_dict in AveragedModel (#65495)
Summary:
While implementing [EMA](https://github.com/pytorch/vision/pull/4381)(which extends AveragedModel) in torchvision, update_parameters() from AveragedModel could not be used as it did not handle state_dict(), so a custom update_parameters() needed to be defined in [EMA class](https://github.com/pytorch/vision/pull/4406). This PR aims to handle this scenario removing the need for this custom update_parameters() implementation.
Discussion: https://github.com/pytorch/vision/pull/4406#pullrequestreview-753734102
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65495
Reviewed By: datumbox
Differential Revision: D31176742
Pulled By: prabhat00155
fbshipit-source-id: 326d14876018f21cf602bab5eaba344678dbabe2