Fix test_randperm_device_compatibility for 1 GPU (#59484)
Summary:
Do not try to create tensors on 2nd device if device_count() == 1
Fixes #{issue number}
Pull Request resolved: https://github.com/pytorch/pytorch/pull/59484
Reviewed By: ngimel
Differential Revision: D28910673
Pulled By: malfet
fbshipit-source-id: e3517f31a463dd049ce8a5155409b7b716c8df18