class_docstr: TensorBoardImageHandler is an Ignite Event handler that can visualize images, labels and outputs as 2D/3D images.
  2D output (shape in Batch, channel, H, W) will be shown as simple image using the first element in the batch,
  for 3D to ND output (shape in Batch, channel, H, W, D) input, each of ``self.max_channels`` number of images'
  last three dimensions will be shown as animated GIF along the last axis (typically Depth).
  
  It can be used for any Ignite Engine (trainer, validator and evaluator).
  User can easily add it to engine for any expected Event, for example: ``EPOCH_COMPLETED``,
  ``ITERATION_COMPLETED``. The expected data source is ignite's ``engine.state.batch`` and ``engine.state.output``.
  
  Default behavior:
      - Show y_pred as images (GIF for 3D) on TensorBoard when Event triggered,
      - Need to use ``batch_transform`` and ``output_transform`` to specify
        how many images to show and show which channel.
      - Expects ``batch_transform(engine.state.batch)`` to return data
        format: (image[N, channel, ...], label[N, channel, ...]).
      - Expects ``output_transform(engine.state.output)`` to return a torch
        tensor in format (y_pred[N, channel, ...], loss).
class_docstr_tok: ["TensorBoardImageHandler","is","an","Ignite","Event","handler","that","can","visualize","images",",","labels","and","outputs","as","2D\/3D","images",".","2D","output","(","shape","in","Batch",",","channel",",","H",",","W",")","will","be","shown","as","simple","image","using","the","first","element","in","the","batch",",","for","3D","to","ND","output","(","shape","in","Batch",",","channel",",","H",",","W",",","D",")","input",",","each","of","``","self.max_channels","``","number","of","images'","last","three","dimensions","will","be","shown","as","animated","GIF","along","the","last","axis","(","typically","Depth",")",".","It","can","be","used","for","any","Ignite","Engine","(","trainer",",","validator","and","evaluator",")",".","User","can","easily","add","it","to","engine","for","any","expected","Event",",","for","example",":","``","EPOCH_COMPLETED","``",",","``","ITERATION_COMPLETED","``",".","The","expected","data","source","is","ignite","'s","``","engine.state.batch","``","and","``","engine.state.output","``",".","Default","behavior",":","-","Show","y_pred","as","images","(","GIF","for","3D",")","on","TensorBoard","when","Event","triggered",",","-","Need","to","use","``","batch_transform","``","and","``","output_transform","``","to","specify","how","many","images","to","show","and","show","which","channel",".","-","Expects","``","batch_transform","(","engine.state.batch",")","``","to","return","data","format",":","(","image","[","N",",","channel",",","...","]",",","label","[","N",",","channel",",","...","]",")",".","-","Expects","``","output_transform","(","engine.state.output",")","``","to","return","a","torch","tensor","in","format","(","y_pred","[","N",",","channel",",","...","]",",","loss",")","."]
docstr: Close the summary writer if created in this TensorBoard handler.
docstr_tok: ["Close","the","summary","writer","if","created","in","this","TensorBoard","handler","."]
code: def close(self):
      """
      Close the summary writer if created in this TensorBoard handler.
  
      """
      if self.internal_writer:
          self._writer.close()
  
file_path: MONAILabel/monailabel/deepedit/handlers.py
imports: import logging
  from typing import TYPE_CHECKING, Any, Callable, Dict, Optional
  import numpy
  import torch
  from monai.config import IgniteInfo
  from monai.utils import min_version, optional_import
  from monai.visualize import plot_2d_or_3d_image
  from torch import distributed
  from torchvision.utils import make_grid
label_desc: Use image node_id 4 for calling the TensorBoardImageHandler obj's underlying member method code with example usage: obj.close() without return types