class_docstr: Only calculate the unknown region if trimap provided.
docstr: update metric.
  Args:
      pred (np.ndarray): The value range is [0., 255.].
      gt (np.ndarray): The value range is [0, 255].
      trimap (np.ndarray, optional) The value is in {0, 128, 255}. Default: None.
docstr_tok: ["update","metric",".","Args",":","pred","(","np.ndarray",")",":","The","value","range","is","[","0.",",","255.","]",".","gt","(","np.ndarray",")",":","The","value","range","is","[","0",",","255","]",".","trimap","(","np.ndarray",",","optional",")","The","value","is","in","{","0",",","128",",","255","}",".","Default",":","None","."]
code: def update(self, pred, gt, trimap=None):
      """
      update metric.
      Args:
          pred (np.ndarray): The value range is [0., 255.].
          gt (np.ndarray): The value range is [0, 255].
          trimap (np.ndarray, optional) The value is in {0, 128, 255}. Default: None.
      """
      if trimap is None:
          trimap = np.ones_like(gt) * 128
      if not (pred.shape == gt.shape == trimap.shape):
          raise ValueError(
              "The shape of `pred`, `gt` and `trimap` should be equal. "
              "but they are {}, {} and {}".format(
                  pred.shape, gt.shape, trimap.shape
              )
          )
      pred[trimap == 0] = 0
      pred[trimap == 255] = 255
  
      mask = trimap == 128
      pixels = float(mask.sum())
      pred = pred / 255.0
      gt = gt / 255.0
      diff = (pred - gt) * mask
      mse_diff = (diff**2).sum() / pixels if pixels > 0 else 0
  
      self.mse_diffs += mse_diff
      self.count += 1
  
      return mse_diff
  
imports: import cv2
  import numpy
  from scipy.ndimage.filters import convolve
  from scipy.special import gamma
  from skimage.measure import label
label_desc: Use image node_id 2 for calling the MSE obj's underlying member method code with example usage: obj.update(pred, gt, trimap) and returns: mse_diff