torch.distributed.elastic.events.EventHandler interface and
configure it in your custom launcher.
# my_launcher.py
import torch.distributed.elastic.events as events
class MyEventHandler(events.EventHandler):
       def record(self, event: events.Event):
           # process event
def main():
     events.configure(MyEventHandler())
 spec = WorkerSpec(...)
 agent = LocalElasticAgent(spec)
 agent.run()
