code: def convert_PIL_to_numpy(image, format):
      """
      Convert PIL image to numpy array of target format.
  
      Args:
          image (PIL.Image): a PIL image
          format (str): the format of output image
  
      Returns:
          (np.ndarray): also see `read_image`
      """
      if format is not None:
          # PIL only supports RGB, so convert to RGB and flip channels over below
          conversion_format = format
          if format in ["BGR", "YUV-BT.601"]:
              conversion_format = "RGB"
          image = image.convert(conversion_format)
      image = np.asarray(image)
      # PIL squeezes out the channel dimension for "L", so make it HWC
      if format == "L":
          image = np.expand_dims(image, -1)
  
      # handle formats not supported by PIL
      elif format == "BGR":
          # flip channels if needed
          image = image[:, :, ::-1]
      elif format == "YUV-BT.601":
          image = image / 255.0
          image = np.dot(image, np.array(_M_RGB2YUV).T)
  
      return image
  
imports: import os
  import logging
  import numpy
  from PIL import Image
  import torch
  from ..structures import BitMasks, Boxes, BoxMode, Instances, Keypoints, PolygonMasks, polygons_to_bitmask
  from ..transforms import instance_transforms
  from ..registry.catalog import MetadataCatalog
label_desc: Use image node_id 4 for calling a global function with example usage: convert_PIL_to_numpy(image, format) and returns: image