code: def _process_feature_extraction(output, im_scales, feat_name="fc6"):
      batch_size = len(output[0]["proposals"])
      n_boxes_per_image = [len(_) for _ in output[0]["proposals"]]
      score_list = output[0]["scores"].split(n_boxes_per_image)
      score_list = [
          torch.nn.functional.softmax(x, -1) for x in score_list
      ]
      feats = output[0][feat_name].split(n_boxes_per_image)
      cur_device = score_list[0].device
  
      feat_list = []
      bbox_list = []
  
      for i in range(batch_size):
          dets = output[0]["proposals"][i].bbox / im_scales[i]
          scores = score_list[i]
  
          max_conf = torch.zeros(scores.shape[0]).to(cur_device)
  
          for cls_ind in range(1, scores.shape[1]):
              cls_scores = scores[:, cls_ind]
              keep = nms(dets, cls_scores, 0.5)
              max_conf[keep] = torch.where(
                  cls_scores[keep] > max_conf[keep],
                  cls_scores[keep],
                  max_conf[keep],
              )
  
          keep_boxes = torch.argsort(max_conf, descending=True)[:100]
          feat_list.append(feats[i][keep_boxes])
          bbox_list.append(output[0]["proposals"][i].bbox[keep_boxes])
      return feat_list, bbox_list
  
file_path: mmf/mmf/projects/m4c/scripts/extract_ocr_frcn_feature.py
imports: import argparse
  import os
  import sys
  import cv2
  import numpy
  import torch
  import tqdm
  from maskrcnn_benchmark.config import cfg
  from maskrcnn_benchmark.layers import nms
  from maskrcnn_benchmark.modeling.detector import build_detection_model
  from maskrcnn_benchmark.structures.image_list import to_image_list
  from maskrcnn_benchmark.utils.model_serialization import load_state_dict
  from PIL import Image
label_desc: Use image node_id 3 for calling a global function with example usage: _process_feature_extraction(output, im_scales, feat_name) and returns: feat_list,  bbox_list