Fix dataloader hang with large sampler (#48669)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/48666
Pull Request resolved: https://github.com/pytorch/pytorch/pull/48669
Reviewed By: zhangguanheng66
Differential Revision: D25255763
Pulled By: VitalyFedyunin
fbshipit-source-id: d06421f52bb1d00cdf8025f1a2ba0d1f9284731a