add a hook for recompile user context (#157961)
Summary:
Users may want compile-related but customized logging info to dynamo_compile. One example is to logging the current training iteration index when recompilation happens. In general, current training iteration index is not available to compiler, since the same compiled function may be called multiple times in the same training iteration. The user could provide the training iteration index in a user hook where torch.compile logs it when recompilation happens.
X-link: https://github.com/pytorch/pytorch/pull/157961
Approved by: https://github.com/masnesral
Reviewed By: masnesral
Differential Revision: D78115274
fbshipit-source-id: 6e2023146772734515a356139aaac9263a9ece2a