Resize image by pil module.
    Args:
        img (numpy.ndarray): Image array to save.
            Image shape is considered as (height, width, channel) for RGB or (height, width) for gray-scale by default.
        size (tupple of int): (width, height).
        channel_first (bool):
            This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
            Default value isyou can get the array whose shape is False, which means the img shape is (height, width, channels)
        interpolate (str):
            must be one of ["nearest", "box", "bilinear", "hamming", "bicubic", "lanczos"]
    Returns:
         numpy.ndarray whose shape is ('size'[1], 'size'[0], channel) or (size[1], size[0])

def imresize(img, size, interpolate="bilinear", channel_first=False):
    """
    Resize image by pil module.
    Args:
        img (numpy.ndarray): Image array to save.
            Image shape is considered as (height, width, channel) for RGB or (height, width) for gray-scale by default.
        size (tupple of int): (width, height).
        channel_first (bool):
            This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
            Default value isyou can get the array whose shape is False, which means the img shape is (height, width, channels)
        interpolate (str):
            must be one of ["nearest", "box", "bilinear", "hamming", "bicubic", "lanczos"]
    Returns:
         numpy.ndarray whose shape is ('size'[1], 'size'[0], channel) or (size[1], size[0])
    """

    img = _imresize_before(img, size, channel_first,
                           interpolate, list(interpolations_map.keys()))

    expand_flag = False
    if len(img.shape) == 3 and img.shape[-1] == 1:
        # (h, w, 1) can not be handled by pil.Image, temporally reshape to (h, w)
        img = img.reshape(img.shape[0], img.shape[1])
        expand_flag = True

    resample = interpolations_map[interpolate]

    if img.dtype == np.uint8:
        resized = pil_resize_from_ndarray(img, size, resample)
    else:
        dtype = img.dtype
        img_float32 = np.asarray(img, np.float32)
        if len(img.shape) == 3:
            resized = np.stack([pil_resize_from_ndarray(img_float32[..., i], size, resample)
                                for i in range(img.shape[-1])], axis=2)
        else:
            resized = pil_resize_from_ndarray(img_float32, size, resample)

        resized = np.asarray(resized, dtype)

    if expand_flag:
        resized = resized[..., np.newaxis]

    return _imresize_after(resized, channel_first)