Enable typechecking of `collect_env.py` during CI (#43062)
Summary:
No type annotations can be added to the script, as it still have to be Python-2 compliant.
Make changes to avoid variable type redefinition.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/43062
Reviewed By: zou3519
Differential Revision: D23132991
Pulled By: malfet
fbshipit-source-id: 360c02e564398f555273e5889a99f834a5467059