def save_images(images, size, image_path='<STR_LIT>'):
if len(images.shape) == <NUM_LIT:3>:  <EOL><INDENT>images = images[:, :, :, np.newaxis]<EOL><DEDENT>def merge(images, size):<EOL><INDENT>h, w = images.shape[<NUM_LIT:1>], images.shape[<NUM_LIT:2>]<EOL>img = np.zeros((h * size[<NUM_LIT:0>], w * size[<NUM_LIT:1>], <NUM_LIT:3>), dtype=images.dtype)<EOL>for idx, image in enumerate(images):<EOL><INDENT>i = idx % size[<NUM_LIT:1>]<EOL>j = idx // size[<NUM_LIT:1>]<EOL>img[j * h:j * h + h, i * w:i * w + w, :] = image<EOL><DEDENT>return img<EOL><DEDENT>def imsave(images, size, path):<EOL><INDENT>if np.max(images) <= <NUM_LIT:1> and (-<NUM_LIT:1> <= np.min(images) < <NUM_LIT:0>):<EOL><INDENT>images = ((images + <NUM_LIT:1>) * <NUM_LIT>).astype(np.uint8)<EOL><DEDENT>elif np.max(images) <= <NUM_LIT:1> and np.min(images) >= <NUM_LIT:0>:<EOL><INDENT>images = (images * <NUM_LIT:255>).astype(np.uint8)<EOL><DEDENT>return imageio.imwrite(path, merge(images, size))<EOL><DEDENT>if len(images) > size[<NUM_LIT:0>] * size[<NUM_LIT:1>]:<EOL><INDENT>raise AssertionError("<STR_LIT>".format(len(images)))<EOL><DEDENT>return imsave(images, size, image_path)<EOL>
Save multiple images into one single image.

    Parameters
    -----------
    images : numpy array
        (batch, w, h, c)
    size : list of 2 ints
        row and column number.
        number of images should be equal or less than size[0] * size[1]
    image_path : str
        save path

    Examples
    ---------
    >>> import numpy as np
    >>> import tensorlayer as tl
    >>> images = np.random.rand(64, 100, 100, 3)
    >>> tl.visualize.save_images(images, [8, 8], 'temp.png')