code: def _image3_animated_gif(tag, ims):
      PIL = require_module("PIL")
      from PIL.GifImagePlugin import Image as GIF
  
      # x=numpy.random.randint(0,256,[10,10,10],numpy.uint8)
      ims = [
          np.asarray((ims[i, :, :]).astype(np.uint8))
          for i in range(ims.shape[0])
      ]
      ims = [GIF.fromarray(im) for im in ims]
      img_str = b""
      for b_data in PIL.GifImagePlugin.getheader(ims[0])[0]:
          img_str += b_data
      img_str += (
          b"\x21\xFF\x0B\x4E\x45\x54\x53\x43\x41\x50"
          b"\x45\x32\x2E\x30\x03\x01\x00\x00\x00"
      )
      for i in ims:
          for b_data in PIL.GifImagePlugin.getdata(i):
              img_str += b_data
      img_str += b"\x3B"
      if IS_PYTHON2:
          img_str = str(img_str)
      summary_image_str = summary_pb2.Summary.Image(
          height=10,
          width=10,
          colorspace=1,
          encoded_image_string=img_str,
      )
      image_summary = summary_pb2.Summary.Value(
          tag=tag, image=summary_image_str
      )
      return [
          summary_pb2.Summary(value=[image_summary]).SerializeToString()
      ]
  
imports: from __future__ import absolute_import, print_function, unicode_literals
  import errno
  import importlib
  import logging
  import os
  import re
  import sys
  import warnings
  import nibabel
  import numpy
  import pandas
  import scipy.ndimage
  import tensorflow
  from tensorflow.core.framework import summary_pb2
  from niftynet.io.image_loader import load_image_obj
  from niftynet.utilities.niftynet_global_config import NiftyNetGlobalConfig
  from niftynet.utilities.util_import import require_module
label_desc: Use image node_id 23 for calling a global function with example usage: _image3_animated_gif(tag, ims) and returns: list