class_docstr: 专属于 ``pytorch`` 的 ``driver``，是 ``TorchSingleDriver`` 和 ``TorchDDPDriver`` 的父类。
  
  .. warning::
  
      您不应当直接初始化该类，然后传入给 ``Trainer``，换句话说，您应当使用该类的子类 ``TorchSingleDriver`` 和 ``TorchDDPDriver``，而不是
      该类本身。
  
  .. note::
  
      您可以在使用 ``TorchSingleDriver`` 和 ``TorchDDPDriver`` 时使用 ``TorchDriver`` 提供的接口。
  
  :param model: 训练时使用的 **pytorch** 模型。
  :param fp16: 是否开启混合精度训练;
  :param torch_kwargs:
class_docstr_tok: ["\u4e13\u5c5e\u4e8e","``","pytorch","``","\u7684","``","driver","``","\uff0c\u662f","``","TorchSingleDriver","``","\u548c","``","TorchDDPDriver","``","\u7684\u7236\u7c7b\u3002","..","warning",":",":","\u60a8\u4e0d\u5e94\u5f53\u76f4\u63a5\u521d\u59cb\u5316\u8be5\u7c7b\uff0c\u7136\u540e\u4f20\u5165\u7ed9","``","Trainer","``","\uff0c\u6362\u53e5\u8bdd\u8bf4\uff0c\u60a8\u5e94\u5f53\u4f7f\u7528\u8be5\u7c7b\u7684\u5b50\u7c7b","``","TorchSingleDriver","``","\u548c","``","TorchDDPDriver","``","\uff0c\u800c\u4e0d\u662f","\u8be5\u7c7b\u672c\u8eab\u3002","..","note",":",":","\u60a8\u53ef\u4ee5\u5728\u4f7f\u7528","``","TorchSingleDriver","``","\u548c","``","TorchDDPDriver","``","\u65f6\u4f7f\u7528","``","TorchDriver","``","\u63d0\u4f9b\u7684\u63a5\u53e3\u3002",":","param","model",":","\u8bad\u7ec3\u65f6\u4f7f\u7528\u7684","*","*","pytorch","*","*","\u6a21\u578b\u3002",":","param","fp16",":","\u662f\u5426\u5f00\u542f\u6df7\u5408\u7cbe\u5ea6\u8bad\u7ec3",";",":","param","torch_kwargs",":"]
docstr: 将一个 ``batch`` 的数据迁移到对应的设备上
  
  :param batch: 包含 :class:`torch.Tensor` 的数据集合，可以是 **List**、**Dict** 等嵌套类型
  :return: 移动到指定机器后的 ``batch``
code: def move_data_to_device(self, batch):
      """
      将一个 ``batch`` 的数据迁移到对应的设备上
  
      :param batch: 包含 :class:`torch.Tensor` 的数据集合，可以是 **List**、**Dict** 等嵌套类型
      :return: 移动到指定机器后的 ``batch``
      """
      return torch_move_data_to_device(
          batch, self.data_device, self.non_blocking
      )
  
imports: import os
  from typing import Union, Dict, Optional, Callable
  from functools import partial
  import numpy
  import random
  from dataclasses import dataclass
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from pathlib import Path
  from .utils import optimizer_state_to_device
  from fastNLP.core.drivers.driver import Driver
  from fastNLP.core.drivers.torch_driver.utils import _build_fp16_env, DummyGradScaler
  from fastNLP.core.utils import apply_to_collection, torch_move_data_to_device
  from fastNLP.envs import rank_zero_call
  from fastNLP.envs import FASTNLP_GLOBAL_RANK, FASTNLP_MODEL_FILENAME, FASTNLP_CHECKPOINT_FILENAME
  from fastNLP.core.log import logger
  from fastNLP.core.samplers import ReproducibleBatchSampler, ReproducibleSampler, ReproduceBatchSampler, RandomSampler
  from fastNLP.core.dataloaders import OverfitDataLoader
label_desc: Use image node_id 20 for calling the TorchDriver obj's underlying member method code with example usage: obj.move_data_to_device(batch) and returns: torch_move_data_to_device