code: def find_duplicates(
      sample_collection,
      label_field,
      iou_thresh=0.999,
      method="simple",
      **kwargs,
  ):
      """Returns IDs of duplicate labels in the given field of the collection, as
      defined as labels with an IoU greater than a chosen threshold with another
      label in the field.
  
      The following duplicate removal methods are supported:
  
      -   ``method="simple"``: mark the latter label in every pair of labels
          whose IoU exceeds the threshold. This may remove more labels than the
          greedy method
  
      -   ``method="greedy"``: apply a greedy method to mark the fewest number of
          labels as duplicate such that no non-duplicate labels have IoU greater
          than the specified threshold. This method is more computationally
          expensive than the simple method
  
      Args:
          sample_collection: a
              :class:`fiftyone.core.collections.SampleCollection`
          label_field: a label field of type
              :class:`fiftyone.core.labels.Detections`,
              :class:`fiftyone.core.labels.Polylines`, or
              :class:`fiftyone.core.labels.Keypoints`
          iou_thresh (0.999): the IoU threshold to use to determine whether
              labels are duplicates
          method ("simple"): the duplicate removal method to use. The supported
              values are ``("simple", "greedy")``
          **kwargs: optional keyword arguments for :func:`compute_ious`
  
      Returns:
          a list of IDs of duplicate labels
      """
      fov.validate_collection_label_fields(
          sample_collection,
          label_field,
          (fol.Detections, fol.Polylines, fol.Keypoints),
      )
  
      (
          _label_field,
          is_frame_field,
      ) = sample_collection._handle_frame_field(label_field)
  
      view = sample_collection.select_fields(label_field)
  
      dup_ids = []
  
      for sample in view.iter_samples(progress=True):
          if is_frame_field:
              for frame in sample.frames.values():
                  _dup_ids = _find_duplicates(
                      frame, _label_field, iou_thresh, method, **kwargs
                  )
                  dup_ids.extend(_dup_ids)
          else:
              _dup_ids = _find_duplicates(
                  sample, _label_field, iou_thresh, method, **kwargs
              )
              dup_ids.extend(_dup_ids)
  
      return dup_ids
  
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 4 for calling a global function with example usage: find_duplicates(sample_collection, label_field, iou_thresh, method) and returns: dup_ids