code: def extract_gt(g, img_size):
      """extract prediction from ground truth graph"""
      if g is None or g.number_of_nodes() == 0:
          return None, None
      gt_eids = np.where(g.edata["rel_class"].asnumpy() > 0)[0]
      if len(gt_eids) == 0:
          return None, None
  
      gt_class = g.ndata["node_class"][:, 0].asnumpy()
      gt_bbox = g.ndata["bbox"].asnumpy()
      gt_bbox[:, 0] /= img_size[1]
      gt_bbox[:, 1] /= img_size[0]
      gt_bbox[:, 2] /= img_size[1]
      gt_bbox[:, 3] /= img_size[0]
  
      gt_objects = np.vstack(
          [gt_class, gt_bbox.transpose(1, 0)]
      ).transpose(1, 0)
  
      gt_node_ids = g.find_edges(gt_eids)
      gt_node_sub = gt_node_ids[0].asnumpy()
      gt_node_ob = gt_node_ids[1].asnumpy()
      gt_rel_class = g.edata["rel_class"][gt_eids, 0].asnumpy() - 1
      gt_sub_class = gt_class[gt_node_sub]
      gt_ob_class = gt_class[gt_node_ob]
  
      gt_sub_bbox = gt_bbox[gt_node_sub]
      gt_ob_bbox = gt_bbox[gt_node_ob]
  
      n = len(gt_eids)
      gt_triplets = np.vstack(
          [
              np.ones(n),
              np.ones(n),
              gt_rel_class,
              gt_sub_class,
              gt_ob_class,
              gt_sub_bbox.transpose(1, 0),
              gt_ob_bbox.transpose(1, 0),
          ]
      ).transpose(1, 0)
      return gt_objects, gt_triplets
  
imports: import logging
  import time
  from operator import attrgetter, itemgetter
  import dgl
  import mxnet
  import numpy
  from dgl.nn.mxnet import GraphConv
  from dgl.utils import toindex
  from gluoncv.data.batchify import Pad
  from gluoncv.model_zoo import get_model
  from mxnet import gluon, nd
  from mxnet.gluon import nn
label_desc: Use image node_id 4 for calling a global function with example usage: extract_gt(g, img_size) and returns: gt_objects,  gt_triplets, None,  None, None,  None