code: def calculate_metrics(
      metrics: Dict[str, Metric], dataset: VisionData
  ) -> Dict[str, float]:
      """Calculate a list of ignite metrics on a given model and dataset.
  
      Returns
      -------
      t.Dict[str, float]
          Dictionary of metrics with the metric name as key and the metric value as value
      """
  
      def process_function(_, batch):
          return sequence_to_numpy(
              batch["predictions"]
          ), sequence_to_numpy(batch["labels"])
  
      engine = Engine(process_function)
      for name, metric in metrics.items():
          metric.reset()
          metric.attach(engine, name)
  
      state = engine.run(dataset.batch_loader)
      return state.metrics
  
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 1 for calling a global function with example usage: calculate_metrics(metrics, dataset) and returns: state, sequence_to_numpy,  sequence_to_numpy