def _save_image(image, filename, nrow=8, padding=2, square_image=True):
    """Saves a given Tensor into an image file. If the input tensor contains multiple images,
    a grid of images will be saved.

    Parameters
    ----------
        image : `NDArray`
            Input image(s) in the format of HW, CHW, or NCHW.
        filename : str
            Filename of the saved image(s).
        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.
        square_image : bool
            If True, force the image grid to be strictly square.
    """
    if not isinstance(image, NDArray):
        raise TypeError('MXNet NDArray expected, received {}'.format(str(type(image))))
    image = _prepare_image(image, nrow=nrow, padding=padding, square_image=square_image)
    if Image is None:
        raise ImportError('saving image failed because PIL is not found')
    im = Image.fromarray(image.asnumpy())
    im.save(filename)
def _save_image ( image , filename , nrow = 8 , padding = 2 , square_image = True ) : if not isinstance ( image , NDArray ) : raise TypeError ( 'MXNet NDArray expected, received {}' . format ( str ( type ( image ) ) ) ) image = _prepare_image ( image , nrow = nrow , padding = padding , square_image = square_image ) if Image is None : raise ImportError ( 'saving image failed because PIL is not found' ) im = Image . fromarray ( image . asnumpy ( ) ) im . save ( filename )
Saves a given Tensor into an image file. If the input tensor contains multiple images,
    a grid of images will be saved.

    Parameters
    ----------
        image : `NDArray`
            Input image(s) in the format of HW, CHW, or NCHW.
        filename : str
            Filename of the saved image(s).
        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.
        square_image : bool
            If True, force the image grid to be strictly square.