[PyTorch] Solved two syntax issues when dumping execution graph result to json file. (#81854)
Summary:
Solved two syntax issues when dumping execution graph outputs to a json file.
1. Added workarounds to properly dump inf/nan values.
2. Added support for JSON string escape.
Test Plan:
```
buck build mode/dev-nosan caffe2/test:profiler --show-output
buck-out/gen/caffe2/test/profiler#binary.par test_profiler.TestExecutionGraph.test_execution_graph_start_stop
```
Differential Revision: D37292316
Pull Request resolved: https://github.com/pytorch/pytorch/pull/81854
Approved by: https://github.com/rajshahdev, https://github.com/chaekit