separate deterministic scatter_add as a helper function (#97922)
separate it for better readability and and this helper function can be reused for the deterministic implementation of `scatter` and `scatter_reduce` with sum reduction mode.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/97922
Approved by: https://github.com/ngimel