class_docstr: Metric that calculates the mean IoU metric for each class.
  
  See more: https://en.wikipedia.org/wiki/Jaccard_index
  
  Parameters
  ----------
  threshold: float, default: 0.5
      prediction value per pixel above which the pixel is considered True.
  smooth: float, default: 1e-3
      smoothing factor to prevent division by zero when the mask is empty.
  average: str, default: none
      The method for averaging over the classes. If none, returns the result per class.
class_docstr_tok: ["Metric","that","calculates","the","mean","IoU","metric","for","each","class",".","See","more",":","https",":","\/\/en.wikipedia.org\/wiki\/Jaccard_index","Parameters","--","--","--","--","--","threshold",":","float",",","default",":","0.5","prediction","value","per","pixel","above","which","the","pixel","is","considered","True",".","smooth",":","float",",","default",":","1e-3","smoothing","factor","to","prevent","division","by","zero","when","the","mask","is","empty",".","average",":","str",",","default",":","none","The","method","for","averaging","over","the","classes",".","If","none",",","returns","the","result","per","class","."]
docstr: Compute metric value.
docstr_tok: ["Compute","metric","value","."]
code: def compute(self):
      """Compute metric value."""
      sorted_classes = [
          int(class_id) for class_id in sorted(self._evals.keys())
      ]
      max_class = max(sorted_classes)
      scores_per_class = np.empty(max_class + 1) * np.nan
      for class_id in sorted_classes:
          count = self._evals[class_id]["count"]
          iou = self._evals[class_id]["iou"]
          mean_iou = iou / count if count != 0 else 0
          scores_per_class[class_id] = mean_iou
      if self.average == "macro":
          scores_per_class = np.nanmean(scores_per_class)
      return scores_per_class
  
file_path: deepchecks/deepchecks/vision/metrics_utils/semantic_segmentation_metrics.py
imports: from collections import defaultdict
  from typing import Tuple
  import numpy
  import torch
  from ignite.metrics import Metric
  from deepchecks.core.errors import DeepchecksValueError
  from deepchecks.vision.metrics_utils.semantic_segmentation_metric_utils import format_segmentation_masks, segmentation_counts_micro, segmentation_counts_per_class
label_desc: Use image node_id 4 for calling the MeanIoU obj's underlying member method code with example usage: obj.compute() and returns: scores_per_class