code: def _apply_confidence_thresh(label, confidence_thresh):
      if _is_frames_dict(label):
          label = {
              frame_number: _apply_confidence_thresh(
                  frame_dict, confidence_thresh
              )
              for frame_number, frame_dict in label.items()
          }
      elif isinstance(label, dict):
          label = {
              k: _apply_confidence_thresh(v, confidence_thresh)
              for k, v in label.items()
          }
      elif isinstance(label, fol._HasLabelList):
          labels = [
              l
              for l in getattr(label, label._LABEL_LIST_FIELD)
              if l.confidence is not None
              and l.confidence >= confidence_thresh
          ]
          setattr(label, label._LABEL_LIST_FIELD, labels)
      elif hasattr(label, "confidence"):
          if (
              label.confidence is None
              or label.confidence < confidence_thresh
          ):
              label = None
  
      return label
  
imports: import os
  from bson import ObjectId
  from fiftyone.core.document import Document, DocumentView
  import fiftyone.core.frame
  import fiftyone.core.frame_utils
  import fiftyone.core.labels
  import fiftyone.core.metadata
  import fiftyone.core.media
  import fiftyone.core.odm
  import fiftyone.core.utils
  from fiftyone.core.singletons import SampleSingleton
label_desc: Use image node_id 2 for calling a global function with example usage: _apply_confidence_thresh(label, confidence_thresh) and returns: label