class_docstr: This class encodes and decodes a set of bounding boxes into
  the representation used for training the regressors.
  
  Args:
      weights: 4-element tuple or 6-element tuple
      boxes_xform_clip: high threshold to prevent sending too large values into torch.exp()
  
  Example:
      .. code-block:: python
  
          box_coder = BoxCoder(weights=[1., 1., 1., 1., 1., 1.])
          gt_boxes = torch.tensor([[1,2,1,4,5,6],[1,3,2,7,8,9]])
          proposals = gt_boxes + torch.rand(gt_boxes.shape)
          rel_gt_boxes = box_coder.encode_single(gt_boxes, proposals)
          gt_back = box_coder.decode_single(rel_gt_boxes, proposals)
          # We expect gt_back to be equal to gt_boxes
docstr: From a set of original boxes and encoded relative box offsets,
  
  Args:
      rel_codes: encoded boxes, Nx(4*num_box_reg) or Nx(6*num_box_reg) torch tensor.
      reference_boxes: reference boxes, Nx4 or Nx6 torch tensor. The box mode is assumed to be ``StandardMode``
  
  Return:
      decoded boxes, Nx(4*num_box_reg) or Nx(6*num_box_reg) torch tensor. The box mode will to be ``StandardMode``
docstr_tok: ["From","a","set","of","original","boxes","and","encoded","relative","box","offsets",",","Args",":","rel_codes",":","encoded","boxes",",","Nx","(","4","*","num_box_reg",")","or","Nx","(","6","*","num_box_reg",")","torch","tensor",".","reference_boxes",":","reference","boxes",",","Nx4","or","Nx6","torch","tensor",".","The","box","mode","is","assumed","to","be","``","StandardMode","``","Return",":","decoded","boxes",",","Nx","(","4","*","num_box_reg",")","or","Nx","(","6","*","num_box_reg",")","torch","tensor",".","The","box","mode","will","to","be","``","StandardMode","``"]
code: def decode_single(
      self, rel_codes: Tensor, reference_boxes: Tensor
  ) -> Tensor:
      """
      From a set of original boxes and encoded relative box offsets,
  
      Args:
          rel_codes: encoded boxes, Nx(4*num_box_reg) or Nx(6*num_box_reg) torch tensor.
          reference_boxes: reference boxes, Nx4 or Nx6 torch tensor. The box mode is assumed to be ``StandardMode``
  
      Return:
          decoded boxes, Nx(4*num_box_reg) or Nx(6*num_box_reg) torch tensor. The box mode will to be ``StandardMode``
      """
      reference_boxes = reference_boxes.to(rel_codes.dtype)
      offset = reference_boxes.shape[-1]
  
      pred_boxes = []
      boxes_cccwhd = convert_box_mode(
          reference_boxes,
          src_mode=StandardMode,
          dst_mode=CenterSizeMode,
      )
      for axis in range(self.spatial_dims):
          whd_axis = boxes_cccwhd[:, axis + self.spatial_dims]
          ctr_xyz_axis = boxes_cccwhd[:, axis]
          dxyz_axis = rel_codes[:, axis::offset] / self.weights[axis]
          dwhd_axis = (
              rel_codes[:, self.spatial_dims + axis :: offset]
              / self.weights[axis + self.spatial_dims]
          )
          # Prevent sending too large values into torch.exp()
          dwhd_axis = torch.clamp(
              dwhd_axis.to(COMPUTE_DTYPE), max=self.boxes_xform_clip
          )
  
          pred_ctr_xyx_axis = (
              dxyz_axis * whd_axis[:, None] + ctr_xyz_axis[:, None]
          )
          pred_whd_axis = torch.exp(dwhd_axis) * whd_axis[:, None]
          pred_whd_axis = pred_whd_axis.to(dxyz_axis.dtype)
  
          # When convert float32 to float16, Inf or Nan may occur
          if (
              torch.isnan(pred_whd_axis).any()
              or torch.isinf(pred_whd_axis).any()
          ):
              raise ValueError("pred_whd_axis is NaN or Inf.")
  
          # Distance from center to box's corner.
          c_to_c_whd_axis = (
              torch.tensor(
                  0.5,
                  dtype=pred_ctr_xyx_axis.dtype,
                  device=pred_whd_axis.device,
              )
              * pred_whd_axis
          )
  
          pred_boxes.append(pred_ctr_xyx_axis - c_to_c_whd_axis)
          pred_boxes.append(pred_ctr_xyx_axis + c_to_c_whd_axis)
  
      pred_boxes = pred_boxes[::2] + pred_boxes[1::2]
      pred_boxes_final = torch.stack(pred_boxes, dim=2).flatten(1)
      return pred_boxes_final
  
file_path: MONAI/monai/apps/detection/utils/box_coder.py
imports: from __future__ import annotations
  import math
  from collections.abc import Sequence
  import torch
  from torch import Tensor
  from monai.data.box_utils import COMPUTE_DTYPE, CenterSizeMode, StandardMode, convert_box_mode, is_valid_box_values
  from monai.utils.module import look_up_option
label_desc: Use image node_id 5 for calling the BoxCoder obj's underlying member method code with example usage: obj.decode_single(rel_codes, reference_boxes) and returns: pred_boxes_final