[Profiler] Improve tree testing (#81895)
In the course of trying to get https://github.com/pytorch/pytorch/pull/80797 out the door, I've wound up making a number of minor tweaks to `test_profiler_tree` which collectively have made it much easier to debug. It's also revealed what seems to be a correctness issue with how profiler assigns lineage on certain platforms. So I've decided to pull those testing improvements into a standalone PR.
Differential Revision: [D38038122](https://our.internmc.facebook.com/intern/diff/D38038122/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/81895
Approved by: https://github.com/slgong-fb, https://github.com/davidchencsl