code: def test_tb_image_shape(self, shape):
      with tempfile.TemporaryDirectory() as tempdir:
          # set up engine
          def _train_func(engine, batch):
              engine.state.batch = batch
              return [
                  {
                      "pred": np.random.randint(
                          0, 2, size=(10, 4, *shape)
                      )
                  }
              ]
  
          engine = Engine(_train_func)
          # set up testing handler
          stats_handler = TensorBoardImageHandler(
              log_dir=tempdir,
          )
          engine.add_event_handler(
              Events.ITERATION_COMPLETED, stats_handler
          )
  
          data = zip(
              [
                  {
                      "image": torch.as_tensor(
                          np.random.normal(size=(10, 4, *shape))
                      ),
                      "image_meta_dict": {
                          "filename_or_obj": "test_image1.nii.gz"
                      },
                      "label": np.random.randint(
                          0, 2, size=(10, 4, *shape)
                      ),
                  },
                  {
                      "image": torch.as_tensor(
                          np.random.normal(size=(10, 4, *shape))
                      ),
                      "image_meta_dict": {
                          "filename_or_obj": "test_image2.nii.gz"
                      },
                      "label": np.random.randint(
                          0, 2, size=(10, 4, *shape)
                      ),
                  },
              ]
          )
          engine.run(data, epoch_length=10, max_epochs=1)
          stats_handler.close()
  
          self.assertTrue(len(glob.glob(tempdir)) > 0)
  
file_path: MONAILabel/tests/unit/deepedit/test_deepedit_handler.py
imports: import glob
  import tempfile
  import unittest
  import numpy
  import torch
  from ignite.engine import Engine, Events
  from monai.utils import optional_import
  from parameterized import parameterized
  from monailabel.deepedit.handlers import TensorBoard2DImageHandler, TensorBoardImageHandler
label_desc: Use image node_id 1 for calling the TestHandlerTBImage obj's underlying member method code with example usage: obj.test_tb_image_shape(shape) and returns: list