def imsave(path, img, channel_first=False, as_uint16=False, auto_scale=True):
    """
    Save image by cv2 module.
    Args:
        path (str): output filename
        img (numpy.ndarray): Image array to save. Image shape is considered as (height, width, channel) by default.
        channel_first:
            This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
            Default value is False, which means the img shape is (height, width, channel)
        as_uint16 (bool):
            If True, save image as uint16.
         auto_scale (bool) :
            Whether upscale pixel values or not.
            If you want to save float image, this argument must be True.
            In cv2 backend, all below are supported.
                - float ([0, 1]) to uint8 ([0, 255])  (if img.dtype==float and auto_scale==True and as_uint16==False)
                - float to uint16 ([0, 65535]) (if img.dtype==float and auto_scale==True and as_uint16==True)
                - uint8 to uint16 are supported (if img.dtype==np.uint8 and auto_scale==True and as_uint16==True)
    """

    img = _imsave_before(img, channel_first, auto_scale)

    if auto_scale:
        img = upscale_pixel_intensity(img, as_uint16)

    img = check_type_and_cast_if_necessary(img, as_uint16)

    # revert channel order to opencv`s one.
    if len(img.shape) == 3:
        if img.shape[-1] == 3:
            img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
        elif img.shape[-1] == 4:
            img = cv2.cvtColor(img, cv2.COLOR_RGBA2BGRA)

    cv2.imwrite(path, img)