class_docstr: Confusion Matrix for segmentation evaluation.
  
  Args:
      num_classes (int): Number of categories of the confusion matrix.
      streaming (bool): Whether to use streaming mode. If the value is set to True, the data will be
                        accumulated every time the `calculate` interface is called. Default to False.
code: def calculate(self, pred, label, ignore=None):
      # If not in streaming mode, clear matrix everytime when call `calculate`
      if not self.streaming:
          self.zero_matrix()
  
      mask = np.array(ignore) == 1
  
      label = np.asarray(label)[mask]
      pred = np.asarray(pred)[mask]
      one = np.ones_like(pred)
      # Accumuate ([row=label, col=pred], 1) into sparse matrix
      spm = csr_matrix(
          (one, (label, pred)),
          shape=(self.num_classes, self.num_classes),
      )
      spm = spm.todense()
      self.confusion_matrix += spm
  
imports: import os
  from typing import Callable, Union, List, Tuple
  import cv2
  import paddle
  import PIL
  import numpy
  import paddle.nn.functional
  from scipy.sparse import csr_matrix
label_desc: Use image node_id 2 for calling the ConfusionMatrix obj's underlying member method code with example usage: obj.calculate(pred, label, ignore) without return types