class_docstr: 实现了 **PaddlePaddle** 框架下在单卡或 ``cpu`` 环境下训练功能的 **Driver**。
  
  :param model: 训练时使用的 **PaddlePaddle** 模型
  :param device: 训练使用的设备
  :param fp16: 是否开启混合精度训练
  :param paddle_kwargs:
      * *gradscaler_kwargs* -- 用于 ``fp16=True`` 时，提供给 :class:`paddle.amp.GradScaler` 的参数。
  :kwargs:
      * *model_wo_auto_param_call* (``bool``) -- 是否关闭在训练时调用我们的 ``auto_param_call`` 函数来自动匹配 batch 和前向函数的参数的行为。
  
      .. note::
  
          关于该参数的详细说明，请参见 :class:`~fastNLP.core.controllers.Trainer` 中的描述；函数 ``auto_param_call`` 详见 :func:`fastNLP.core.utils.auto_param_call`。
class_docstr_tok: ["\u5b9e\u73b0\u4e86","*","*","PaddlePaddle","*","*","\u6846\u67b6\u4e0b\u5728\u5355\u5361\u6216","``","cpu","``","\u73af\u5883\u4e0b\u8bad\u7ec3\u529f\u80fd\u7684","*","*","Driver","*","*","\u3002",":","param","model",":","\u8bad\u7ec3\u65f6\u4f7f\u7528\u7684","*","*","PaddlePaddle","*","*","\u6a21\u578b",":","param","device",":","\u8bad\u7ec3\u4f7f\u7528\u7684\u8bbe\u5907",":","param","fp16",":","\u662f\u5426\u5f00\u542f\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3",":","param","paddle_kwargs",":","*","*","gradscaler_kwargs","*","--","\u7528\u4e8e","``","fp16=True","``","\u65f6\uff0c\u63d0\u4f9b\u7ed9",":","class",":","`","paddle.amp.GradScaler","`","\u7684\u53c2\u6570\u3002",":","kwargs",":","*","*","model_wo_auto_param_call","*","(","``","bool","``",")","--","\u662f\u5426\u5173\u95ed\u5728\u8bad\u7ec3\u65f6\u8c03\u7528\u6211\u4eec\u7684","``","auto_param_call","``","\u51fd\u6570\u6765\u81ea\u52a8\u5339\u914d","batch","\u548c\u524d\u5411\u51fd\u6570\u7684\u53c2\u6570\u7684\u884c\u4e3a\u3002","..","note",":",":","\u5173\u4e8e\u8be5\u53c2\u6570\u7684\u8be6\u7ec6\u8bf4\u660e\uff0c\u8bf7\u53c2\u89c1",":","class",":","`","~fastNLP.core.controllers.Trainer","`","\u4e2d\u7684\u63cf\u8ff0\uff1b\u51fd\u6570","``","auto_param_call","``","\u8be6\u89c1",":","func",":","`","fastNLP.core.utils.auto_param_call","`","\u3002"]
code: def set_dist_repro_dataloader(
      self,
      dataloader,
      dist: Union[
          str, ReproducibleBatchSampler, ReproducibleSampler
      ] = None,
      reproducible: bool = False,
  ):
      # 暂时不支持iterableDataset
      assert (
          dataloader.dataset_kind != _DatasetKind.ITER
      ), "FastNLP does not support `IteratorDataset` now."
      # 如果 dist 为 ReproducibleBatchSampler, ReproducibleIterator 说明是在断点重训时 driver.load_checkpoint 函数调用；
      if isinstance(dist, ReproducibleBatchSampler):
          return replace_batch_sampler(dataloader, dist)
      elif isinstance(dist, ReproducibleSampler):
          return replace_sampler(dataloader, dist)
  
      # 如果 dist 为 str 或者 None，说明是在 trainer 初试化时调用；
      args = self.get_dataloader_args(dataloader)
      if isinstance(args.batch_sampler, ReproducibleBatchSampler):
          batch_sampler = re_instantiate_sampler(args.batch_sampler)
          return replace_batch_sampler(dataloader, batch_sampler)
      elif isinstance(args.sampler, ReproducibleSampler):
          sampler = re_instantiate_sampler(args.sampler)
          return replace_sampler(dataloader, sampler)
  
      if reproducible:
          if type(args.batch_sampler) is PaddleBatchSampler:
              if type(args.sampler) is PaddleRandomSampler:
                  if isinstance(args.sampler, PaddleRandomSampler):
                      if (
                          getattr(args.sampler, "_num_samples", None)
                          is None
                          and getattr(
                              args.sampler, "replacements", False
                          )
                          is False
                          and getattr(args.sampler, "generator", None)
                          is None
                      ):
                          # 如果本来就是随机的，并且没有定制，直接替换掉。
                          sampler = RandomSampler(
                              args.sampler.data_source, shuffle=True
                          )
                          logger.debug(
                              "Replace paddle RandomSampler into fastNLP RandomSampler."
                          )
                          return replace_sampler(dataloader, sampler)
              elif type(args.sampler) is PaddleSequenialSampler:
                  # 需要替换为不要 shuffle 的。
                  sampler = RandomSampler(
                      args.sampler.data_source, shuffle=False
                  )
                  logger.debug(
                      "Replace paddle SequentialSampler into fastNLP RandomSampler."
                  )
                  return replace_sampler(dataloader, sampler)
          batch_sampler = ReproduceBatchSampler(
              batch_sampler=args.batch_sampler,
              batch_size=args.batch_size,
              drop_last=args.drop_last,
          )
          return replace_batch_sampler(dataloader, batch_sampler)
      else:
          return dataloader
  
imports: import os
  import contextlib
  from typing import Optional, Dict, Union, Callable, Tuple
  from .paddle_driver import PaddleDriver
  from .utils import replace_batch_sampler, replace_sampler
  from fastNLP.envs.imports import _NEED_IMPORT_PADDLE
  from fastNLP.envs.env import USER_CUDA_VISIBLE_DEVICES
  from fastNLP.core.utils import auto_param_call, get_paddle_gpu_str, get_paddle_device_id
  from fastNLP.core.utils.paddle_utils import _convert_data_device
  from fastNLP.core.utils.utils import _get_fun_msg
  from fastNLP.core.samplers import ReproducibleBatchSampler, ReproduceBatchSampler, ReproducibleSampler, RandomSampler, re_instantiate_sampler
  from fastNLP.core.log import logger
label_desc: Use image node_id 5 for calling the PaddleSingleDriver obj's underlying member method code with example usage: obj.set_dist_repro_dataloader(dataloader, dist, reproducible) and returns: replace_batch_sampler, replace_batch_sampler, replace_batch_sampler, dataloader, replace_sampler, replace_sampler, replace_sampler, replace_sampler