code: def generate_rpn_on_dataset(
      weights_file,
      dataset_name,
      _proposal_file_ignored,
      output_dir,
      multi_gpu=False,
      gpu_id=0,
  ):
      """Run inference on a dataset."""
      dataset = JsonDataset(dataset_name)
      test_timer = Timer()
      test_timer.tic()
      if multi_gpu:
          num_images = len(dataset.get_roidb())
          (
              _boxes,
              _scores,
              _ids,
              rpn_file,
          ) = multi_gpu_generate_rpn_on_dataset(
              weights_file,
              dataset_name,
              _proposal_file_ignored,
              num_images,
              output_dir,
          )
      else:
          # Processes entire dataset range by default
          _boxes, _scores, _ids, rpn_file = generate_rpn_on_range(
              weights_file,
              dataset_name,
              _proposal_file_ignored,
              output_dir,
              gpu_id=gpu_id,
          )
      test_timer.toc()
      logger.info(
          "Total inference time: {:.3f}s".format(
              test_timer.average_time
          )
      )
      return evaluate_proposal_file(dataset, rpn_file, output_dir)
  
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 1 for calling a global function with example usage: generate_rpn_on_dataset(weights_file, dataset_name, _proposal_file_ignored, output_dir, multi_gpu, gpu_id) and returns: evaluate_proposal_file