docstr: Create the Inference V2 engine.
  
  Arguments:
      policy (InferenceV2Policy): Policy for the model implementation. This policy object
          will be used to build the model and load the checkpoint associated with it.
      engine_config (RaggedInferenceEngineConfig): Configuration for the inference engine.
docstr_tok: ["Create","the","Inference","V2","engine",".","Arguments",":","policy","(","InferenceV2Policy",")",":","Policy","for","the","model","implementation",".","This","policy","object","will","be","used","to","build","the","model","and","load","the","checkpoint","associated","with","it",".","engine_config","(","RaggedInferenceEngineConfig",")",":","Configuration","for","the","inference","engine","."]
code: def __init__(
      self,
      policy: InferenceV2Policy,
      engine_config: RaggedInferenceEngineConfig,
  ) -> None:
      """
      Create the Inference V2 engine.
  
      Arguments:
          policy (InferenceV2Policy): Policy for the model implementation. This policy object
              will be used to build the model and load the checkpoint associated with it.
          engine_config (RaggedInferenceEngineConfig): Configuration for the inference engine.
      """
      self._config = engine_config
      self._policy = policy
      self._base_mp_group = self._initialize_tp_group()
  
      # Build model from policy
      inference_logger().info("Building model...")
      self._model = self._policy.build_model(
          self._config, self._base_mp_group
      )
      inference_logger().info("Model built.")
  
      # Create state manager
      self._batch = RaggedBatchWrapper(self._config.state_manager)
      self._state_manager = DSStateManager(
          self._config.state_manager,
          self._model.kv_cache_config(),
          base_mp_group=self._base_mp_group,
      )
      self._model.set_state_manager(self._state_manager)
  
imports: import os
  import json
  import pickle
  from typing import Iterable, Tuple
  import torch
  import deepspeed.comm
  from deepspeed.accelerator import get_accelerator
  from deepspeed.comm.comm import init_distributed
  from .model_implementations import InferenceV2Policy
  from .logging import inference_logger
  from .ragged import DSStateManager, RaggedBatchWrapper, PlaceholderSequenceDescriptor
  from .scheduling_utils import SchedulingError, SchedulingResult
  from .model_implementations.flat_model_helpers import make_param_filename, make_metadata_filename
  from .model_implementations.inference_model_base import DSInferenceModelBase
  from .config_v2 import RaggedInferenceEngineConfig
label_desc: Use image node_id 4 to create a new InferenceEngineV2 object  with example: obj = InferenceEngineV2(policy, engine_config)