code: def test_metrics_print(self):
      with tempfile.TemporaryDirectory() as tempdir:
          # set up engine
          def _train_func(engine, batch):
              return [batch + 1.0]
  
          engine = Engine(_train_func)
  
          # set up dummy metric
          @engine.on(Events.EPOCH_COMPLETED)
          def _update_metric(engine):
              current_metric = engine.state.metrics.get("acc", 0.1)
              engine.state.metrics["acc"] = current_metric + 0.1
  
          # set up testing handler
          stats_handler = TensorBoardStatsHandler(
              log_dir=tempdir, iteration_log=False, epoch_log=True
          )
          stats_handler.attach(engine)
          engine.run(range(3), max_epochs=2)
          stats_handler.close()
          # check logging output
          self.assertTrue(len(glob.glob(tempdir)) > 0)
  
file_path: MONAI/tests/test_handler_tb_stats.py
imports: from __future__ import annotations
  import glob
  import tempfile
  import unittest
  from unittest.mock import MagicMock
  from ignite.engine import Engine, Events
  from parameterized import parameterized
  from monai.handlers import TensorBoardStatsHandler
  from monai.utils import optional_import
label_desc: Use image node_id 1 for calling the TestHandlerTBStats obj's underlying member method code with example usage: obj.test_metrics_print() and returns: list