OpenMP: Refactor parallel_reduce to share code with parallel_for (#60184)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/60184
Test Plan: Imported from OSS
Reviewed By: albanD
Differential Revision: D29287817
Pulled By: ngimel
fbshipit-source-id: 734a33a8d965208662989e2497b345b68c132498