Fix stream graph output semantics (#164819)
Summary:
Preivously, we would stash a single stream value we constructed at trace time in a global and return the same value from repeated calls to the graph.
With this PR, we construct the stream value in advance, reference the constructed value in the graph via the lookup table, and if that value is returned as an output, read the value from the lookup table and return it (in bytecode, not as a graph output, since we don't support arbitrary stream outputs).
X-link: https://github.com/pytorch/pytorch/pull/164819
Approved by: https://github.com/anijain2305
Reviewed By: donigian
Differential Revision: D86056493
fbshipit-source-id: c65664e5cd43d00ce503e70a9c9eab2a58cbfaa9