class_docstr: Metric that calculates the mean Dice metric for each class.
  
  See more: https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient
  
  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","Dice","metric","for","each","class",".","See","more",":","https",":","\/\/en.wikipedia.org\/wiki\/S","%","C3","%","B8rensen","%","E2","%","80","%","93Dice_coefficient","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: Update metric with batch of samples.
docstr_tok: ["Update","metric","with","batch","of","samples","."]
code: def update(self, output: Tuple[np.ndarray, np.ndarray]):
      """Update metric with batch of samples."""
      for pred, label in zip(output[0], output[1]):
          label_onehot, pred_onehot = format_segmentation_masks(
              label, pred, self.threshold
          )
          if self.average == "micro":
              tp, label, pred = segmentation_counts_micro(
                  label_onehot, pred_onehot
              )
              tp_count, label_count, pred_count = (
                  np.asarray([tp]),
                  np.asarray([label]),
                  np.asarray([pred]),
              )
          else:
              (
                  tp_count,
                  label_count,
                  pred_count,
              ) = segmentation_counts_per_class(
                  label_onehot, pred_onehot
              )
  
          dice = (2 * tp_count + self.smooth) / (
              label_count + pred_count + self.smooth
          )
  
          classes_ids = (
              [0] if self.average == "micro" else np.unique(label)
          )
          for class_id in [int(x) for x in classes_ids]:
              self._evals[class_id]["dice"] += dice[class_id]
              self._evals[class_id]["count"] += 1
  
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 3 for calling the MeanDice obj's underlying member method code with example usage: obj.update(output) without return types