class_docstr: 实际使用的 callback 类，不管是 **fastNLP** 默认提供的一些 callback 实例，还是用户自己定制的 callback 类，都应该继承该基类；
  callback 调用时机顺序大概如下::
  
      Trainer.__init__():
          on_after_trainer_initialized(trainer, driver)
      Trainer.run():
          if num_eval_sanity_batch>0:
              on_sanity_check_begin(trainer)  # 如果设置了num_eval_sanity_batch
              on_sanity_check_end(trainer, sanity_check_res)
          try:
              on_train_begin(trainer)
              while cur_epoch_idx < n_epochs:
                  on_train_epoch_begin(trainer)
                  while batch_idx_in_epoch<=num_batches_per_epoch:
                      on_fetch_data_begin(trainer)
                      batch = next(dataloader)
                      on_fetch_data_end(trainer)
                      on_train_batch_begin(trainer, batch, indices)
                      on_before_backward(trainer, outputs)  # 其中 outputs 是经过 output_mapping（如果设置了） 后的，否则即为 model 的输出。
                      on_after_backward(trainer)
                      on_before_zero_grad(trainer, optimizers)  # 实际调用受到 accumulation_steps 影响
                      on_after_zero_grad(trainer, optimizers)  # 实际调用受到 accumulation_steps 影响
                      on_before_optimizers_step(trainer, optimizers)  # 实际调用受到 accumulation_steps 影响
                      on_after_optimizers_step(trainer, optimizers)  # 实际调用受到 accumulation_steps 影响
                      on_train_batch_end(trainer)
                  on_train_epoch_end(trainer)
          except BaseException:
              self.on_exception(trainer, exception)
          finally:
              on_train_end(trainer)
  
  其它 callback 例如 **on_evaluate_begin(trainer)** / **on_evaluate_end(trainer, results)** / **on_save_model(trainer)** / 
  **on_load_model(trainer)** / **on_save_checkpoint(trainer)** / **on_load_checkpoint(trainer)** 将根据需要在 :meth:`Trainer.run <fastNLP.core.controllers.Trainer.run>` 
  中特定的时间调用。
