[Profiler] Encapsulate callback handle management. (#83892)
Right now the profiler is capible of leaking callback handles if a client does not call `at::removeCallback`. (As well as a double free if two clients handle it.) This modestly improves the situation by pulling removal into a single method and calling that removal code in the dtor unless explicitly opted out. Once we deprecate the legacy profiler we can further simplify by making the ProfilerThreadLocalStateBase own the handle outright.
Differential Revision: [D38920537](https://our.internmc.facebook.com/intern/diff/D38920537/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/83892
Approved by: https://github.com/slgong-fb