code: def multi_gpu_generate_rpn_on_dataset(
      weights_file,
      dataset_name,
      _proposal_file_ignored,
      num_images,
      output_dir,
  ):
      """Multi-gpu inference on a dataset."""
      # Retrieve the test_net binary path
      binary_dir = envu.get_runtime_dir()
      binary_ext = envu.get_py_bin_ext()
      binary = os.path.join(binary_dir, "test_net" + binary_ext)
      assert os.path.exists(binary), "Binary '{}' not found".format(
          binary
      )
  
      # Pass the target dataset via the command line
      opts = ["TEST.DATASETS", '("{}",)'.format(dataset_name)]
      opts += ["TEST.WEIGHTS", weights_file]
  
      # Run inference in parallel in subprocesses
      outputs = subprocess_utils.process_in_parallel(
          "rpn_proposals", num_images, binary, output_dir, opts
      )
  
      # Collate the results from each subprocess
      boxes, scores, ids = [], [], []
      for rpn_data in outputs:
          boxes += rpn_data["boxes"]
          scores += rpn_data["scores"]
          ids += rpn_data["ids"]
      rpn_file = os.path.join(output_dir, "rpn_proposals.pkl")
      cfg_yaml = yaml.dump(cfg)
      save_object(
          dict(boxes=boxes, scores=scores, ids=ids, cfg=cfg_yaml),
          rpn_file,
      )
      logger.info(
          "Wrote RPN proposals to {}".format(os.path.abspath(rpn_file))
      )
      return boxes, scores, ids, rpn_file
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import cv2
  import datetime
  import logging
  import numpy
  import os
  import yaml
  from caffe2.python import core
  from caffe2.python import workspace
  from detectron.core.config import cfg
  from detectron.datasets import task_evaluation
  from detectron.datasets.json_dataset import JsonDataset
  from detectron.modeling import model_builder
  from detectron.utils.io import save_object
  from detectron.utils.timer import Timer
  import detectron.utils.blob
  import detectron.utils.c2
  import detectron.utils.env
  import detectron.utils.net
  import detectron.utils.subprocess
label_desc: Use image node_id 2 for calling a global function with example usage: multi_gpu_generate_rpn_on_dataset(weights_file, dataset_name, _proposal_file_ignored, num_images, output_dir) and returns: boxes,  scores,  ids,  rpn_file