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: This model will iterate over the parameters (as provided by the checkpoint engine) and
  use the container map built by ``build_container_map`` to populate the model
docstr_tok: ["This","model","will","iterate","over","the","parameters","(","as","provided","by","the","checkpoint","engine",")","and","use","the","container","map","built","by","``","build_container_map","``","to","populate","the","model"]
code: def populate_model_parameters(self) -> None:
      """
      This model will iterate over the parameters (as provided by the checkpoint engine) and
      use the container map built by ``build_container_map`` to populate the model
      """
  
      container_map = self.build_container_map()
  
      if self._checkpoint_engine is not None:
          for name, parameter in self._checkpoint_engine.parameters():
              container_map.map_param(name, parameter)
  
          buffer, metadata = flatten_inference_model(
              container_map.transformer_params,
              container_map.non_transformer_params,
              self.__class__.__name__,
          )
      else:
          buffer_path = make_param_filename(
              self._inf_checkpoint_path,
              self.model.tp_rank,
              self.model.tp_size,
          )
          metadata_path = make_metadata_filename(
              self._inf_checkpoint_path,
              self.model.tp_rank,
              self.model.tp_size,
          )
  
          buffer = torch.load(buffer_path)
          metadata = json.load(open(metadata_path, "r"))
          metadata = ModelMetadata.parse_raw(metadata)
  
          restore_inference_model(
              buffer,
              metadata,
              container_map.transformer_params,
              container_map.non_transformer_params,
          )
  
      container_map.validate()
  
      self.model.set_parameters(
          transformer=container_map.transformer_params,
          non_transformer=container_map.non_transformer_params,
          flattened_param_buffer=buffer,
          flattened_param_metadata=metadata,
      )
  
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 5 for calling the InferenceV2Policy obj's underlying member method code with example usage: obj.populate_model_parameters() without return types