Fix DDP error checking for unused parameters (#36054)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/36054
Test Plan: Imported from OSS
Differential Revision: D20865498
Pulled By: mrshenli
fbshipit-source-id: 6dbb7b9b1d1ace3a8a619431330c260bfc43cefd