[c10d] Use macro to deduplicate codes (#101243)
Ops.cpp copies code for each of the three device keys (CPU, CUDA PrivateUse1).
Use macro to deduplicate it.
No logic change.
Cc @kumpera @H-Huang
Pull Request resolved: https://github.com/pytorch/pytorch/pull/101243
Approved by: https://github.com/H-Huang