Replace hasattr with getattr in pytorch/benchmark/run_e2e.py
Summary:
The pattern
```
X.Y if hasattr(X, "Y") else Z
```
can be replaced with
```
getattr(X, "Y", Z)
```
The [getattr](https://www.w3schools.com/python/ref_func_getattr.asp) function gives more succinct code than the [hasattr](https://www.w3schools.com/python/ref_func_hasattr.asp) function. Please use it when appropriate.
**This diff is very low risk. Green tests indicate that you can safely Accept & Ship.**
Reviewed By: xuzhao9
Differential Revision: D44886823
fbshipit-source-id: 942612a38a00df70cadb9643ad6faecd1e7f822c