Handle error during dict expansion (#51374)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/51374
Test Plan: Imported from OSS
Reviewed By: gmagogsfm
Differential Revision: D26155995
Pulled By: ansley
fbshipit-source-id: 04e924cb641565341c570c6cf5e5eec42e4f9c8b