class_docstr: The InferenceV2Policy is the base class for all inference policies. An inference policy
  is responsible for instantiating the inference model and mapping the parameters from the
  checkpoint engine to the model itself.
class_docstr_tok: ["The","InferenceV2Policy","is","the","base","class","for","all","inference","policies",".","An","inference","policy","is","responsible","for","instantiating","the","inference","model","and","mapping","the","parameters","from","the","checkpoint","engine","to","the","model","itself","."]
docstr: Completely instantiate the inference model. This will both create the ops needed to run the
  model, as well as load the model parameters via the checkpoint engine. For more context
  on each of these components please see ``instantiate_model`` and ``populate_model_parameters``.
  
  Arguments:
      engine_config: The config that has been used to instantiate the engine. This is used
          to communicate to the model implementation the limits on batches (sequences/tokens)
          and bound the size of intermediate buffers.
      mp_group: Object to enable communication between tensor parallel ranks.
  
  Returns:
      DSInferenceModelBase: An implementation of the inference model abstraction that will be
          run by the engine.
docstr_tok: ["Completely","instantiate","the","inference","model",".","This","will","both","create","the","ops","needed","to","run","the","model",",","as","well","as","load","the","model","parameters","via","the","checkpoint","engine",".","For","more","context","on","each","of","these","components","please","see","``","instantiate_model","``","and","``","populate_model_parameters","``",".","Arguments",":","engine_config",":","The","config","that","has","been","used","to","instantiate","the","engine",".","This","is","used","to","communicate","to","the","model","implementation","the","limits","on","batches","(","sequences\/tokens",")","and","bound","the","size","of","intermediate","buffers",".","mp_group",":","Object","to","enable","communication","between","tensor","parallel","ranks",".","Returns",":","DSInferenceModelBase",":","An","implementation","of","the","inference","model","abstraction","that","will","be","run","by","the","engine","."]
code: def build_model(
      self, engine_config: RaggedInferenceEngineConfig, mp_group: Any
  ) -> DSInferenceModelBase:
      """
      Completely instantiate the inference model. This will both create the ops needed to run the
      model, as well as load the model parameters via the checkpoint engine. For more context
      on each of these components please see ``instantiate_model`` and ``populate_model_parameters``.
  
      Arguments:
          engine_config: The config that has been used to instantiate the engine. This is used
              to communicate to the model implementation the limits on batches (sequences/tokens)
              and bound the size of intermediate buffers.
          mp_group: Object to enable communication between tensor parallel ranks.
  
      Returns:
          DSInferenceModelBase: An implementation of the inference model abstraction that will be
              run by the engine.
      """
      self.model = self.instantiate_model(engine_config, mp_group)
      self.populate_model_parameters()
      return self.model
  
imports: import json
  from abc import ABC, ABCMeta, abstractmethod
  from typing import Any, Iterable, List, Optional, Union
  import torch
  from ..config_v2 import RaggedInferenceEngineConfig
  from ..checkpoint import CheckpointEngineBase
  from ..logging import inference_logger
  from .layer_container_base import LayerContainer
  from .inference_model_base import DSInferenceModelBase
  from .flat_model_helpers import flatten_inference_model, make_param_filename, make_metadata_filename, ModelMetadata, restore_inference_model
label_desc: Use image node_id 2 for calling the InferenceV2Policy obj's underlying member method code with example usage: obj.build_model(engine_config, mp_group) and returns: self