code: def _all_class_nms_ir(
      boxes,
      sorted_scores,
      sorted_indices,
      valid_count,
      batch_class,
      num_class,
      num_anchors,
      iou_threshold,
      max_output_size_per_class,
      box_indices,
      selected_scores,
      num_valid_boxes,
      nms_loop,
  ):
      ib = tvm.tir.ir_builder.create()
      boxes = ib.buffer_ptr(boxes)
      sorted_scores = ib.buffer_ptr(sorted_scores)
      sorted_indices = ib.buffer_ptr(sorted_indices)
      valid_count = ib.buffer_ptr(valid_count)
      box_indices = ib.buffer_ptr(box_indices)
      num_valid_boxes = ib.buffer_ptr(num_valid_boxes)
  
      if selected_scores is not None:
          selected_scores = ib.buffer_ptr(selected_scores)
  
      if isinstance(iou_threshold, float):
          iou_threshold = tvm.tir.FloatImm("float32", iou_threshold)
  
      if isinstance(max_output_size_per_class, int):
          max_output_size_per_class = tvm.tir.const(
              max_output_size_per_class
          )
  
      def calc_overlap(i, j, k):
          offset_j = sorted_indices[i, j] * 4
          offset_k = sorted_indices[i, k] * 4
          batch_id = i // num_class
          base_bbox_idx = batch_id * num_anchors * 4
          return calculate_overlap(
              boxes,
              base_bbox_idx + offset_j,
              base_bbox_idx + offset_k,
          )
  
      def on_new_valid_box(ib, tid, num_current_valid_box, i, j):
          with ib.if_scope(tid + 0 == 0):
              box_indices[i, num_current_valid_box] = sorted_indices[
                  i, j
              ]
  
              if selected_scores is not None:
                  selected_scores[
                      i, num_current_valid_box
                  ] = sorted_scores[i, j]
  
      def on_new_invalidated_box(*_):
          pass
  
      def needs_bbox_check(*_):
          return tvm.tir.const(True)
  
      return nms_loop(
          ib,
          batch_class,
          tvm.tir.IntImm("int32", -1),  # top_k
          iou_threshold,
          max_output_size_per_class,
          valid_count,
          on_new_valid_box,
          on_new_invalidated_box,
          needs_bbox_check,
          calc_overlap,
          sorted_scores,
          num_valid_boxes,
      )
  
file_path: tvm/python/tvm/topi/vision/nms_util.py
imports: import tvm
  from tvm import te
label_desc: Use image node_id 6 for calling a global function with example usage: _all_class_nms_ir(boxes, sorted_scores, sorted_indices, valid_count, batch_class, num_class, num_anchors, iou_threshold, max_output_size_per_class, box_indices, selected_scores, num_valid_boxes, nms_loop) and returns: nms_loop, calculate_overlap, tvm