code: def test_compute(self, input_params, expected_avg):
      metric = ConfusionMatrix(**input_params)
      # test input a list of channel-first tensor
      y_pred = [torch.Tensor([[0], [1]]), torch.Tensor([[1], [0]])]
      y = [torch.Tensor([[0], [1]]), torch.Tensor([[0], [1]])]
      metric.update([y_pred, y])
  
      y_pred = torch.Tensor([[[0], [1]], [[1], [0]]])
      y = torch.Tensor([[[0], [1]], [[1], [0]]])
      metric.update([y_pred, y])
  
      avg_metric = metric.compute()
      assert_allclose(
          avg_metric,
          expected_avg,
          atol=1e-4,
          rtol=1e-4,
          type_test=False,
      )
  
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 1 for calling the TestHandlerConfusionMatrix obj's underlying member method code with example usage: obj.test_compute(input_params, expected_avg) without return types