code: def auc_roc(logits, label, num_classes, ignore_index=None):
      """
      Calculate area under the roc curve
  
      Args:
          logits (Tensor): The prediction by model on testset, of shape (N,C,H,W) .
          label (Tensor): The ground truth of image.   (N,1,H,W)
          num_classes (int): The unique number of target classes.
          ignore_index (int): Specifies a target value that is ignored. Default: 255.
  
      Returns:
          auc_roc(float): The area under roc curve
      """
      if ignore_index or len(np.unique(label)) > num_classes:
          raise RuntimeError(
              "labels with ignore_index is not supported yet."
          )
  
      if len(label.shape) != 4:
          raise ValueError(
              "The shape of label is not 4 dimension as (N, C, H, W), it is {}".format(
                  label.shape
              )
          )
  
      if len(logits.shape) != 4:
          raise ValueError(
              "The shape of logits is not 4 dimension as (N, C, H, W), it is {}".format(
                  logits.shape
              )
          )
  
      N, C, H, W = logits.shape
      logits = np.transpose(logits, (1, 0, 2, 3))
      logits = logits.reshape([C, N * H * W]).transpose([1, 0])
  
      label = np.transpose(label, (1, 0, 2, 3))
      label = label.reshape([1, N * H * W]).squeeze()
  
      if not logits.shape[0] == label.shape[0]:
          raise ValueError(
              "length of `logit` and `label` should be equal, "
              "but they are {} and {}.".format(
                  logits.shape[0], label.shape[0]
              )
          )
  
      if num_classes == 2:
          auc = skmetrics.roc_auc_score(label, logits[:, 1])
      else:
          auc = skmetrics.roc_auc_score(
              label, logits, multi_class="ovr"
          )
  
      return auc
  
file_path: PaddleSeg/paddleseg/utils/metrics.py
imports: import numpy
  import paddle
  import paddle.nn.functional
  import sklearn.metrics
label_desc: Use image node_id 2 for calling a global function with example usage: auc_roc(logits, label, num_classes, ignore_index) and returns: auc