Fix nll_loss to support empty tensors on GPU (#31491)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31491
Fixes #31472
Test Plan: Imported from OSS
Differential Revision: D19537231
Pulled By: pbelevich
fbshipit-source-id: 20a43251a0f68a7a3557dd8234daee2d4814e5dd