code: def batch_image(b, max_images=64, rows=None, cols=None):
      """Turn a batch of images into a single image mosaic."""
      mb = min(b.shape[0], max_images)
      if rows is None:
          rows = int(np.ceil(np.sqrt(mb)))
          cols = rows
      diff = rows * cols - mb
      b = np.vstack(
          [b[:mb], np.zeros([diff, b.shape[1], b.shape[2], b.shape[3]])]
      )
      tmp = b.reshape(-1, cols * b.shape[1], b.shape[2], b.shape[3])
      img = np.hstack(tmp[i] for i in range(rows))
      return img
  
imports: import functools
  import importlib
  import os
  from magenta.models.latent_transfer import local_mnist
  import numpy
  from PIL import Image
  import tensorflow.compat.v1
label_desc: Use image node_id 8 for calling a global function with example usage: batch_image(b, max_images, rows, cols) and returns: img