code: def save_alpha_pred(
      alpha: np.ndarray, trimap: Union[np.ndarray, str] = None
  ):
      """
      The value of alpha is range [0, 1], shape should be [h,w]
      """
      if isinstance(trimap, str):
          trimap = cv2.imread(trimap, 0)
  
      alpha[trimap == 0] = 0
      alpha[trimap == 255] = 255
      alpha = (alpha).astype("uint8")
      return alpha
  
imports: import random
  import base64
  from typing import Callable, Union, List, Tuple
  import cv2
  import numpy
  import paddle
  import paddle.nn.functional
  from paddleseg.transforms import functional
  from PIL import Image
label_desc: Use image node_id 2 for calling a global function with example usage: save_alpha_pred(alpha, trimap) and returns: alpha