code: def _batched_nms_coordinate_trick(
      boxes: Tensor,
      scores: Tensor,
      idxs: Tensor,
      iou_threshold: float,
  ) -> Tensor:
      # strategy: in order to perform NMS independently per class,
      # we add an offset to all the boxes. The offset is dependent
      # only on the class idx, and is large enough so that boxes
      # from different classes do not overlap
      if boxes.numel() == 0:
          return torch.empty(
              (0,), dtype=torch.int64, device=boxes.device
          )
      max_coordinate = boxes.max()
      offsets = idxs.to(boxes) * (
          max_coordinate + torch.tensor(1).to(boxes)
      )
      boxes_for_nms = boxes + offsets[:, None]
      keep = nms(boxes_for_nms, scores, iou_threshold)
      return keep
  
imports: from typing import Tuple
  import torch
  import torchvision
  from torch import Tensor
  from torchvision.extension import _assert_has_ops
  from ..utils import _log_api_usage_once
  from ._box_convert import _box_cxcywh_to_xyxy, _box_xywh_to_xyxy, _box_xyxy_to_cxcywh, _box_xyxy_to_xywh
  from ._utils import _upcast
label_desc: Use image node_id 3 for calling a global function with example usage: _batched_nms_coordinate_trick(boxes, scores, idxs, iou_threshold) and returns: keep, torch