code: def encode_image(img):
      """
      :param id: String you use to identify this record
      :param data: Data, ndarray type
      :return:
      """
      if isinstance(img, str):
          img = cv2.imread(img)
          if img.size == 0:
              print(
                  "You have pushed an image with path: ",
                  img,
                  "the path is invalid, skipped.",
              )
              return
  
      # force resize here to avoid input image shape inconsistent
      # if the shape is consistent, it would not affect the data
      data = cv2.imencode(".jpg", img)[1]
      img_encoded = base64.b64encode(data).decode("utf-8")
      return img_encoded
  
imports: import pyarrow
  import numpy
  import cv2
  import base64
  from bigdl.serving.log4Error import invalidInputError
label_desc: Use image node_id 2 for calling a global function with example usage: encode_image(img) and returns: img_encoded