class_docstr: 通过向命令行打印进度的方式显示。在打印 evaluate 的结果时，不会打印名称以 "_" 开头的内容。
  
  :param print_every: 多少个 batch 更新一次显示。
  :param loss_round_ndigit: 显示的 loss 保留多少位有效数字
  :param monitor: 监控的 metric 值。当检测到这个key的结果更好时，会打印出不同的颜色进行提示。
  
      * 为 ``None``
          将尝试使用 :class:`~fastNLP.core.controllers.Trainer` 中设置 `monitor` 值（如果有设置）。
      * 为 ``str``
          尝试直接使用该名称从 ``evaluation`` 结果中寻找，如果在 ``evaluation`` 结果中没有找到完全一致的名称，将
          使用 最长公共字符串算法 从 ``evaluation`` 结果中找到最匹配的那个作为 ``monitor`` 。
      * 为 :class:`Callable`
          接受参数为 ``evaluation`` 的结果(字典类型)，返回一个 ``float`` 值作为 ``monitor`` 的结果，如果当前结果中没有相关
          的 ``monitor`` 值请返回 ``None`` 。
  :param larger_better: 是否是monitor的结果越大越好。
  :param format_json: 是否format json再打印
class_docstr_tok: ["\u901a\u8fc7\u5411\u547d\u4ee4\u884c\u6253\u5370\u8fdb\u5ea6\u7684\u65b9\u5f0f\u663e\u793a\u3002\u5728\u6253\u5370","evaluate","\u7684\u7ed3\u679c\u65f6\uff0c\u4e0d\u4f1a\u6253\u5370\u540d\u79f0\u4ee5","``","_","''","\u5f00\u5934\u7684\u5185\u5bb9\u3002",":","param","print_every",":","\u591a\u5c11\u4e2a","batch","\u66f4\u65b0\u4e00\u6b21\u663e\u793a\u3002",":","param","loss_round_ndigit",":","\u663e\u793a\u7684","loss","\u4fdd\u7559\u591a\u5c11\u4f4d\u6709\u6548\u6570\u5b57",":","param","monitor",":","\u76d1\u63a7\u7684","metric","\u503c\u3002\u5f53\u68c0\u6d4b\u5230\u8fd9\u4e2akey\u7684\u7ed3\u679c\u66f4\u597d\u65f6\uff0c\u4f1a\u6253\u5370\u51fa\u4e0d\u540c\u7684\u989c\u8272\u8fdb\u884c\u63d0\u793a\u3002","*","\u4e3a","``","None","``","\u5c06\u5c1d\u8bd5\u4f7f\u7528",":","class",":","`","~fastNLP.core.controllers.Trainer","`","\u4e2d\u8bbe\u7f6e","`","monitor","`","\u503c\uff08\u5982\u679c\u6709\u8bbe\u7f6e\uff09\u3002","*","\u4e3a","``","str","``","\u5c1d\u8bd5\u76f4\u63a5\u4f7f\u7528\u8be5\u540d\u79f0\u4ece","``","evaluation","``","\u7ed3\u679c\u4e2d\u5bfb\u627e\uff0c\u5982\u679c\u5728","``","evaluation","``","\u7ed3\u679c\u4e2d\u6ca1\u6709\u627e\u5230\u5b8c\u5168\u4e00\u81f4\u7684\u540d\u79f0\uff0c\u5c06","\u4f7f\u7528","\u6700\u957f\u516c\u5171\u5b57\u7b26\u4e32\u7b97\u6cd5","\u4ece","``","evaluation","``","\u7ed3\u679c\u4e2d\u627e\u5230\u6700\u5339\u914d\u7684\u90a3\u4e2a\u4f5c\u4e3a","``","monitor","``","\u3002","*","\u4e3a",":","class",":","`","Callable","`","\u63a5\u53d7\u53c2\u6570\u4e3a","``","evaluation","``","\u7684\u7ed3\u679c","(","\u5b57\u5178\u7c7b\u578b",")","\uff0c\u8fd4\u56de\u4e00\u4e2a","``","float","``","\u503c\u4f5c\u4e3a","``","monitor","``","\u7684\u7ed3\u679c\uff0c\u5982\u679c\u5f53\u524d\u7ed3\u679c\u4e2d\u6ca1\u6709\u76f8\u5173","\u7684","``","monitor","``","\u503c\u8bf7\u8fd4\u56de","``","None","``","\u3002",":","param","larger_better",":","\u662f\u5426\u662fmonitor\u7684\u7ed3\u679c\u8d8a\u5927\u8d8a\u597d\u3002",":","param","format_json",":","\u662f\u5426format","json\u518d\u6253\u5370"]
code: def on_train_batch_end(self, trainer):
      if trainer.global_forward_batches % self.print_every == 0:
          loss = self.loss / self.print_every
          self.loss = 0
          text = (
              f"Epoch:{trainer.cur_epoch_idx}/{trainer.n_epochs}, Batch:{trainer.batch_idx_in_epoch}, "
              f"loss:{round(loss, self.loss_round_ndigit)}, "
              f"finished {round(trainer.global_forward_batches/trainer.n_batches*100, 2)}%."
          )
          logger.info(text)
  
imports: import json
  from typing import Union
  from .has_monitor_callback import HasMonitorCallback
  from fastNLP.core.utils import f_rich_progress, f_tqdm_progress
  from fastNLP.core.log import logger
label_desc: Use image node_id 4 for calling the RawTextCallback obj's underlying member method code with example usage: obj.on_train_batch_end(trainer) without return types