def images_to_grid(images):
    """Converts a grid of images (5D tensor) to a single image.

    Args:
      images: 5D tensor (count_y, count_x, height, width, colors), grid of images.

    Returns:
      a 3D tensor image of shape (count_y * height, count_x * width, colors).
    """
    ny, nx, h, w, c = images.shape
    images = images.transpose(0, 2, 1, 3, 4)
    images = images.reshape([ny * h, nx * w, c])
    return images