Modernize for-loops in caffe2/torch (#52618)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/52618
Pull Request resolved: https://github.com/pytorch/pytorch/pull/50797
Modernize for-loops throughout caffe2/ subdirs to use ranged-loops where possible (all `.cpp` files were examined).
```
find caffe2/ -iname "*.cpp" > /home/rbarnes/files
buck run mode/opt foundation/clangr:clangr_local -- -j 10 --file=/home/rbarnes/files --multi --apply-replacements=true tidy '--checks=-*,modernize-loop-convert'
```
Test Plan: Sandcastle tests
Reviewed By: suo
Differential Revision: D26585065
fbshipit-source-id: 439b9f9ce7c54fa9b4b80161f6bb27ebe8a35967