code: def _to_polylines(result, tolerance, filled, confidence_thresh=None):
      if result.masks is None:
          return None
  
      classes = np.rint(result.boxes.cls.detach().cpu().numpy()).astype(
          int
      )
      confs = result.boxes.conf.detach().cpu().numpy().astype(float)
  
      if tolerance > 1:
          masks = result.masks.data.detach().cpu().numpy() > 0.5
          points = itertools.repeat(None)
      else:
          masks = itertools.repeat(None)
          points = result.masks.xyn
  
      polylines = []
      for cls, mask, _points, conf in zip(
          classes, masks, points, confs
      ):
          if confidence_thresh is not None and conf < confidence_thresh:
              continue
  
          if _points is None:
              _points = fol._get_polygons(mask, tolerance)
          else:
              _points = [_points.astype(float)]
  
          label = result.names[cls]
  
          polyline = fol.Polyline(
              label=label,
              points=_points,
              confidence=conf,
              closed=True,
              filled=filled,
          )
          polylines.append(polyline)
  
      return fol.Polylines(polylines=polylines)
  
imports: import itertools
  import numpy
  from PIL import Image
  from fiftyone.core.config import Config
  import fiftyone.core.labels
  from fiftyone.core.models import Model
  import fiftyone.utils.torch
  import fiftyone.core.utils
label_desc: Use image node_id 7 for calling a global function with example usage: _to_polylines(result, tolerance, filled, confidence_thresh) and returns: fol, None