Create helper function for RPC profiling in _invoke_rpc and remote (#56643)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56643
Refactor enabling rpc profiling logic in `_invoke_rpc` and `remote()` into `_rpc_profiling()` helper function.
Reviewed By: rohan-varma
Differential Revision: D27922286
fbshipit-source-id: 27cfe662a401756f0ee8a3cd45978d933377f78f