Fix persistent_workers + pin_memory (#48543)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/48370 https://github.com/pytorch/pytorch/issues/47445
cc emcastillo who authored the original functionality.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/48543
Reviewed By: bdhirsh
Differential Revision: D25277474
Pulled By: ejguan
fbshipit-source-id: 1967002124fb0fff57caca8982bc7df359a059a2