code: def update(self, labels, preds, masks=None):
      masks = [None] * len(labels) if masks is None else masks
      for label, pred_label, mask in zip(labels, preds, masks):
          if pred_label.shape != label.shape:
              # pred_label = pred_label.argmax(axis=self.axis)
              pred_label = mx.npx.topk(
                  pred_label.astype("float32", copy=False),
                  k=1,
                  ret_typ="indices",
                  axis=self.axis,
                  dtype=np.int32,
              )
          pred_label = pred_label.astype("int32").reshape((-1,))
          label = label.astype("int32").reshape((-1,))
          if mask is not None:
              mask = mask.astype("int32").reshape((-1,))
              num_correct = (
                  ((pred_label == label) * mask).sum().asnumpy().item()
              )
              self.sum_metric += num_correct
              self.num_inst += mask.sum().asnumpy().item()
          else:
              num_correct = (pred_label == label).sum().asnumpy().item()
              self.sum_metric += num_correct
              self.num_inst += len(pred_label)
  
imports: import time
  import os
  import sys
  import logging
  import random
  import numpy
  import mxnet
  from mxnet.gluon.metric import EvalMetric
  import gluonnlp.data.batchify
  from gluonnlp.utils.misc import glob
  from gluonnlp.data.loading import NumpyDataset, DatasetLoader
  from gluonnlp.data.sampler import SplitSampler, FixedBucketSampler
  from create_pretraining_data import create_training_instances
label_desc: Use image node_id 2 for calling the MaskedAccuracy obj's underlying member method code with example usage: obj.update(labels, preds, masks) without return types