class_docstr: Metric proposed by `Graph R-CNN for Scene Graph Generation`
code: def update(self, labels, preds):
      label_objects, label_triplets = labels
      pred_objects, pred_triplets = preds
      if label_objects is None or pred_objects is None:
          self.num_inst += 1
          return
      count = 0
      # count objects
      object_matched = [False for obj in label_objects]
      m = len(pred_objects)
      gt_obj_num = label_objects.shape[0]
      for i in range(m):
          pred = pred_objects[i]
          for j in range(gt_obj_num):
              if object_matched[j]:
                  continue
              label = label_objects[j]
              if int(label[0]) == int(pred[0]) and object_iou_thresh(
                  pred, label, self.iou_thresh
              ):
                  count += 1
                  object_matched[j] = True
  
      # count predicate and triplet
      pred_triplets = pred_triplets[pred_triplets[:, 1].argsort()[::-1]]
      m = min(self.topk, len(pred_triplets))
      gt_triplet_num = label_triplets.shape[0]
      triplet_matched = [False for label in label_triplets]
      predicate_matched = [False for label in label_triplets]
      for i in range(m):
          pred = pred_triplets[i]
          for j in range(gt_triplet_num):
              label = label_triplets[j]
              if not predicate_matched:
                  if int(label[2]) == int(
                      pred[2]
                  ) and triplet_iou_thresh(
                      pred, label, self.iou_thresh
                  ):
                      count += label[3]
                      predicate_matched[j] = True
              if not triplet_matched[j]:
                  if (
                      int(label[2]) == int(pred[2])
                      and int(label[3]) == int(pred[3])
                      and int(label[4]) == int(pred[4])
                      and triplet_iou_thresh(
                          pred, label, self.iou_thresh
                      )
                  ):
                      count += 1
                      triplet_matched[j] = True
      # compute sum
      total = labels.shape[0]
      N = gt_obj_num + 2 * total
      self.sum_metric += count / N
      self.num_inst += 1
  
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 2 for calling the SGDetPlus obj's underlying member method code with example usage: obj.update(labels, preds) without return types