code: def test_compute_seg(self, input_params, expected_avg):
      metric = ConfusionMatrix(**input_params)
  
      def _val_func(engine, batch):
          pass
  
      engine = Engine(_val_func)
      metric.attach(engine, "confusion_matrix")
  
      y_pred = data_1["y_pred"]
      y = data_1["y"]
      metric.update([y_pred, y])
  
      y_pred = data_2["y_pred"]
      y = data_2["y"]
      metric.update([y_pred, y])
  
      avg_metric = metric.compute()
      self.assertAlmostEqual(avg_metric, expected_avg, places=4)
  
file_path: MONAI/tests/test_handler_confusion_matrix.py
imports: from __future__ import annotations
  import unittest
  from typing import Any
  import torch
  from ignite.engine import Engine
  from parameterized import parameterized
  from monai.handlers import ConfusionMatrix
  from tests.utils import assert_allclose
label_desc: Use image node_id 2 for calling the TestHandlerConfusionMatrix obj's underlying member method code with example usage: obj.test_compute_seg(input_params, expected_avg) without return types