Do not assume what is in `os.environ` (#82495)
`os.environ['FOO']` will raise `IndexError` if `FOO` is not found, while `os.environ.get('FOO')` would simply return `None`
Fixes https://github.com/pytorch/pytorch/issues/82492
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82495
Approved by: https://github.com/huydhn, https://github.com/kit1980