[Profiler][Trivial] Force Result to be a shared_ptr
Pull Request resolved: https://github.com/pytorch/pytorch/pull/77695
A lot of the graph manipulation in later changes will rely on the ability to hold stable references, both in C++ and Python.
Differential Revision: [D36302564](https://our.internmc.facebook.com/intern/diff/D36302564/)
Approved by: https://github.com/aaronenyeshi