code: def image3(
      name,
      tensor,
      max_out=3,
      collections=(tf.GraphKeys.SUMMARIES,),
      animation_axes=(1,),
      image_axes=(2, 3),
      other_indices=None,
  ):
      """
      Summary for higher dimensional images
  
      Parameters:
  
          name: string name for the summary
          tensor: tensor to summarize. Should be in the range 0..255.
              By default, assumes tensor is NDHWC, and animates (through D)
              HxW slices of the 1st channel.
          collections: list of strings collections to add the summary to
          animation_axes=[1],image_axes=[2,3]
  
      """
  
      if max_out == 1:
          suffix = "/image"
      else:
          suffix = "/image/{}"
      if other_indices is None:
          other_indices = {}
      axis_order = [0] + animation_axes + image_axes
      # slice tensor
      slicing = []
      for i in range(len(tensor.shape)):
          if i in axis_order:
              slicing.append(slice(None))
          else:
              other_ind = other_indices.get(i, 0)
              slicing.append(slice(other_ind, other_ind + 1))
      tensor = tensor[tuple(slicing)]
      axis_order_all = axis_order + [
          i
          for i in range(len(tensor.shape.as_list()))
          if i not in axis_order
      ]
      original_shape = tensor.shape.as_list()
      new_shape = [
          original_shape[0],
          -1,
          original_shape[axis_order[-2]],
          original_shape[axis_order[-1]],
      ]
      transposed_tensor = tf.transpose(tensor, axis_order_all)
      transposed_tensor = tf.reshape(transposed_tensor, new_shape)
      # split images
      with tf.device("/cpu:0"):
          for it_i in range(
              min(max_out, transposed_tensor.shape.as_list()[0])
          ):
              inp = [
                  name + suffix.format(it_i),
                  transposed_tensor[it_i, :, :, :],
              ]
              summary_op = tf.py_func(
                  _image3_animated_gif, inp, tf.string
              )
              for c in collections:
                  tf.add_to_collection(c, summary_op)
      return summary_op
  
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 24 for calling a global function with example usage: image3(name, tensor, max_out, collections, animation_axes, image_axes, other_indices) and returns: summary_op