code: def mask_to_onehot(mask, num_classes):
      """
      Convert a mask (H, W) to onehot (K, H, W).
  
      Args:
          mask (np.ndarray): Label mask with shape (H, W)
          num_classes (int): Number of classes.
  
      Returns:
          np.ndarray: Onehot mask with shape(K, H, W).
      """
      _mask = [mask == i for i in range(num_classes)]
      _mask = np.array(_mask).astype(np.uint8)
      return _mask
  
imports: import cv2
  import numpy
  from PIL import Image, ImageEnhance
  from scipy.ndimage import distance_transform_edt
label_desc: Use image node_id 15 for calling a global function with example usage: mask_to_onehot(mask, num_classes) and returns: _mask