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","."]
code: def __init__(
      self,
      iou_metrics: Sequence[str] = ["mIoU"],
      beta: int = 1,
      collect_device: str = "cpu",
      output_dir: Optional[str] = None,
      format_only: bool = False,
      backend_args: dict = None,
      prefix: Optional[str] = None,
  ) -> None:
      super().__init__(collect_device=collect_device, prefix=prefix)
  
      if isinstance(iou_metrics, str):
          iou_metrics = [iou_metrics]
      if not set(iou_metrics).issubset(
          set(["mIoU", "mDice", "mFscore"])
      ):
          raise KeyError(
              f"metrics {iou_metrics} is not supported. "
              f"Only supports mIoU/mDice/mFscore."
          )
      self.metrics = iou_metrics
      self.beta = beta
      self.output_dir = output_dir
      if self.output_dir and is_main_process():
          mkdir_or_exist(self.output_dir)
      self.format_only = format_only
      self.backend_args = backend_args
  
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 1 to create a new SemSegMetric object from inherited base classes: BaseMetric with example: obj = SemSegMetric(iou_metrics, beta, collect_device, output_dir, format_only, backend_args, prefix)