code: def _build_segmentation_mask(image_info, seg):
      cv2 = tfds.core.lazy_imports.cv2
      mask = np.zeros(
          (image_info["height"], image_info["width"]), np.uint8
      )
      error_msg = f"Annotation contains an invalid polygon with < 3 points: {seg}"
      assert all(
          len(poly) % 2 == 0 and len(poly) >= 6 for poly in seg
      ), error_msg
  
      for poly in seg:
          poly = np.asarray(poly, np.int32).reshape((1, -1, 2))
          cv2.fillPoly(mask, poly, 255)
      return mask[:, :, np.newaxis]
  
imports: from __future__ import annotations
  import collections
  import json
  import pathlib
  from etils import epath
  import numpy
  import tensorflow_datasets.public_api
label_desc: Use image node_id 3 for calling a global function with example usage: _build_segmentation_mask(image_info, seg) and returns: mask