code: def preprocess(img, transforms, trimap=None):
      data = {}
      data["img"] = img
      if trimap is not None:
          data["trimap"] = trimap
          data["gt_fields"] = ["trimap"]
      data["trans_info"] = []
      data = transforms(data)
      data["img"] = paddle.to_tensor(data["img"])
      data["img"] = data["img"].unsqueeze(0)
      if trimap is not None:
          data["trimap"] = paddle.to_tensor(data["trimap"])
          data["trimap"] = data["trimap"].unsqueeze((0, 1))
  
      return data
  
file_path: PaddleSeg/Matting/ppmatting/core/predict.py
imports: import os
  import math
  import time
  import cv2
  import numpy
  import paddle
  import paddle.nn.functional
  from paddleseg import utils
  from paddleseg.core import infer
  from paddleseg.utils import logger, progbar, TimeAverager
  from ppmatting.utils import mkdir, estimate_foreground_ml
label_desc: Use image node_id 4 for calling a global function with example usage: preprocess(img, transforms, trimap) and returns: data