code: def convert_pil(
      pil_image, grayscale, num_channels, return_palette_indices
  ):
      if pil_image.mode == "I":
          raise ValueError(
              "Input img type seems int32. Currently we don`t support int32 image in pillow backend."
          )
  
      # Note:
      #   This code block below is copied from
      #   https://github.com/scipy/scipy/blob/maintenance/1.2.x/scipy/misc/pilutil.py.
      if pil_image.mode == "P" and not return_palette_indices:
          # Mode 'P' means there is an indexed "palette".  If we leave the mode
          # as 'P', then when we do `a = array(im)` below, `a` will be a 2-D
          # containing the indices into the palette, and not a 3-D array
          # containing the RGB or RGBA values.
          if "transparency" in pil_image.info:
              pil_image = pil_image.convert("RGBA")
          else:
              pil_image = pil_image.convert("RGB")
  
      if grayscale:
          ret = np.asarray(pil_image.convert("L"))
  
          if num_channels > 0:
              ret = np.broadcast_to(
                  ret[..., np.newaxis], ret.shape + (num_channels,)
              )
  
          return ret
      elif num_channels == 3:
          return pil_image.convert("RGB")
  
      elif num_channels == 4:
          return pil_image.convert("RGBA")
  
      return pil_image
  
file_path: nnabla/python/src/nnabla/utils/image_utils/backend_events/pil_backend.py
imports: from __future__ import absolute_import, division
  import numpy
  from PIL import Image
  from nnabla.logger import logger
  from .common import _imread_before, _imread_after, _imsave_before, _imresize_before, _imresize_after
  from .image_utils_backend import ImageUtilsBackend
label_desc: Use image node_id 2 for calling the PilBackend obj's underlying member method code with example usage: obj.convert_pil(pil_image, grayscale, num_channels, return_palette_indices) and returns: pil_image, ret, pil_image, pil_image