Allow Future::then to return pre-extracted DataPtrs (#58424)
Summary:
Pull Request resolved: 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: 129567044
Test Plan: Used in next PR.
Reviewed By: mrshenli
Differential Revision: D28474880
fbshipit-source-id: 91a0dde5e29d1afac55650c5dfb306873188d785