code: def to_polylines(
      results, confidence_thresh=None, tolerance=2, filled=True
  ):
      """Converts ``ultralytics.YOLO`` instance segmentations to FiftyOne format.
  
      Args:
          results: a single or list of ``ultralytics.engine.results.Results``
          confidence_thresh (None): a confidence threshold to filter boxes
          tolerance (2): a tolerance, in pixels, when generating approximate
              polylines for instance masks. Typical values are 1-3 pixels
          filled (True): whether the polyline should be filled
  
      Returns:
          a single or list of :class:`fiftyone.core.labels.Polylines`
      """
      single = not isinstance(results, list)
      if single:
          results = [results]
  
      batch = [
          _to_polylines(
              r, tolerance, filled, confidence_thresh=confidence_thresh
          )
          for r in results
      ]
  
      if single:
          return batch[0]
  
      return batch
  
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 6 for calling a global function with example usage: to_polylines(results, confidence_thresh, tolerance, filled) and returns: batch, batch