[reland] Allow external CUDA streams to be set as current (#66324)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/66324
Fixes https://github.com/pytorch/pytorch/issues/65822.
Reland of https://github.com/pytorch/pytorch/pull/65914.
ghstack-source-id: 140105651
Test Plan: Added tests
Reviewed By: ngimel
Differential Revision: D31506134
fbshipit-source-id: ff56203a120befdb282e974309478ac11aa56652