[Flaky tests] Fix flaky rpc profiling tests (#57517)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/57517
Fixes the flaky tests https://github.com/pytorch/pytorch/issues/45145
and https://github.com/pytorch/pytorch/issues/45067.
The root cause is that it is not the case that all remote events will be
children of the record function remote event, as other events can sometimes be
profiled under the hood such as the issue described in
https://github.com/pytorch/pytorch/issues/43868.
We fix this issue by verifying that the set of events that are children on the
remote end and children on the local end are the same, without necessarily
enforcing specific events to be logged.
Tested by running the test 1000+ times and verifying it passed. Will also test on CI box before landing
ghstack-source-id: 128200041
Test Plan: CI
Reviewed By: pritamdamania87
Differential Revision: D28166602
fbshipit-source-id: 8145857da4642aef31f360b20db00f4328abe2ca