code: def compute_ious(
      preds,
      gts,
      iscrowd=None,
      classwise=False,
      use_masks=False,
      use_boxes=False,
      tolerance=None,
      error_level=1,
  ):
      """Computes the pairwise IoUs between the predicted and ground truth
      objects.
  
      For polylines, IoUs are computed as solid shapes when ``filled=True` and
      "IoUs" are computed using
      `object keypoint similarity <https://cocodataset.org/#keypoints-eval>`_
      when ``filled=False``.
  
      For keypoints, "IoUs" are computed via
      `object keypoint similarity <https://cocodataset.org/#keypoints-eval>`_.
  
      Args:
          preds: a list of predicted
              :class:`fiftyone.core.labels.Detection`,
              :class:`fiftyone.core.labels.Polyline`, or
              :class:`fiftyone.core.labels.Keypoints` instances
          gts: a list of ground truth
              :class:`fiftyone.core.labels.Detection`,
              :class:`fiftyone.core.labels.Polyline`, or
              :class:`fiftyone.core.labels.Keypoints` instances
          iscrowd (None): an optional name of a boolean attribute or boolean
              function to apply to each label that determines whether a ground
              truth object is a crowd. If provided, the area of the predicted
              object is used as the "union" area for IoU calculations involving
              crowd objects
          classwise (False): whether to consider objects with different ``label``
              values as always non-overlapping (True) or to compute IoUs for all
              objects regardless of label (False)
          use_masks (False): whether to compute IoUs using the instances masks in
              the ``mask`` attribute of the provided objects, which must be
              :class:`fiftyone.core.labels.Detection` instances
          use_boxes (False): whether to compute IoUs using the bounding boxes
              of the provided :class:`fiftyone.core.labels.Polyline` instances
              rather than using their actual geometries
          tolerance (None): a tolerance, in pixels, when generating approximate
              polylines for instance masks. Typical values are 1-3 pixels
          error_level (1): the error level to use when manipulating instance
              masks or polylines. Valid values are:
  
              -   0: raise geometric errors that are encountered
              -   1: log warnings if geometric errors are encountered
              -   2: ignore geometric errors
  
              If ``error_level > 0``, any calculation that raises a geometric
              error will default to an IoU of 0
  
      Returns:
          a ``num_preds x num_gts`` array of IoUs
      """
      if not preds or not gts:
          return np.zeros((len(preds), len(gts)))
  
      if etau.is_str(iscrowd):
          iscrowd = lambda l: bool(
              l.get_attribute_value(iscrowd, False)
          )
  
      if isinstance(gts[0], fol.Polyline):
          if use_boxes:
              return _compute_bbox_ious(
                  preds, gts, iscrowd=iscrowd, classwise=classwise
              )
  
          if any(gt.filled for gt in gts):
              return _compute_polygon_ious(
                  preds,
                  gts,
                  error_level,
                  iscrowd=iscrowd,
                  classwise=classwise,
              )
  
          return _compute_polyline_similarities(
              preds, gts, classwise=classwise
          )
  
      if isinstance(gts[0], fol.Keypoint):
          return _compute_keypoint_similarities(
              preds, gts, classwise=classwise
          )
  
      if use_masks:
          # @todo when tolerance is None, consider using dense masks rather than
          # polygonal approximations?
          if tolerance is None:
              tolerance = 2
  
          return _compute_mask_ious(
              preds,
              gts,
              tolerance,
              error_level,
              iscrowd=iscrowd,
              classwise=classwise,
          )
  
      return _compute_bbox_ious(
          preds, gts, iscrowd=iscrowd, classwise=classwise
      )
  
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 1 for calling a global function with example usage: compute_ious(preds, gts, iscrowd, classwise, use_masks, use_boxes, tolerance, error_level) and returns: _compute_bbox_ious, np, _compute_polyline_similarities, _compute_keypoint_similarities, _compute_mask_ious, _compute_bbox_ious, _compute_polygon_ious