code: def update(self, labels, preds):
      if self.pred_idx >= 0 and self.label_idx >= 0:
          pred = preds[self.pred_idx]
          label = preds[self.label_idx]
      else:
          pred = preds[self.pred.index("rpn_cls_prob")]
          label = labels[self.label.index("rpn_label")]
          # label = preds[self.pred.index('rpn_label')]
  
      num_images = pred.shape[0]
      # print(pred.shape, label.shape, file=sys.stderr)
      # pred (b, c, p) or (b, c, h, w)
      pred_label = (
          mx.ndarray.argmax_channel(pred).asnumpy().astype("int32")
      )
      # pred_label = pred_label.reshape((pred_label.shape[0], -1))
      pred_label = pred_label.reshape(
          -1,
      )
      # label (b, p)
      label = (
          label.asnumpy()
          .astype("int32")
          .reshape(
              -1,
          )
      )
      # print(pred_label.shape, label.shape)
  
      # filter with keep_inds
      keep_inds = np.where(label != -1)[0]
      # print('in_metric acc', pred_label.shape, label.shape, len(keep_inds), file=sys.stderr)
      # print(keep_inds, file=sys.stderr)
      _pred_label = pred_label[keep_inds]
      _label = label[keep_inds]
      # print('in_metric2', pred_label.shape, label.shape, len(keep_inds), file=sys.stderr)
      if isinstance(self.name, str):
          self.sum_metric += np.sum(_pred_label.flat == _label.flat)
          self.num_inst += len(_pred_label.flat)
      else:
          self.sum_metric[0] += np.sum(_pred_label.flat == _label.flat)
          self.num_inst[0] += len(_pred_label.flat)
  
          keep_inds = np.where(label == 0)[0]
          _pred_label = pred_label[keep_inds]
          _label = label[keep_inds]
          self.sum_metric[1] += np.sum(_pred_label.flat == _label.flat)
          self.num_inst[1] += len(_pred_label.flat)
  
          keep_inds = np.where(label == 1)[0]
          _pred_label = pred_label[keep_inds]
          _label = label[keep_inds]
          a = np.sum(_pred_label.flat == _label.flat)
          b = len(_pred_label.flat)
          self.sum_metric[2] += a
          self.num_inst[2] += b
  
imports: from __future__ import print_function
  import sys
  import mxnet
  import numpy
  from rcnn.config import config
label_desc: Use image node_id 4 for calling the RPNAccMetric obj's underlying member method code with example usage: obj.update(labels, preds) without return types