code: def make_animated_gif_summary(
      tag: str,
      image: np.ndarray | torch.Tensor,
      writer: SummaryWriter | SummaryWriterX | None = None,
      max_out: int = 3,
      frame_dim: int = -3,
      scale_factor: float = 1.0,
  ) -> Summary:
      """Creates an animated gif out of an image tensor in 'CHWD' format and returns Summary.
  
      Args:
          tag: Data identifier
          image: The image, expected to be in `CHWD` format
          writer: the tensorboard writer to plot image
          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
      """
  
      suffix = "/image" if max_out == 1 else "/image/{}"
      # GIF image has no channel dim, reduce the spatial dim index if positive
      frame_dim = frame_dim - 1 if frame_dim > 0 else frame_dim
  
      summary_op = []
      for it_i in range(min(max_out, list(image.shape)[0])):
          one_channel_img: torch.Tensor | np.ndarray = (
              image[it_i, :, :, :].squeeze(dim=0)
              if isinstance(image, torch.Tensor)
              else image[it_i, :, :, :]
          )
          summary_op.append(
              _image3_animated_gif(
                  tag + suffix.format(it_i),
                  one_channel_img,
                  writer,
                  frame_dim,
                  scale_factor,
              )
          )
      return summary_op
  
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 2 for calling a global function with example usage: make_animated_gif_summary(tag, image, writer, max_out, frame_dim, scale_factor) and returns: summary_op