class_docstr: DeepSpeed engine for training and inference.
class_docstr_tok: ["DeepSpeed","engine","for","training","and","inference","."]
code: def create_inference_module(self):
      self.layer_params = []
      self.layer_lora_params = []
      self.lora_params = []
      self.all_lora_params = []
  
      self._other_layers = []
      self._orig_modules_others = []
      self._orig_fwds_others = []
  
      if self._config.hybrid_engine.inference_tp_size > 1:
          if self.mpu is None:
              global_rank = dist.get_rank()
              world_size = dist.get_world_size()
              mp_group_id = (
                  global_rank
                  // self._config.hybrid_engine.inference_tp_size
              )
              num_mp_groups = (
                  world_size
                  // self._config.hybrid_engine.inference_tp_size
              )
              for mp_group_id in range(num_mp_groups):
                  ranks = list(
                      range(
                          mp_group_id
                          * self._config.hybrid_engine.inference_tp_size,
                          (mp_group_id + 1)
                          * self._config.hybrid_engine.inference_tp_size,
                          1,
                      )
                  )
                  mp_group = dist.new_group(ranks)
                  if global_rank in ranks:
                      # mp_group is used for broader collective
                      self.mp_group = mp_group
  
                      # mp_replace is used for container tensor slicing
                      from deepspeed.module_inject import (
                          ReplaceWithTensorSlicing,
                      )
  
                      self.mp_replace = ReplaceWithTensorSlicing(
                          mp_group=self.mp_group,
                          mp_size=self._config.hybrid_engine.inference_tp_size,
                          out_dim=0,
                          in_dim=1,
                      )
  
          else:
              self.mp_group = (
                  self.mpu.get_model_parallel_group()
                  if hasattr(self.mpu, "get_model_parallel_group")
                  else self.mpu.get_tensor_model_parallel_group()
              )
  
              from deepspeed.module_inject import (
                  ReplaceWithTensorSlicing,
              )
  
              self.mp_replace = ReplaceWithTensorSlicing(
                  mp_group=self.mp_group,
                  mp_size=self._config.hybrid_engine.inference_tp_size,
                  out_dim=0,
                  in_dim=1,
              )
      else:
          self.mp_group = None
          self.mp_replace = None
      self.populate_all_inference_policies()
      self.all_layers_params = list(self.module.parameters())
      self.create_inference_containers(self.module)
  
      if len(self._inference_containers) > 0:
          self._generate = self.module.generate
          self.module.generate = self.generate
  
      self._t0 = time.time()
  
imports: import torch
  from deepspeed.inference.config import DeepSpeedInferenceConfig
  from deepspeed.module_inject.replace_policy import replace_policies
  from deepspeed.module_inject.utils import policy_to_ds_container
  from .engine import DeepSpeedEngine
  from .utils import TLinear, get_inactive_params
  from deepspeed.runtime.zero import GatheredParameters
  import time
  import gc
  import math
  from deepspeed import comm
  from deepspeed.accelerator import get_accelerator
  from torch import nn
  from deepspeed.utils import logger
  from deepspeed.ops.op_builder import InferenceBuilder
  from deepspeed.module_inject.layers import LinearLayer, Normalize, EmbeddingLayer, OPTEmbedding
label_desc: Use image node_id 13 for calling the DeepSpeedHybridEngine obj's underlying member method code with example usage: obj.create_inference_module() without return types