code: def test_metric_logging(self):
      dummy_name = "dummy"
  
      # set up engine
      def _train_func(engine, batch):
          return torch.tensor(0.0)
  
      engine = Engine(_train_func)
  
      # set up dummy metric
      @engine.on(Events.EPOCH_COMPLETED)
      def _update_metric(engine):
          engine.state.metrics[dummy_name] = 1
  
      # set up testing handler
      handler = MetricLogger(
          loss_transform=lambda output: output.item()
      )
      handler.attach(engine)
  
      engine.run(range(3), max_epochs=2)
  
      expected_loss = [
          (1, 0.0),
          (2, 0.0),
          (3, 0.0),
          (4, 0.0),
          (5, 0.0),
          (6, 0.0),
      ]
      expected_metric = [(4, 1), (5, 1), (6, 1)]
  
      self.assertSetEqual({dummy_name}, set(handler.metrics))
  
      self.assertListEqual(expected_loss, handler.loss)
      self.assertListEqual(expected_metric, handler.metrics[dummy_name])
  
file_path: MONAI/tests/test_handler_metric_logger.py
imports: from __future__ import annotations
  import unittest
  import torch
  from monai.utils import optional_import
  from tests.utils import SkipIfNoModule
label_desc: Use image node_id 1 for calling the TestHandlerMetricLogger obj's underlying member method code with example usage: obj.test_metric_logging() and returns: torch