code: def demo_mm_sampling_results(
      proposals_list,
      batch_gt_instances,
      batch_gt_instances_ignore=None,
      assigner_cfg=None,
      sampler_cfg=None,
      feats=None,
  ):
      """Create sample results that can be passed to BBoxHead.get_targets."""
      assert len(proposals_list) == len(batch_gt_instances)
      if batch_gt_instances_ignore is None:
          batch_gt_instances_ignore = [None for _ in batch_gt_instances]
      else:
          assert len(batch_gt_instances_ignore) == len(
              batch_gt_instances
          )
  
      default_assigner_cfg = dict(
          type="MaxIoUAssigner",
          pos_iou_thr=0.5,
          neg_iou_thr=0.5,
          min_pos_iou=0.5,
          ignore_iof_thr=-1,
      )
      assigner_cfg = (
          assigner_cfg
          if assigner_cfg is not None
          else default_assigner_cfg
      )
      default_sampler_cfg = dict(
          type="RandomSampler",
          num=512,
          pos_fraction=0.25,
          neg_pos_ub=-1,
          add_gt_as_proposals=True,
      )
      sampler_cfg = (
          sampler_cfg
          if sampler_cfg is not None
          else default_sampler_cfg
      )
      bbox_assigner = TASK_UTILS.build(assigner_cfg)
      bbox_sampler = TASK_UTILS.build(sampler_cfg)
  
      sampling_results = []
      for i in range(len(batch_gt_instances)):
          if feats is not None:
              feats = [lvl_feat[i][None] for lvl_feat in feats]
          # rename proposals.bboxes to proposals.priors
          proposals = proposals_list[i]
          proposals.priors = proposals.pop("bboxes")
  
          assign_result = bbox_assigner.assign(
              proposals,
              batch_gt_instances[i],
              batch_gt_instances_ignore[i],
          )
          sampling_result = bbox_sampler.sample(
              assign_result,
              proposals,
              batch_gt_instances[i],
              feats=feats,
          )
          sampling_results.append(sampling_result)
  
      return sampling_results
  
imports: import copy
  from os.path import dirname, exists, join
  import numpy
  import torch
  from mmengine.config import Config
  from mmengine.dataset import pseudo_collate
  from mmengine.structures import InstanceData, PixelData
  from mmdet.utils.util_random import ensure_rng
  from ..registry import TASK_UTILS
  from ..structures import DetDataSample, TrackDataSample
  from ..structures.bbox import HorizontalBoxes
label_desc: Use image node_id 9 for calling a global function with example usage: demo_mm_sampling_results(proposals_list, batch_gt_instances, batch_gt_instances_ignore, assigner_cfg, sampler_cfg, feats) and returns: sampling_results