def draw_grid(self, images, rows, cols):
if ia.is_np_array(images):<EOL><INDENT>if len(images.shape) == <NUM_LIT:4>:<EOL><INDENT>images = [images[i] for i in range(images.shape[<NUM_LIT:0>])]<EOL><DEDENT>elif len(images.shape) == <NUM_LIT:3>:<EOL><INDENT>images = [images]<EOL><DEDENT>elif len(images.shape) == <NUM_LIT:2>:<EOL><INDENT>images = [images[:, :, np.newaxis]]<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>"<EOL>+ "<STR_LIT>" % (images.shape,))<EOL><DEDENT><DEDENT>elif isinstance(images, list):<EOL><INDENT>for i, image in enumerate(images):<EOL><INDENT>if len(image.shape) == <NUM_LIT:3>:<EOL><INDENT>continue<EOL><DEDENT>elif len(image.shape) == <NUM_LIT:2>:<EOL><INDENT>images[i] = image[:, :, np.newaxis]<EOL><DEDENT>else:<EOL><INDENT>raise Exception(("<STR_LIT>"<EOL>+ "<STR_LIT>") % (i, image.shape,))<EOL><DEDENT><DEDENT><DEDENT>ia.do_assert(isinstance(images, list))<EOL>det = self if self.deterministic else self.to_deterministic()<EOL>augs = []<EOL>for image in images:<EOL><INDENT>augs.append(det.augment_images([image] * (rows * cols)))<EOL><DEDENT>augs_flat = list(itertools.chain(*augs))<EOL>cell_height = max([image.shape[<NUM_LIT:0>] for image in augs_flat])<EOL>cell_width = max([image.shape[<NUM_LIT:1>] for image in augs_flat])<EOL>width = cell_width * cols<EOL>height = cell_height * (rows * len(images))<EOL>grid = np.zeros((height, width, <NUM_LIT:3>), dtype=augs[<NUM_LIT:0>][<NUM_LIT:0>].dtype)<EOL>for row_idx in range(rows):<EOL><INDENT>for img_idx, image in enumerate(images):<EOL><INDENT>for col_idx in range(cols):<EOL><INDENT>image_aug = augs[img_idx][(row_idx * cols) + col_idx]<EOL>cell_y1 = cell_height * (row_idx * len(images) + img_idx)<EOL>cell_y2 = cell_y1 + image_aug.shape[<NUM_LIT:0>]<EOL>cell_x1 = cell_width * col_idx<EOL>cell_x2 = cell_x1 + image_aug.shape[<NUM_LIT:1>]<EOL>grid[cell_y1:cell_y2, cell_x1:cell_x2, :] = image_aug<EOL><DEDENT><DEDENT><DEDENT>return grid<EOL>
Apply this augmenter to the given images and return a grid image of the results.
Each cell in the grid contains a single augmented variation of an input image.

If multiple images are provided, the row count is multiplied by
the number of images and each image gets its own row.
E.g. for ``images = [A, B]``, ``rows=2``, ``cols=3``::

    A A A
    B B B
    A A A
    B B B

for ``images = [A]``, ``rows=2``,
``cols=3``::

    A A A
    A A A

Parameters
-------
images : (N,H,W,3) ndarray or (H,W,3) ndarray or (H,W) ndarray or list of (H,W,3) ndarray\
         or list of (H,W) ndarray
    List of images of which to show the augmented versions.
    If a list, then each element is expected to have shape ``(H, W)`` or
    ``(H, W, 3)``. If a single array, then it is expected to have
    shape ``(N, H, W, 3)`` or ``(H, W, 3)`` or ``(H, W)``.

rows : int
    Number of rows in the grid.
    If ``N`` input images are given, this value will automatically be
    multiplied by ``N`` to create rows for each image.

cols : int
    Number of columns in the grid.

Returns
-------
grid : (Hg, Wg, 3) ndarray
    The generated grid image with augmented versions of the input
    images. Here, ``Hg`` and ``Wg`` reference the output size of the grid,
    and *not* the sizes of the input images.