[reland] Allow Future::then to return pre-extracted DataPtrs (#59207)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/59207
Reland of https://github.com/pytorch/pytorch/pull/58424
In CUDA mode, Future must inspect its value and extract DataPtrs. However some types are not supported, for example the C++/JIT custom classes, which include Message, which is widely used in RPC. Hence for these scenarios we allow the user to perform the custom DataPtr extraction on their own, and pass the pre-extracted DataPtrs.
Note that `markCompleted` already allowed users to pass in pre-extracted DataPtrs, hence this PR simply extends this possibility to the `then` method too.
ghstack-source-id: 130202846
Test Plan: Used in next PR.
Reviewed By: mrshenli
Differential Revision: D28623890
fbshipit-source-id: 468c5308b40774ba0a778b195add0e0845c1929e