class_docstr: Box selector which selects the predicted boxes.
  The box selection is performed with the following steps:
  
  #. For each level, discard boxes with scores less than self.score_thresh.
  #. For each level, keep boxes with top self.topk_candidates_per_level scores.
  #. For the whole image, perform non-maximum suppression (NMS) on boxes, with overlapping threshold nms_thresh.
  #. For the whole image, keep boxes with top self.detections_per_img scores.
  
  Args:
      apply_sigmoid: whether to apply sigmoid to get scores from classification logits
      score_thresh: no box with scores less than score_thresh will be kept
      topk_candidates_per_level: max number of boxes to keep for each level
      nms_thresh: box overlapping threshold for NMS
      detections_per_img: max number of boxes to keep for each image
  
  Example:
  
      .. code-block:: python
  
          input_param = {
              "apply_sigmoid": True,
              "score_thresh": 0.1,
              "topk_candidates_per_level": 2,
              "nms_thresh": 0.1,
              "detections_per_img": 5,
          }
          box_selector = BoxSelector(**input_param)
          boxes = [torch.randn([3,6]), torch.randn([7,6])]
          logits = [torch.randn([3,3]), torch.randn([7,3])]
          spatial_size = (8,8,8)
          selected_boxes, selected_scores, selected_labels = box_selector.select_boxes_per_image(
              boxes, logits, spatial_size
          )
code: def __init__(
      self,
      box_overlap_metric: Callable = box_iou,
      apply_sigmoid: bool = True,
      score_thresh: float = 0.05,
      topk_candidates_per_level: int = 1000,
      nms_thresh: float = 0.5,
      detections_per_img: int = 300,
  ):
      self.box_overlap_metric = box_overlap_metric
  
      self.apply_sigmoid = apply_sigmoid
      self.score_thresh = score_thresh
      self.topk_candidates_per_level = topk_candidates_per_level
      self.nms_thresh = nms_thresh
      self.detections_per_img = detections_per_img
  
file_path: MONAI/monai/apps/detection/utils/box_selector.py
imports: from __future__ import annotations
  from collections.abc import Callable
  import torch
  from torch import Tensor
  from monai.data.box_utils import batched_nms, box_iou, clip_boxes_to_image
  from monai.transforms.utils_pytorch_numpy_unification import floor_divide
label_desc: Use image node_id 1 to create a new BoxSelector object  with example: obj = BoxSelector(box_overlap_metric, apply_sigmoid, score_thresh, topk_candidates_per_level, nms_thresh, detections_per_img)