[PyTorch] Implement improved version of gather_ranges_to_dense (#66664)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/66664
Reviewed By: hlu1
Differential Revision: D31325860
fbshipit-source-id: 8e154f929ff7c597ff6e41f18278b24c552d1719