class_docstr_tok: ["\u5b9e\u9645\u4f7f\u7528\u7684","callback","\u7c7b\uff0c\u4e0d\u7ba1\u662f","*","*","fastNLP","*","*","\u9ed8\u8ba4\u63d0\u4f9b\u7684\u4e00\u4e9b","callback","\u5b9e\u4f8b\uff0c\u8fd8\u662f\u7528\u6237\u81ea\u5df1\u5b9a\u5236\u7684","callback","\u7c7b\uff0c\u90fd\u5e94\u8be5\u7ee7\u627f\u8be5\u57fa\u7c7b\uff1b","callback","\u8c03\u7528\u65f6\u673a\u987a\u5e8f\u5927\u6982\u5982\u4e0b",":",":","Trainer.__init__","(",")",":","on_after_trainer_initialized","(","trainer",",","driver",")","Trainer.run","(",")",":","if","num_eval_sanity_batch",">","0",":","on_sanity_check_begin","(","trainer",")","#","\u5982\u679c\u8bbe\u7f6e\u4e86num_eval_sanity_batch","on_sanity_check_end","(","trainer",",","sanity_check_res",")","try",":","on_train_begin","(","trainer",")","while","cur_epoch_idx","<","n_epochs",":","on_train_epoch_begin","(","trainer",")","while","batch_idx_in_epoch","<","=num_batches_per_epoch",":","on_fetch_data_begin","(","trainer",")","batch","=","next","(","dataloader",")","on_fetch_data_end","(","trainer",")","on_train_batch_begin","(","trainer",",","batch",",","indices",")","on_before_backward","(","trainer",",","outputs",")","#","\u5176\u4e2d","outputs","\u662f\u7ecf\u8fc7","output_mapping\uff08\u5982\u679c\u8bbe\u7f6e\u4e86\uff09","\u540e\u7684\uff0c\u5426\u5219\u5373\u4e3a","model","\u7684\u8f93\u51fa\u3002","on_after_backward","(","trainer",")","on_before_zero_grad","(","trainer",",","optimizers",")","#","\u5b9e\u9645\u8c03\u7528\u53d7\u5230","accumulation_steps","\u5f71\u54cd","on_after_zero_grad","(","trainer",",","optimizers",")","#","\u5b9e\u9645\u8c03\u7528\u53d7\u5230","accumulation_steps","\u5f71\u54cd","on_before_optimizers_step","(","trainer",",","optimizers",")","#","\u5b9e\u9645\u8c03\u7528\u53d7\u5230","accumulation_steps","\u5f71\u54cd","on_after_optimizers_step","(","trainer",",","optimizers",")","#","\u5b9e\u9645\u8c03\u7528\u53d7\u5230","accumulation_steps","\u5f71\u54cd","on_train_batch_end","(","trainer",")","on_train_epoch_end","(","trainer",")","except","BaseException",":","self.on_exception","(","trainer",",","exception",")","finally",":","on_train_end","(","trainer",")","\u5176\u5b83","callback","\u4f8b\u5982","*","*","on_evaluate_begin","(","trainer",")","*","*","\/","*","*","on_evaluate_end","(","trainer",",","results",")","*","*","\/","*","*","on_save_model","(","trainer",")","*","*","\/","*","*","on_load_model","(","trainer",")","*","*","\/","*","*","on_save_checkpoint","(","trainer",")","*","*","\/","*","*","on_load_checkpoint","(","trainer",")","*","*","\u5c06\u6839\u636e\u9700\u8981\u5728",":","meth",":","`","Trainer.run","<","fastNLP.core.controllers.Trainer.run",">","`","\u4e2d\u7279\u5b9a\u7684\u65f6\u95f4\u8c03\u7528\u3002"]
docstr: 在将要进行 ``evaluate`` 时调用。如果是设置的以 step 数量或自定义地决定 evaluate 的频率，该接口是在 :meth:`on_train_batch_end` 之后
  进行调用。如果是以 epoch 数量决定调用时机，该接口是在 :meth:`on_train_epoch_end` 之后调用。
  
  :param trainer: :class:`~fastNLP.core.controllers.Trainer` 实例；
docstr_tok: ["\u5728\u5c06\u8981\u8fdb\u884c","``","evaluate","``","\u65f6\u8c03\u7528\u3002\u5982\u679c\u662f\u8bbe\u7f6e\u7684\u4ee5","step","\u6570\u91cf\u6216\u81ea\u5b9a\u4e49\u5730\u51b3\u5b9a","evaluate","\u7684\u9891\u7387\uff0c\u8be5\u63a5\u53e3\u662f\u5728",":","meth",":","`","on_train_batch_end","`","\u4e4b\u540e","\u8fdb\u884c\u8c03\u7528\u3002\u5982\u679c\u662f\u4ee5","epoch","\u6570\u91cf\u51b3\u5b9a\u8c03\u7528\u65f6\u673a\uff0c\u8be5\u63a5\u53e3\u662f\u5728",":","meth",":","`","on_train_epoch_end","`","\u4e4b\u540e\u8c03\u7528\u3002",":","param","trainer",":",":","class",":","`","~fastNLP.core.controllers.Trainer","`","\u5b9e\u4f8b\uff1b"]
code: def on_evaluate_begin(self, trainer):
      r"""
      在将要进行 ``evaluate`` 时调用。如果是设置的以 step 数量或自定义地决定 evaluate 的频率，该接口是在 :meth:`on_train_batch_end` 之后
      进行调用。如果是以 epoch 数量决定调用时机，该接口是在 :meth:`on_train_epoch_end` 之后调用。
  
      :param trainer: :class:`~fastNLP.core.controllers.Trainer` 实例；
      """
      pass
  
imports: from typing import Callable, Dict, Optional
  from .callback_event import Event, Filter
label_desc: Use image node_id 23 for calling the Callback obj's underlying member method code with example usage: obj.on_evaluate_begin(trainer) without return types