def make_image_grid(tensor, nrow=<NUM_LIT:8>, padding=<NUM_LIT:2>, normalize=False, norm_range=None,<EOL>scale_each=False, pad_value=<NUM_LIT:0>, square_image=False):
if not isinstance(tensor, NDArray) or not (isinstance(tensor, NDArray) and<EOL>all(isinstance(t, NDArray) for t in tensor)):<EOL><INDENT>raise TypeError('<STR_LIT>'.format(<EOL>str(type(tensor))))<EOL><DEDENT>if isinstance(tensor, list):<EOL><INDENT>tensor = op.stack(tensor, axis=<NUM_LIT:0>)<EOL><DEDENT>if tensor.ndim <= <NUM_LIT:1> or tensor.ndim > <NUM_LIT:4>:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(<EOL>tensor.ndim))<EOL><DEDENT>if tensor.ndim == <NUM_LIT:2>:  <EOL><INDENT>tensor = tensor.reshape(((<NUM_LIT:1>,) + tensor.shape))<EOL><DEDENT>if tensor.ndim == <NUM_LIT:3>:  <EOL><INDENT>if tensor.shape[<NUM_LIT:0>] == <NUM_LIT:1>:  <EOL><INDENT>tensor = op.concat(*(tensor, tensor, tensor), dim=<NUM_LIT:0>)<EOL><DEDENT>tensor = tensor.reshape((<NUM_LIT:1>,) + tensor.shape)<EOL><DEDENT>if tensor.ndim == <NUM_LIT:4> and tensor.shape[<NUM_LIT:1>] == <NUM_LIT:1>:  <EOL><INDENT>tensor = op.concat(*(tensor, tensor, tensor), dim=<NUM_LIT:1>)<EOL><DEDENT>if normalize is True:<EOL><INDENT>tensor = tensor.copy()  <EOL>if norm_range is not None:<EOL><INDENT>assert isinstance(norm_range, tuple) and len(norm_range) == <NUM_LIT:2>,"<STR_LIT>"<EOL><DEDENT>def norm_ip(img, val_min, val_max):<EOL><INDENT>op.clip(img, a_min=val_min, a_max=val_max, out=img)<EOL>img -= val_min<EOL>img /= (val_max - val_min)<EOL><DEDENT>def norm_range_helper(t, val_range):<EOL><INDENT>if val_range is not None:<EOL><INDENT>norm_ip(t, val_range[<NUM_LIT:0>], val_range[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>norm_ip(t, t.min().asscalar(), t.max().asscalar())<EOL><DEDENT><DEDENT>if scale_each is True:<EOL><INDENT>for t in tensor:  <EOL><INDENT>norm_range_helper(t, norm_range)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>norm_range_helper(tensor, norm_range)<EOL><DEDENT><DEDENT>if tensor.shape[<NUM_LIT:0>] == <NUM_LIT:1>:<EOL><INDENT>return tensor.squeeze(axis=<NUM_LIT:0>)<EOL><DEDENT>nmaps = tensor.shape[<NUM_LIT:0>]<EOL>xmaps = min(nrow, nmaps)<EOL>ymaps = xmaps if square_image else int(np.ceil(float(nmaps) / xmaps))<EOL>height, width = int(tensor.shape[<NUM_LIT:2>] + padding), int(tensor.shape[<NUM_LIT:3>] + padding)<EOL>grid = nd.empty(shape=(<NUM_LIT:3>, height * ymaps + padding, width * xmaps + padding),<EOL>dtype=tensor.dtype, ctx=tensor.context)<EOL>grid[:] = pad_value<EOL>k = <NUM_LIT:0><EOL>for y in range(ymaps):<EOL><INDENT>for x in range(xmaps):<EOL><INDENT>if k >= nmaps:<EOL><INDENT>break<EOL><DEDENT>start1 = y * height + padding<EOL>end1 = start1 + height - padding<EOL>start2 = x * width + padding<EOL>end2 = start2 + width - padding<EOL>grid[:, start1:end1, start2:end2] = tensor[k]<EOL>k = k + <NUM_LIT:1><EOL><DEDENT><DEDENT>return grid<EOL>
Make a grid of images. This is an MXNet version of torchvision.utils.make_grid
    Ref: https://github.com/pytorch/vision/blob/master/torchvision/utils.py

    Parameters
    ----------
        tensor : `NDArray` or list of `NDArray`s
            Input image(s) in the format of HW, CHW, or NCHW.
        nrow : int
            Number of images displayed in each row of the grid. The Final grid size is
            (batch_size / `nrow`, `nrow`) when square_image is False; otherwise, (`nrow`, `nrow`).
        padding : int
            Padding value for each image in the grid.
        normalize : bool
            If True, shift the image to the range (0, 1), by subtracting the
            minimum and dividing by the maximum pixel value.
        norm_range : tuple
            Tuple of (min, max) where min and max are numbers. These numbers are used
            to normalize the image. By default, `min` and `max` are computed from the `tensor`.
        scale_each : bool
            If True, scale each image in the batch of images separately rather than the
            `(min, max)` over all images.
        pad_value : float
            Value for the padded pixels.
        square_image : bool
            If True, force the generated image grid to be strictly square (the last
            row of the image grid may be entire blank as a result).

    Returns
    -------
    NDArray
        A image grid made of the input images.