code: def _polylines_to_shapely(polylines, error_level):
      polys = []
      for polyline in polylines:
          try:
              poly = polyline.to_shapely(filled=True)
  
              # Cleanup invalid (eg overlapping or self-intersecting) geometries
              # https://shapely.readthedocs.io/en/stable/manual.html#shapely.ops.unary_union
              # https://shapely.readthedocs.io/en/stable/manual.html#object.buffer
              poly = so.unary_union(poly).buffer(0)
          except Exception as e:
              poly = sg.Polygon()
              fou.handle_error(
                  ValueError(
                      "Failed to convert polygon for object '%s' to Shapely "
                      "format" % polyline.id
                  ),
                  error_level,
                  base_error=e,
              )
  
          polys.append(poly)
  
      return polys
  
imports: import contextlib
  import itertools
  import logging
  import numpy
  import scipy.spatial
  import eta.core.numutils
  import eta.core.utils
  import fiftyone.core.labels
  import fiftyone.core.utils
  import fiftyone.core.validation
  from .utils3d import compute_cuboid_iou
label_desc: Use image node_id 22 for calling a global function with example usage: _polylines_to_shapely(polylines, error_level) and returns: polys