class_docstr: Only calculate the unknown region if trimap provided.
  Refer to: https://github.com/open-mlab/mmediting/blob/master/mmedit/core/evaluation/metrics.py
docstr: update metric.
  Args:
      pred (np.ndarray): The value range is [0., 1.].
      gt (np.ndarray): The value range is [0, 255].
      trimap (np.ndarray, optional)L The value is in {0, 128, 255}. Default: None.
      sigma (float, optional): Standard deviation of the gaussian kernel. Default: 1.4.
docstr_tok: ["update","metric",".","Args",":","pred","(","np.ndarray",")",":","The","value","range","is","[","0.",",","1.","]",".","gt","(","np.ndarray",")",":","The","value","range","is","[","0",",","255","]",".","trimap","(","np.ndarray",",","optional",")","L","The","value","is","in","{","0",",","128",",","255","}",".","Default",":","None",".","sigma","(","float",",","optional",")",":","Standard","deviation","of","the","gaussian","kernel",".","Default",":","1.4","."]
code: def update(self, pred, gt, trimap=None, sigma=1.4):
      """
      update metric.
      Args:
          pred (np.ndarray): The value range is [0., 1.].
          gt (np.ndarray): The value range is [0, 255].
          trimap (np.ndarray, optional)L The value is in {0, 128, 255}. Default: None.
          sigma (float, optional): Standard deviation of the gaussian kernel. Default: 1.4.
      """
      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
  
      gt = gt.squeeze()
      pred = pred.squeeze()
      gt = gt.astype(np.float64)
      pred = pred.astype(np.float64)
      gt_normed = np.zeros_like(gt)
      pred_normed = np.zeros_like(pred)
      cv2.normalize(gt, gt_normed, 1.0, 0.0, cv2.NORM_MINMAX)
      cv2.normalize(pred, pred_normed, 1.0, 0.0, cv2.NORM_MINMAX)
  
      gt_grad = self.gauss_gradient(gt_normed, sigma).astype(np.float32)
      pred_grad = self.gauss_gradient(pred_normed, sigma).astype(
          np.float32
      )
  
      grad_diff = ((gt_grad - pred_grad) ** 2 * (trimap == 128)).sum()
  
      grad_diff /= 1000
      self.grad_diffs += grad_diff
      self.count += 1
  
      return grad_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 6 for calling the Grad obj's underlying member method code with example usage: obj.update(pred, gt, trimap, sigma) and returns: grad_diff