code: def nms(
      boxes,
      scores=None,
      iou_threshold=0.5,
      max_output_size=None,
      score_threshold=float("-inf"),
  ):
      change_id = False
      if score_threshold is not float("-inf") and scores is not None:
          keep_idx = scores > score_threshold
          boxes = boxes[keep_idx]
          scores = scores[keep_idx]
          change_id = True
          nonzero = ivy.nonzero(keep_idx)[0].flatten()
      if scores is None:
          scores = ivy.ones((boxes.shape[0],), dtype=boxes.dtype)
  
      if len(boxes) < 2:
          if len(boxes) == 1:
              ret = ivy.array([0], dtype=ivy.int64)
          else:
              ret = ivy.array([], dtype=ivy.int64)
      else:
          x1 = boxes[:, 0]
          y1 = boxes[:, 1]
          x2 = boxes[:, 2]
          y2 = boxes[:, 3]
  
          areas = (x2 - x1) * (y2 - y1)
          order = ivy.argsort(
              (-1 * scores), stable=True
          )  # get boxes with more ious first
          keep = []
  
          while order.size > 0:
              i = order[0]  # pick maxmum iou box
              keep.append(i)
              xx1 = ivy.maximum(x1[i], x1[order[1:]])
              yy1 = ivy.maximum(y1[i], y1[order[1:]])
              xx2 = ivy.minimum(x2[i], x2[order[1:]])
              yy2 = ivy.minimum(y2[i], y2[order[1:]])
  
              w = ivy.maximum(0.0, xx2 - xx1)  # maximum width
              h = ivy.maximum(0.0, yy2 - yy1)  # maximum height
              inter = w * h
              ovr = inter / (areas[i] + areas[order[1:]] - inter)
              inds = ivy.nonzero(ovr <= iou_threshold)[0]
  
              order = order[inds + 1]
  
          ret = ivy.array(keep)
  
      if len(ret) > 1 and scores is not None:
          ret = sorted(
              ret.flatten().tolist(),
              reverse=True,
              key=lambda x: (scores[x], -x),
          )
          ret = ivy.array(ret, dtype=ivy.int64).flatten()
  
      if change_id and len(ret) > 0:
          ret = ivy.array(nonzero[ret], dtype=ivy.int64).flatten()
  
      return ret.flatten()[:max_output_size]
  
imports: from typing import Optional, Tuple, Union, Sequence
  import ivy
  from ivy.utils.backend import current_backend
  from ivy.func_wrapper import handle_array_function, handle_partial_mixed_function, inputs_to_ivy_arrays, to_native_arrays_and_back, inputs_to_native_shapes, handle_out_argument, handle_nestable, handle_array_like_without_promotion, handle_device, handle_backend_invalid
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 36 for calling a global function with example usage: nms(boxes, scores, iou_threshold, max_output_size, score_threshold) and returns: ret