class_docstr: DeepSpeed engine for training and inference.
class_docstr_tok: ["DeepSpeed","engine","for","training","and","inference","."]
code: def new_inference_container(self, orig_layer, policy_cls, layer_id):
      policy = policy_cls(orig_layer, inference=True)
  
      if self._config.fp16_enabled:
          inference_dtype = torch.float16
      elif self._config.bfloat16_enabled:
          inference_dtype = torch.bfloat16
      else:
          inference_dtype = torch.float32
  
      _container = policy_to_ds_container(
          policy=policy,
          config=DeepSpeedInferenceConfig(
              set_empty_params=True,
              dtype=inference_dtype,
              max_out_tokens=self._config.hybrid_engine.max_out_tokens,
              min_out_tokens=self._config.hybrid_engine.max_out_tokens,
              transposed_mode=True,
          ),
          model_config=self.module.config
          if hasattr(self.module, "config")
          else None,
          layer_id=layer_id,
          child=orig_layer,
      )
  
      if self.mpu is not None:
          if hasattr(self.mpu, "get_model_parallel_world_size"):
              _container.set_tensor_parallel_config(
                  self.mpu.get_model_parallel_world_size(),
                  self.mpu.get_model_parallel_group(),
              )
          else:
              _container.set_tensor_parallel_config(
                  self.mpu.get_tensor_model_parallel_world_size(),
                  self.mpu.get_tensor_model_parallel_group(),
              )
      else:
          _container.set_tensor_parallel_config(
              self._config.hybrid_engine.inference_tp_size,
              self.mp_group,
          )
      _container.initialize_tensors(enable_training=True)
      _container.create_ds_model_config()
      _container.create_module()
      _container.set_params_wo_copy(Z3_enabled=self.Z3_enabled)
      return _container
  
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 3 for calling the DeepSpeedHybridEngine obj's underlying member method code with example usage: obj.new_inference_container(orig_layer, policy_cls, layer_id) and returns: _container