class_docstr: mIoU evaluation metric.
  
  Args:
      iou_metrics (list[str] | str): Metrics to be calculated, the options
          includes 'mIoU', 'mDice' and 'mFscore'.
      beta (int): Determines the weight of recall in the combined score.
          Default: 1.
      collect_device (str): Device name used for collecting results from
          different ranks during distributed training. Must be 'cpu' or
          'gpu'. Defaults to 'cpu'.
      output_dir (str): The directory for output prediction. Defaults to
          None.
      format_only (bool): Only format result for results commit without
          perform evaluation. It is useful when you want to save the result
          to a specific format and submit it to the test server.
          Defaults to False.
      backend_args (dict, optional): Arguments to instantiate the
          corresponding backend. Defaults to None.
      prefix (str, optional): The prefix that will be added in the metric
          names to disambiguate homonymous metrics of different evaluators.
          If prefix is not provided in the argument, self.default_prefix
          will be used instead. Defaults to None.
class_docstr_tok: ["mIoU","evaluation","metric",".","Args",":","iou_metrics","(","list","[","str","]","|","str",")",":","Metrics","to","be","calculated",",","the","options","includes","'mIoU","'",",","'mDice","'","and","'mFscore","'",".","beta","(","int",")",":","Determines","the","weight","of","recall","in","the","combined","score",".","Default",":","1.","collect_device","(","str",")",":","Device","name","used","for","collecting","results","from","different","ranks","during","distributed","training",".","Must","be","'cpu","'","or","'gpu","'",".","Defaults","to","'cpu","'",".","output_dir","(","str",")",":","The","directory","for","output","prediction",".","Defaults","to","None",".","format_only","(","bool",")",":","Only","format","result","for","results","commit","without","perform","evaluation",".","It","is","useful","when","you","want","to","save","the","result","to","a","specific","format","and","submit","it","to","the","test","server",".","Defaults","to","False",".","backend_args","(","dict",",","optional",")",":","Arguments","to","instantiate","the","corresponding","backend",".","Defaults","to","None",".","prefix","(","str",",","optional",")",":","The","prefix","that","will","be","added","in","the","metric","names","to","disambiguate","homonymous","metrics","of","different","evaluators",".","If","prefix","is","not","provided","in","the","argument",",","self.default_prefix","will","be","used","instead",".","Defaults","to","None","."]
docstr: Parse semantic segmentation predictions.
  
  Args:
      pred_label (torch.tensor): Prediction segmentation map
          or predict result filename. The shape is (H, W).
      label (torch.tensor): Ground truth segmentation map
          or label filename. The shape is (H, W).
      num_classes (int): Number of categories.
  
  Returns:
      torch.Tensor: The intersection of prediction and ground truth
          histogram on all classes.
      torch.Tensor: The union of prediction and ground truth histogram on
          all classes.
      torch.Tensor: The prediction histogram on all classes.
      torch.Tensor: The ground truth histogram on all classes.
docstr_tok: ["Parse","semantic","segmentation","predictions",".","Args",":","pred_label","(","torch.tensor",")",":","Prediction","segmentation","map","or","predict","result","filename",".","The","shape","is","(","H",",","W",")",".","label","(","torch.tensor",")",":","Ground","truth","segmentation","map","or","label","filename",".","The","shape","is","(","H",",","W",")",".","num_classes","(","int",")",":","Number","of","categories",".","Returns",":","torch.Tensor",":","The","intersection","of","prediction","and","ground","truth","histogram","on","all","classes",".","torch.Tensor",":","The","union","of","prediction","and","ground","truth","histogram","on","all","classes",".","torch.Tensor",":","The","prediction","histogram","on","all","classes",".","torch.Tensor",":","The","ground","truth","histogram","on","all","classes","."]
code: def _compute_pred_stats(
      self,
      pred_label: torch.tensor,
      label: torch.tensor,
      num_classes: int,
      ignore_index: int,
  ):
      """Parse semantic segmentation predictions.
  
      Args:
          pred_label (torch.tensor): Prediction segmentation map
              or predict result filename. The shape is (H, W).
          label (torch.tensor): Ground truth segmentation map
              or label filename. The shape is (H, W).
          num_classes (int): Number of categories.
  
      Returns:
          torch.Tensor: The intersection of prediction and ground truth
              histogram on all classes.
          torch.Tensor: The union of prediction and ground truth histogram on
              all classes.
          torch.Tensor: The prediction histogram on all classes.
          torch.Tensor: The ground truth histogram on all classes.
      """
      assert pred_label.shape == label.shape
      mask = label != ignore_index
      label, pred_label = label[mask], pred_label[mask]
  
      intersect = pred_label[pred_label == label]
      area_intersect = torch.histc(
          intersect.float(),
          bins=num_classes,
          min=0,
          max=num_classes - 1,
      )
      area_pred_label = torch.histc(
          pred_label.float(),
          bins=num_classes,
          min=0,
          max=num_classes - 1,
      )
      area_label = torch.histc(
          label.float(), bins=num_classes, min=0, max=num_classes - 1
      )
      area_union = area_pred_label + area_label - area_intersect
      result = dict(
          area_intersect=area_intersect,
          area_union=area_union,
          area_pred_label=area_pred_label,
          area_label=area_label,
      )
      return result
  
imports: import os.path
  from collections import OrderedDict
  from typing import Dict, Optional, Sequence, Union
  import numpy
  import torch
  from mmcv import imwrite
  from mmengine.dist import is_main_process
  from mmengine.evaluator import BaseMetric
  from mmengine.logging import MMLogger, print_log
  from mmengine.utils import mkdir_or_exist
  from PIL import Image
  from mmdet.registry import METRICS
label_desc: Use image node_id 4 for calling the SemSegMetric obj's underlying member method code with example usage: obj._compute_pred_stats(pred_label, label, num_classes, ignore_index) and returns: result