class_docstr: General purpose box cropper when the corresponding image is cropped by SpatialCrop(*) with the same ROI.
  The difference is that we do not support negative indexing for roi_slices.
  
  If a dimension of the expected ROI size is bigger than the input image size, will not crop that dimension.
  So the cropped result may be smaller than the expected ROI, and the cropped results of several images may
  not have exactly the same shape.
  It can support to crop ND spatial boxes.
  
  The cropped region can be parameterised in various ways:
      - a list of slices for each spatial dimension (do not allow for use of negative indexing)
      - a spatial center and size
      - the start and end coordinates of the ROI
  
  Args:
      roi_center: voxel coordinates for center of the crop ROI.
      roi_size: size of the crop ROI, if a dimension of ROI size is bigger than image size,
          will not crop that dimension of the image.
      roi_start: voxel coordinates for start of the crop ROI.
      roi_end: voxel coordinates for end of the crop ROI, if a coordinate is out of image,
          use the end coordinate of image.
      roi_slices: list of slices for each of the spatial dimensions.
class_docstr_tok: ["General","purpose","box","cropper","when","the","corresponding","image","is","cropped","by","SpatialCrop","(","*",")","with","the","same","ROI",".","The","difference","is","that","we","do","not","support","negative","indexing","for","roi_slices",".","If","a","dimension","of","the","expected","ROI","size","is","bigger","than","the","input","image","size",",","will","not","crop","that","dimension",".","So","the","cropped","result","may","be","smaller","than","the","expected","ROI",",","and","the","cropped","results","of","several","images","may","not","have","exactly","the","same","shape",".","It","can","support","to","crop","ND","spatial","boxes",".","The","cropped","region","can","be","parameterised","in","various","ways",":","-","a","list","of","slices","for","each","spatial","dimension","(","do","not","allow","for","use","of","negative","indexing",")","-","a","spatial","center","and","size","-","the","start","and","end","coordinates","of","the","ROI","Args",":","roi_center",":","voxel","coordinates","for","center","of","the","crop","ROI",".","roi_size",":","size","of","the","crop","ROI",",","if","a","dimension","of","ROI","size","is","bigger","than","image","size",",","will","not","crop","that","dimension","of","the","image",".","roi_start",":","voxel","coordinates","for","start","of","the","crop","ROI",".","roi_end",":","voxel","coordinates","for","end","of","the","crop","ROI",",","if","a","coordinate","is","out","of","image",",","use","the","end","coordinate","of","image",".","roi_slices",":","list","of","slices","for","each","of","the","spatial","dimensions","."]
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
  
  Returns:
      - cropped boxes, does not share memory with original boxes
      - cropped labels, does not share memory with original labels
  
  Example:
      .. code-block:: python
  
          box_cropper = SpatialCropPadBox(roi_start=[0, 1, 4], roi_end=[21, 15, 8])
          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)
          boxes_crop, labels_crop_tuple = box_cropper(boxes, labels)
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","Returns",":","-","cropped","boxes",",","does","not","share","memory","with","original","boxes","-","cropped","labels",",","does","not","share","memory","with","original","labels","Example",":","..","code-block",":",":","python","box_cropper","=","SpatialCropPadBox","(","roi_start=","[","0",",","1",",","4","]",",","roi_end=","[","21",",","15",",","8","]",")","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",")","boxes_crop",",","labels_crop_tuple","=","box_cropper","(","boxes",",","labels",")"]
code: def __call__(  # type: ignore[override]
      self,
      boxes: NdarrayTensor,
      labels: Sequence[NdarrayOrTensor] | NdarrayOrTensor,
  ) -> tuple[NdarrayTensor, 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
  
      Returns:
          - cropped boxes, does not share memory with original boxes
          - cropped labels, does not share memory with original labels
  
      Example:
          .. code-block:: python
  
              box_cropper = SpatialCropPadBox(roi_start=[0, 1, 4], roi_end=[21, 15, 8])
              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)
              boxes_crop, labels_crop_tuple = box_cropper(boxes, labels)
      """
      spatial_dims = min(
          len(self.slices), get_spatial_dims(boxes=boxes)
      )  # spatial dims
      boxes_crop, keep = spatial_crop_boxes(
          boxes,
          [self.slices[axis].start for axis in range(spatial_dims)],
          [self.slices[axis].stop for axis in range(spatial_dims)],
      )
      return boxes_crop, 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 SpatialCropBox obj's underlying member method code with example usage: obj.__call__(boxes, labels) and returns: boxes_crop,  select_labels