class_docstr: 该函数用于 DDP 训练时处理用户自己定制的 train_step 等函数；
  之所以要使用这一额外的包裹模型，是因为在使用 DDP 时，必须使用 DistributedDataParallel 的 forward 函数才能实现正常的运行；
  另一方面，我们要求用户在使用我们的框架时，需要针对不用的模式实现不同的处理函数，例如 'train_step', 'evaluate_step' 等；
  然而，当使用 DistributedDataParallel 包裹 model 后，模型看不见其除了 forward 之外的方法；并且当我们尝试在训练过程中主动提取
  `model = model.module`，这同样会导致错误，会使得每一个gpu上的模型参数不同；
  
  因此出于以上考虑，我们实现了这一函数；
  对于更详细的解释，可以参考 'pytorch_lightning' 的 ddp 的设计；
class_docstr_tok: ["\u8be5\u51fd\u6570\u7528\u4e8e","DDP","\u8bad\u7ec3\u65f6\u5904\u7406\u7528\u6237\u81ea\u5df1\u5b9a\u5236\u7684","train_step","\u7b49\u51fd\u6570\uff1b","\u4e4b\u6240\u4ee5\u8981\u4f7f\u7528\u8fd9\u4e00\u989d\u5916\u7684\u5305\u88f9\u6a21\u578b\uff0c\u662f\u56e0\u4e3a\u5728\u4f7f\u7528","DDP","\u65f6\uff0c\u5fc5\u987b\u4f7f\u7528","DistributedDataParallel","\u7684","forward","\u51fd\u6570\u624d\u80fd\u5b9e\u73b0\u6b63\u5e38\u7684\u8fd0\u884c\uff1b","\u53e6\u4e00\u65b9\u9762\uff0c\u6211\u4eec\u8981\u6c42\u7528\u6237\u5728\u4f7f\u7528\u6211\u4eec\u7684\u6846\u67b6\u65f6\uff0c\u9700\u8981\u9488\u5bf9\u4e0d\u7528\u7684\u6a21\u5f0f\u5b9e\u73b0\u4e0d\u540c\u7684\u5904\u7406\u51fd\u6570\uff0c\u4f8b\u5982","'train_step","'",",","'evaluate_step","'","\u7b49\uff1b","\u7136\u800c\uff0c\u5f53\u4f7f\u7528","DistributedDataParallel","\u5305\u88f9","model","\u540e\uff0c\u6a21\u578b\u770b\u4e0d\u89c1\u5176\u9664\u4e86","forward","\u4e4b\u5916\u7684\u65b9\u6cd5\uff1b\u5e76\u4e14\u5f53\u6211\u4eec\u5c1d\u8bd5\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u4e3b\u52a8\u63d0\u53d6","`","model","=","model.module","`","\uff0c\u8fd9\u540c\u6837\u4f1a\u5bfc\u81f4\u9519\u8bef\uff0c\u4f1a\u4f7f\u5f97\u6bcf\u4e00\u4e2agpu\u4e0a\u7684\u6a21\u578b\u53c2\u6570\u4e0d\u540c\uff1b","\u56e0\u6b64\u51fa\u4e8e\u4ee5\u4e0a\u8003\u8651\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86\u8fd9\u4e00\u51fd\u6570\uff1b","\u5bf9\u4e8e\u66f4\u8be6\u7ec6\u7684\u89e3\u91ca\uff0c\u53ef\u4ee5\u53c2\u8003","'pytorch_lightning","'","\u7684","ddp","\u7684\u8bbe\u8ba1\uff1b"]
code: def __init__(self, model: Module):
      super(_DDPWrappingModel, self).__init__()
      self.model = model
  
imports: import os
  from typing import Any, Dict, Optional
  from enum import IntEnum
  import contextlib
  import random
  import numpy
  import inspect
  from fastNLP.envs.imports import _NEED_IMPORT_ONEFLOW
  from fastNLP.envs.utils import get_global_seed
  from fastNLP.envs import get_global_rank, FASTNLP_BACKEND_LAUNCH, FASTNLP_GLOBAL_SEED
  from fastNLP.core.samplers import ReproducibleBatchSampler
  from fastNLP.core.utils import auto_param_call
  from fastNLP.core.log import logger
label_desc: Use image node_id 1 to create a new _DDPWrappingModel object from inherited base classes: Module with example: obj = _DDPWrappingModel(model)