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: 对于分布式的 ``sampler``，例如 **pytorch** 的 :class:`DistributedSampler`，其需要在每一个 ``epoch`` 前设置随机数种子，来保证每一个进程上的 ``shuffle`` 是一样的；
  ``dataloader`` 中可能真正发挥作用的是 ``batch_sampler`` 也可能是 ``sampler``。
  
  :param dataloader: 需要设置 ``epoch`` 的 ``dataloader``
  :param cur_epoch_idx: 当前是第几个 ``epoch``
docstr_tok: ["\u5bf9\u4e8e\u5206\u5e03\u5f0f\u7684","``","sampler","``","\uff0c\u4f8b\u5982","*","*","pytorch","*","*","\u7684",":","class",":","`","DistributedSampler","`","\uff0c\u5176\u9700\u8981\u5728\u6bcf\u4e00\u4e2a","``","epoch","``","\u524d\u8bbe\u7f6e\u968f\u673a\u6570\u79cd\u5b50\uff0c\u6765\u4fdd\u8bc1\u6bcf\u4e00\u4e2a\u8fdb\u7a0b\u4e0a\u7684","``","shuffle","``","\u662f\u4e00\u6837\u7684\uff1b","``","dataloader","``","\u4e2d\u53ef\u80fd\u771f\u6b63\u53d1\u6325\u4f5c\u7528\u7684\u662f","``","batch_sampler","``","\u4e5f\u53ef\u80fd\u662f","``","sampler","``","\u3002",":","param","dataloader",":","\u9700\u8981\u8bbe\u7f6e","``","epoch","``","\u7684","``","dataloader","``",":","param","cur_epoch_idx",":","\u5f53\u524d\u662f\u7b2c\u51e0\u4e2a","``","epoch","``"]
code: def set_sampler_epoch(self, dataloader, cur_epoch_idx):
      r"""
      对于分布式的 ``sampler``，例如 **pytorch** 的 :class:`DistributedSampler`，其需要在每一个 ``epoch`` 前设置随机数种子，来保证每一个进程上的 ``shuffle`` 是一样的；
      ``dataloader`` 中可能真正发挥作用的是 ``batch_sampler`` 也可能是 ``sampler``。
  
      :param dataloader: 需要设置 ``epoch`` 的 ``dataloader``
      :param cur_epoch_idx: 当前是第几个 ``epoch``
      """
  
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 5 for calling the Driver obj's underlying member method code with example usage: obj.set_sampler_epoch(dataloader, cur_epoch_idx) without return types