class_docstr: Multi-class Dice Coefficient for Semantic Segmentation
  
  Calculates Dice Coefficient for semantic segmentation (multi-class tasks).
  
  Heaviliy inspired by fastai's implementation:  Implement multi-class version following https://github.com/fastai/fastai/blob/594e1cc20068b0d99bfc30bfe6dac88ab381a157/fastai/metrics.py#L343
  
  # Arguments
      classes_to_exclude: A list of class names to exclude from metric computation
code: def accumulate(self, preds):
      pred = np.stack(
          [x.pred.segmentation.mask_array.data for x in preds]
      ).flatten()
  
      target = self._seg_masks_gt = np.stack(
          [x.ground_truth.segmentation.mask_array.data for x in preds]
      ).flatten()
  
      unique_classes_id = list(
          preds[0].segmentation.class_map._class2id.values()
      )
  
      for c in self.classes_to_exclude:
          if c in preds[0].segmentation.class_map._class2id:
              unique_classes_id.remove(
                  preds[0].segmentation.class_map._class2id[c]
              )
  
      # We iterate through all unique classes across preditions and targets
      for c in unique_classes_id:
          p = np.where(pred == c, 1, 0)
          t = np.where(target == c, 1, 0)
  
          c_inter = np.logical_and(p, t).sum()
          c_union = p.sum() + t.sum()
  
          if c in self._intersection:
              self._intersection[c] += c_inter
              self._union[c] += c_union
          else:
              self._intersection[c] = c_inter
              self._union[c] = c_union
  
file_path: icevision/icevision/metrics/dice_coefficient/multiclass_dice_coefficient.py
imports: from icevision.imports import *
  from icevision.utils import *
  from icevision.data import *
  from icevision.metrics.metric import *
label_desc: Use image node_id 3 for calling the MulticlassDiceCoefficient obj's underlying member method code with example usage: obj.accumulate(preds) without return types