Fix collect_env when pytorch is not installed (#47398)
Summary:
Moved all torch specific checks under `if TORCH_AVAILABLE` block
Embed gpu_info dict back into SystemEnv constructor creation and deduplicate some code between HIP and CUDA cases
Fixes https://github.com/pytorch/pytorch/issues/47397
Pull Request resolved: https://github.com/pytorch/pytorch/pull/47398
Reviewed By: walterddr
Differential Revision: D24740421
Pulled By: malfet
fbshipit-source-id: d0a1fe5b428617cb1a9d027324d24d7371c68d64