[PyTorch] Proper reset execution graph data in remove callback registration (#82910)
Summary: This diff fixed issues when execution graph register/unregister is called repeatedly in the training loop. It now properly reset the observer state so that data can be written to new files.
Test Plan:
```
buck build mode/dev-nosan caffe2/test:profiler --show-output
buck-out/gen/caffe2/test/profiler#binary.par test_profiler.TestExecutionGraph
```
Reviewed By: aaronenyeshi
Differential Revision: D37477814
Pull Request resolved: https://github.com/pytorch/pytorch/pull/82910
Approved by: https://github.com/chaekit