class_docstr: This is a base class for all DP plugins. It sets up world size and rank, and provides data loader creation.
class_docstr_tok: ["This","is","a","base","class","for","all","DP","plugins",".","It","sets","up","world","size","and","rank",",","and","provides","data","loader","creation","."]
code: def __init__(self) -> None:
      super().__init__()
      assert (
          dist.is_initialized()
      ), "torch.distributed is not initialized, please use colossalai.launch to create the distributed environment"
      self.rank = dist.get_rank()
      self.world_size = dist.get_world_size()
  
file_path: ColossalAI/colossalai/booster/plugin/dp_plugin_base.py
imports: import random
  import numpy
  import torch
  import torch.distributed
  from torch.utils.data import DataLoader
  from torch.utils.data.distributed import DistributedSampler
  from .plugin_base import Plugin
label_desc: Use image node_id 1 to create a new DPPluginBase object from inherited base classes: Plugin with example: obj = DPPluginBase()