code: def _to_keypoints(result, confidence_thresh=None):
      if result.keypoints is None:
          return None
  
      classes = np.rint(result.boxes.cls.detach().cpu().numpy()).astype(
          int
      )
      points = result.keypoints.xyn.detach().cpu().numpy().astype(float)
      if result.keypoints.conf is not None:
          confs = (
              result.keypoints.conf.detach().cpu().numpy().astype(float)
          )
      else:
          confs = itertools.repeat(None)
  
      keypoints = []
      for cls, _points, _confs in zip(classes, points, confs):
          if confidence_thresh is not None:
              _points[_confs < confidence_thresh] = np.nan
  
          label = result.names[cls]
          _confidence = _confs.tolist() if _confs is not None else None
  
          keypoint = fol.Keypoint(
              label=label,
              points=_points.tolist(),
              confidence=_confidence,
          )
          keypoints.append(keypoint)
  
      return fol.Keypoints(keypoints=keypoints)
  
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 9 for calling a global function with example usage: _to_keypoints(result, confidence_thresh) and returns: fol, None