Fix cuda/cpu check on NoneType (#88854)
Summary: Fix cuda/cpu check on NoneType
Test Plan: sabdcastle/ github CI/CD
Differential Revision: D41203955
Pull Request resolved: https://github.com/pytorch/pytorch/pull/88854
Approved by: https://github.com/drisspg, https://github.com/ngimel