code: def test_compute(self, input_params, expected_avg, details_shape):
      dice_metric = MeanDice(**input_params)
  
      def _val_func(engine, batch):
          pass
  
      engine = Engine(_val_func)
      dice_metric.attach(engine=engine, name="mean_dice")
      # test input a list of channel-first tensor
      y_pred = [torch.Tensor([[0], [1]]), torch.Tensor([[1], [0]])]
      y = torch.Tensor([[[0], [1]], [[0], [1]]])
      engine.state.output = {"pred": y_pred, "label": y}
      engine.fire_event(Events.ITERATION_COMPLETED)
  
      y_pred = [torch.Tensor([[0], [1]]), torch.Tensor([[1], [0]])]
      y = torch.Tensor([[[0], [1]], [[1], [0]]])
      engine.state.output = {"pred": y_pred, "label": y}
      engine.fire_event(Events.ITERATION_COMPLETED)
  
      engine.fire_event(Events.EPOCH_COMPLETED)
      assert_allclose(
          engine.state.metrics["mean_dice"],
          expected_avg,
          atol=1e-4,
          rtol=1e-4,
          type_test=False,
      )
      self.assertTupleEqual(
          tuple(engine.state.metric_details["mean_dice"].shape),
          details_shape,
      )
  
file_path: MONAI/tests/test_handler_mean_dice.py
imports: from __future__ import annotations
  import unittest
  import torch
  from ignite.engine import Engine, Events
  from parameterized import parameterized
  from monai.handlers import MeanDice, from_engine
  from tests.utils import assert_allclose
label_desc: Use image node_id 1 for calling the TestHandlerMeanDice obj's underlying member method code with example usage: obj.test_compute(input_params, expected_avg, details_shape) without return types