Updates the internal evaluation result.

        Parameters
        ----------
        labels : list of `NDArray`
            The labels of the data with class indices as values, one per sample.
        preds : list of `NDArray`
            Prediction values for samples. Each prediction value can either be the class index,
            or a vector of likelihoods for all classes.
        masks : list of `NDArray` or None, optional
            Masks for samples, with the same shape as `labels`. value of its element must
            be either 1 or 0. If None, all samples are considered valid.

def update(self, labels, preds, masks=None):
        # pylint: disable=arguments-differ
        """Updates the internal evaluation result.

        Parameters
        ----------
        labels : list of `NDArray`
            The labels of the data with class indices as values, one per sample.
        preds : list of `NDArray`
            Prediction values for samples. Each prediction value can either be the class index,
            or a vector of likelihoods for all classes.
        masks : list of `NDArray` or None, optional
            Masks for samples, with the same shape as `labels`. value of its element must
            be either 1 or 0. If None, all samples are considered valid.
        """
        labels, preds = check_label_shapes(labels, preds, True)
        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:
                # TODO(haibin) topk does not support fp16. Issue tracked at:
                # https://github.com/apache/incubator-mxnet/issues/14125
                # topk is used because argmax is slow:
                # https://github.com/apache/incubator-mxnet/issues/11061
                pred_label = ndarray.topk(pred_label.astype('float32', copy=False),
                                          k=1, ret_typ='indices', axis=self.axis)

            # flatten before checking shapes to avoid shape miss match
            pred_label = pred_label.astype('int32', copy=False).reshape((-1,))
            label = label.astype('int32', copy=False).reshape((-1,))
            check_label_shapes(label, pred_label)

            if mask is not None:
                mask = mask.astype('int32', copy=False).reshape((-1,))
                check_label_shapes(label, mask)
                num_correct = ((pred_label == label) * mask).sum().asscalar()
                num_inst = mask.sum().asscalar()
            else:
                num_correct = (pred_label == label).sum().asscalar()
                num_inst = len(label)
            self.sum_metric += num_correct
            self.global_sum_metric += num_correct
            self.num_inst += num_inst
            self.global_num_inst += num_inst