Skip undefined tensors when moving torch::nn module to a different device (#30523)
Summary:
This fixes high-pri issues such as https://github.com/pytorch/pytorch/issues/30508 and https://github.com/pytorch/pytorch/issues/30462.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30523
Differential Revision: D18732904
Pulled By: yf225
fbshipit-source-id: fe5a7a43838000f5803bd9c01ecfba0c3f02df5d