code: def test_segmentation_metrics(segmentation_coco_visiondata_train):
      dice_per_class = MeanDice()
      dice_micro = MeanDice(average="micro")
      dice_macro = MeanDice(average="macro")
      iou_per_class = MeanIoU()
      iou_micro = MeanIoU(average="micro")
      iou_macro = MeanIoU(average="macro")
  
      for batch in segmentation_coco_visiondata_train:
          label = sequence_to_numpy(batch["labels"])
          prediction = sequence_to_numpy(batch["predictions"])
          dice_per_class.update((prediction, label))
          dice_micro.update((prediction, label))
          dice_macro.update((prediction, label))
          iou_per_class.update((prediction, label))
          iou_micro.update((prediction, label))
          iou_macro.update((prediction, label))
      assert_that(dice_per_class.compute()[0], close_to(0.973, 0.001))
      assert_that(dice_per_class.compute(), has_length(17))
      assert_that(dice_micro.compute(), close_to(0.951, 0.001))
      assert_that(dice_macro.compute(), close_to(0.649, 0.006))
      assert_that(iou_per_class.compute()[0], close_to(0.948, 0.001))
  
imports: from typing import Dict
  import numpy
  from hamcrest import assert_that, close_to, has_items, has_length
  from ignite.engine import Engine
  from ignite.metrics import Metric
  from numpy import nanmean
  from sklearn.metrics import jaccard_score, make_scorer
  from deepchecks.vision import VisionData
  from deepchecks.vision.metrics_utils import get_scorers_dict
  from deepchecks.vision.metrics_utils.detection_precision_recall import ObjectDetectionAveragePrecision
  from deepchecks.vision.metrics_utils.semantic_segmentation_metrics import MeanDice, MeanIoU, per_sample_dice
  from deepchecks.vision.vision_data.utils import sequence_to_numpy
label_desc: Use image node_id 7 for calling a global function with example usage: test_segmentation_metrics(segmentation_coco_visiondata_train) without return types