code: def add_animated_gif(
      writer: SummaryWriter | SummaryWriterX,
      tag: str,
      image_tensor: np.ndarray | torch.Tensor,
      max_out: int = 3,
      frame_dim: int = -3,
      scale_factor: float = 1.0,
      global_step: int | None = None,
  ) -> None:
      """Creates an animated gif out of an image tensor in 'CHWD' format and writes it with SummaryWriter.
  
      Args:
          writer: Tensorboard SummaryWriter to write to
          tag: Data identifier
          image_tensor: tensor for the image to add, expected to be in `CHWD` format
          max_out: maximum number of image channels to animate through
          frame_dim: the dimension used as frames for GIF image, expect input data shape as `CHWD`,
              default to `-3` (the first spatial dim)
          scale_factor: amount to multiply values by. If the image data is between 0 and 1, using 255 for this value will
              scale it to displayable range
          global_step: Global step value to record
      """
      summary = make_animated_gif_summary(
          tag=tag,
          image=image_tensor,
          writer=writer,
          max_out=max_out,
          frame_dim=frame_dim,
          scale_factor=scale_factor,
      )
      for s in summary:
          # add GIF for every channel separately
          writer._get_file_writer().add_summary(s, global_step)
  
file_path: MONAI/monai/visualize/img2tensorboard.py
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Any
  import numpy
  import torch
  from monai.config import NdarrayTensor
  from monai.transforms import rescale_array
  from monai.utils import convert_data_type, optional_import
label_desc: Use image node_id 3 for calling a global function with example usage: add_animated_gif(writer, tag, image_tensor, max_out, frame_dim, scale_factor, global_step) without return types