fix device type bug for custom device (#97213)
Fixes #ISSUE_NUMBER
support the custom renamed device ,@bdhirsh , please review my changes.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/97213
Approved by: https://github.com/bdhirsh, https://github.com/kit1980