class_docstr: 用来初始化 `Driver` 的基类，所有定制的 `driver` 都需要继承此类；
  **fastNLP** 提供的 driver 实例都会同时被 :class:`~fastNLP.core.controllers.Trainer` 和 :class:`~fastNLP.core.controllers.Evaluator` 调用。
  
  :param model: 训练或者评测的模型，需要注意该模型可能为用户已经使用类似 :class:`torch.nn.DataParallel` 或者
      :class:`torch.nn.parallel.DistributedDataParallel` 包裹过的模型。
class_docstr_tok: ["\u7528\u6765\u521d\u59cb\u5316","`","Driver","`","\u7684\u57fa\u7c7b\uff0c\u6240\u6709\u5b9a\u5236\u7684","`","driver","`","\u90fd\u9700\u8981\u7ee7\u627f\u6b64\u7c7b\uff1b","*","*","fastNLP","*","*","\u63d0\u4f9b\u7684","driver","\u5b9e\u4f8b\u90fd\u4f1a\u540c\u65f6\u88ab",":","class",":","`","~fastNLP.core.controllers.Trainer","`","\u548c",":","class",":","`","~fastNLP.core.controllers.Evaluator","`","\u8c03\u7528\u3002",":","param","model",":","\u8bad\u7ec3\u6216\u8005\u8bc4\u6d4b\u7684\u6a21\u578b\uff0c\u9700\u8981\u6ce8\u610f\u8be5\u6a21\u578b\u53ef\u80fd\u4e3a\u7528\u6237\u5df2\u7ecf\u4f7f\u7528\u7c7b\u4f3c",":","class",":","`","torch.nn.DataParallel","`","\u6216\u8005",":","class",":","`","torch.nn.parallel.DistributedDataParallel","`","\u5305\u88f9\u8fc7\u7684\u6a21\u578b\u3002"]
docstr: 用于在多进程工作时同步各进程的工作进度，运行快的进程运行到这里会等待运行慢的进程，只有所有进程都运行到此函数时，所有的进程才会继续运行；
  仅在多分布式训练场景中有使用。
  
  注意，该函数的行为会受到环境变量 ``FASTNLP_NO_SYNC`` 的影响。仅当 ``FASTNLP_NO_SYNC`` 在 ``os.environ`` 中不存在，或小于 **1** 时
  才真的执行 :meth:`barrier`。
docstr_tok: ["\u7528\u4e8e\u5728\u591a\u8fdb\u7a0b\u5de5\u4f5c\u65f6\u540c\u6b65\u5404\u8fdb\u7a0b\u7684\u5de5\u4f5c\u8fdb\u5ea6\uff0c\u8fd0\u884c\u5feb\u7684\u8fdb\u7a0b\u8fd0\u884c\u5230\u8fd9\u91cc\u4f1a\u7b49\u5f85\u8fd0\u884c\u6162\u7684\u8fdb\u7a0b\uff0c\u53ea\u6709\u6240\u6709\u8fdb\u7a0b\u90fd\u8fd0\u884c\u5230\u6b64\u51fd\u6570\u65f6\uff0c\u6240\u6709\u7684\u8fdb\u7a0b\u624d\u4f1a\u7ee7\u7eed\u8fd0\u884c\uff1b","\u4ec5\u5728\u591a\u5206\u5e03\u5f0f\u8bad\u7ec3\u573a\u666f\u4e2d\u6709\u4f7f\u7528\u3002","\u6ce8\u610f\uff0c\u8be5\u51fd\u6570\u7684\u884c\u4e3a\u4f1a\u53d7\u5230\u73af\u5883\u53d8\u91cf","``","FASTNLP_NO_SYNC","``","\u7684\u5f71\u54cd\u3002\u4ec5\u5f53","``","FASTNLP_NO_SYNC","``","\u5728","``","os.environ","``","\u4e2d\u4e0d\u5b58\u5728\uff0c\u6216\u5c0f\u4e8e","*","*","1","*","*","\u65f6","\u624d\u771f\u7684\u6267\u884c",":","meth",":","`","barrier","`","\u3002"]
code: def barrier(self):
      r"""
      用于在多进程工作时同步各进程的工作进度，运行快的进程运行到这里会等待运行慢的进程，只有所有进程都运行到此函数时，所有的进程才会继续运行；
      仅在多分布式训练场景中有使用。
  
      注意，该函数的行为会受到环境变量 ``FASTNLP_NO_SYNC`` 的影响。仅当 ``FASTNLP_NO_SYNC`` 在 ``os.environ`` 中不存在，或小于 **1** 时
      才真的执行 :meth:`barrier`。
      """
  
imports: import os
  import signal
  import sys
  from typing import Sequence, List, Optional, Callable, Dict, Union, Tuple
  from abc import ABC, abstractmethod
  from datetime import datetime
  from pathlib import Path
  from io import BytesIO
  import json
  from fastNLP.core.utils import nullcontext
label_desc: Use image node_id 35 for calling the Driver obj's underlying member method code with example usage: obj.barrier() without return types