class_docstr: Basic class handling tweaks of the training loop by changing a `Learner` in various events
class_docstr_tok: ["Basic","class","handling","tweaks","of","the","training","loop","by","changing","a","`","Learner","`","in","various","events"]
docstr: Call `self.{event_name}` if it's defined
docstr_tok: ["Call","`","self",".","{","event_name","}","`","if","it","'s","defined"]
code: def __call__(self, event_name):
      "Call `self.{event_name}` if it's defined"
      _run = (
          event_name not in _inner_loop
          or (self.run_train and getattr(self, "training", True))
          or (self.run_valid and not getattr(self, "training", False))
      )
      res = None
      if self.run and _run:
          try:
              res = getcallable(self, event_name)()
          except (
              CancelBatchException,
              CancelBackwardException,
              CancelEpochException,
              CancelFitException,
              CancelStepException,
              CancelTrainException,
              CancelValidException,
          ):
              raise
          except Exception as e:
              raise modify_exception(
                  e,
                  f"Exception occured in `{self.__class__.__name__}` when calling event `{event_name}`:\n\t{e.args[0]}",
                  replace=True,
              )
      if event_name == "after_fit":
          self.run = True  # Reset self.run to True at each end of fit
      return res
  
imports: from __future__ import annotations
  from ..data.all import *
  from ..optimizer import *
  from ..losses import BaseLoss
label_desc: Use image node_id 3 for calling the Callback obj's underlying member method code with example usage: obj.__call__(event_name) and returns: res