code: def run_inference(
      weights_file,
      ind_range=None,
      multi_gpu_testing=False,
      gpu_id=0,
      check_expected_results=False,
  ):
      parent_func, child_func = get_eval_functions()
      is_parent = ind_range is None
  
      def result_getter():
          if is_parent:
              # Parent case:
              # In this case we're either running inference on the entire dataset in a
              # single process or (if multi_gpu_testing is True) using this process to
              # launch subprocesses that each run inference on a range of the dataset
              all_results = {}
              for i in range(len(cfg.TEST.DATASETS)):
                  dataset_name, proposal_file = get_inference_dataset(i)
                  output_dir = get_output_dir(
                      dataset_name, training=False
                  )
                  results = parent_func(
                      weights_file,
                      dataset_name,
                      proposal_file,
                      output_dir,
                      multi_gpu=multi_gpu_testing,
                  )
                  all_results.update(results)
  
              return all_results
          else:
              # Subprocess child case:
              # In this case test_net was called via subprocess.Popen to execute on a
              # range of inputs on a single dataset
              dataset_name, proposal_file = get_inference_dataset(
                  0, is_parent=False
              )
              output_dir = get_output_dir(dataset_name, training=False)
              return child_func(
                  weights_file,
                  dataset_name,
                  proposal_file,
                  output_dir,
                  ind_range=ind_range,
                  gpu_id=gpu_id,
              )
  
      all_results = result_getter()
      if check_expected_results and is_parent:
          task_evaluation.check_expected_results(
              all_results,
              atol=cfg.EXPECTED_RESULTS_ATOL,
              rtol=cfg.EXPECTED_RESULTS_RTOL,
          )
          task_evaluation.log_copy_paste_friendly_results(all_results)
  
      return all_results
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from collections import defaultdict
  import cv2
  import datetime
  import logging
  import numpy
  import os
  import yaml
  from caffe2.python import workspace
  from detectron.core.config import cfg
  from detectron.core.config import get_output_dir
  from detectron.core.rpn_generator import generate_rpn_on_dataset
  from detectron.core.rpn_generator import generate_rpn_on_range
  from detectron.core.test import im_detect_all
  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.c2
  import detectron.utils.env
  import detectron.utils.net
  import detectron.utils.subprocess
  import detectron.utils.vis
label_desc: Use image node_id 3 for calling a global function with example usage: run_inference(weights_file, ind_range, multi_gpu_testing, gpu_id, check_expected_results) and returns: all_results, all_results, child_func