class_docstr: Clip the bounding boxes and the associated labels/scores to make sure they are within the image.
  There might be multiple arrays of labels/scores associated with one array of boxes.
  
  Args:
      remove_empty: whether to remove the boxes and corresponding labels that are actually empty
class_docstr_tok: ["Clip","the","bounding","boxes","and","the","associated","labels\/scores","to","make","sure","they","are","within","the","image",".","There","might","be","multiple","arrays","of","labels\/scores","associated","with","one","array","of","boxes",".","Args",":","remove_empty",":","whether","to","remove","the","boxes","and","corresponding","labels","that","are","actually","empty"]
docstr: Args:
      boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode``
      labels: Sequence of array. Each element represents classification labels or scores
          corresponding to ``boxes``, sized (N,).
      spatial_size: The spatial size of the image where the boxes are attached. len(spatial_size) should be in [2, 3].
  
  Returns:
      - clipped boxes, does not share memory with original boxes
      - clipped labels, does not share memory with original labels
  
  Example:
      .. code-block:: python
  
          box_clipper = ClipBoxToImage(remove_empty=True)
          boxes = torch.ones(2, 6)
          class_labels = torch.Tensor([0, 1])
          pred_scores = torch.Tensor([[0.4,0.3,0.3], [0.5,0.1,0.4]])
          labels = (class_labels, pred_scores)
          spatial_size = [32, 32, 32]
          boxes_clip, labels_clip_tuple = box_clipper(boxes, labels, spatial_size)
docstr_tok: ["Args",":","boxes",":","bounding","boxes",",","Nx4","or","Nx6","torch","tensor","or","ndarray",".","The","box","mode","is","assumed","to","be","``","StandardMode","``","labels",":","Sequence","of","array",".","Each","element","represents","classification","labels","or","scores","corresponding","to","``","boxes","``",",","sized","(","N",",",")",".","spatial_size",":","The","spatial","size","of","the","image","where","the","boxes","are","attached",".","len","(","spatial_size",")","should","be","in","[","2",",","3","]",".","Returns",":","-","clipped","boxes",",","does","not","share","memory","with","original","boxes","-","clipped","labels",",","does","not","share","memory","with","original","labels","Example",":","..","code-block",":",":","python","box_clipper","=","ClipBoxToImage","(","remove_empty=True",")","boxes","=","torch.ones","(","2",",","6",")","class_labels","=","torch.Tensor","(","[","0",",","1","]",")","pred_scores","=","torch.Tensor","(","[","[","0.4,0.3,0.3","]",",","[","0.5,0.1,0.4","]","]",")","labels","=","(","class_labels",",","pred_scores",")","spatial_size","=","[","32",",","32",",","32","]","boxes_clip",",","labels_clip_tuple","=","box_clipper","(","boxes",",","labels",",","spatial_size",")"]
code: def __call__(  # type: ignore
      self,
      boxes: NdarrayOrTensor,
      labels: Sequence[NdarrayOrTensor] | NdarrayOrTensor,
      spatial_size: Sequence[int] | int,
  ) -> tuple[NdarrayOrTensor, tuple | NdarrayOrTensor]:
      """
      Args:
          boxes: bounding boxes, Nx4 or Nx6 torch tensor or ndarray. The box mode is assumed to be ``StandardMode``
          labels: Sequence of array. Each element represents classification labels or scores
              corresponding to ``boxes``, sized (N,).
          spatial_size: The spatial size of the image where the boxes are attached. len(spatial_size) should be in [2, 3].
  
      Returns:
          - clipped boxes, does not share memory with original boxes
          - clipped labels, does not share memory with original labels
  
      Example:
          .. code-block:: python
  
              box_clipper = ClipBoxToImage(remove_empty=True)
              boxes = torch.ones(2, 6)
              class_labels = torch.Tensor([0, 1])
              pred_scores = torch.Tensor([[0.4,0.3,0.3], [0.5,0.1,0.4]])
              labels = (class_labels, pred_scores)
              spatial_size = [32, 32, 32]
              boxes_clip, labels_clip_tuple = box_clipper(boxes, labels, spatial_size)
      """
      spatial_dims: int = get_spatial_dims(boxes=boxes)
      spatial_size = ensure_tuple_rep(
          spatial_size, spatial_dims
      )  # match the spatial image dim
  
      boxes_clip, keep = clip_boxes_to_image(
          boxes, spatial_size, self.remove_empty
      )
      return boxes_clip, select_labels(labels, keep)
  
imports: from __future__ import annotations
  from typing import Any, Sequence
  import numpy
  import torch
  from monai.config.type_definitions import DtypeLike, NdarrayOrTensor, NdarrayTensor
  from monai.data.box_utils import BoxMode, clip_boxes_to_image, convert_box_mode, convert_box_to_standard_mode, get_spatial_dims, spatial_crop_boxes, standardize_empty_box
  from monai.transforms import Rotate90, SpatialCrop
  from monai.transforms.transform import Transform
  from monai.utils import ensure_tuple, ensure_tuple_rep, fall_back_tuple, look_up_option
  from monai.utils.enums import TransformBackends
  from .box_ops import apply_affine_to_boxes, convert_box_to_mask, convert_mask_to_box, flip_boxes, resize_boxes, rot90_boxes, select_labels, zoom_boxes
label_desc: Use image node_id 2 for calling the ClipBoxToImage obj's underlying member method code with example usage: obj.__call__(boxes, labels, spatial_size) and returns: boxes_clip,  select_labels