[Profiler] Use parent time for implicitly finished Torch ops (#80810)
When we implicitly mark an event as finished (for instance for user annotations which are never closed but whose parent finishes) the end time is never set. This can cause issues if we try to compute durations because the uninitialized value is less than start time and thus it makes no sense to compute a duration. This PR addresses this by allowing Torch ops which have been implicitly finished to use their parent's end time.
This issue was masked by the nanosecond to microsecond conversion: dividing the two times before subtracting keeps the numerics valid. (Even if the quantity itself is nonsensical.) It was only when I replaced
```
e->endTimeNS() / 1000 - e->start_time_ns_ / 1000
```
with
```
(e->endTimeNS() - e->start_time_ns_) / 1000
```
that UBSAN catches the issue.
Differential Revision: [D37591996](https://our.internmc.facebook.com/intern/diff/D37591996/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/80810
Approved by: https://github.com/aaronenyeshi