backward passes and can be useful for passing some extra information
about execution environment (e.g. model id) from the higher layers of
the application down to the operator callbacks.
Invoking callbacks adds some overhead, so usually it's useful to just
randomly sample operator invocations. This can be enabled on per-
callback basis with an optional sampling rate passed into
"torch::addGlobalCallback".
Note, that "addGlobalCallback" is not thread-safe and can be called
only when no PyTorch operator is running. Usually, it's a good idea to
call them once during initialization.
Here's an example:
// Called somewhere in the program beginning
   void init() {
       // Sample one in a hundred operator runs randomly
       addGlobalCallback(
         RecordFunctionCallback(
           &onFunctionEnter,
           &onFunctionExit)
         .needsInputs(true)
         .samplingProb(0.01)
       );
       // Note, to enable observers in the model calling thread,