code: def batched_nms(
      predictions: torch.tensor,
      match_metric: str = "IOU",
      match_threshold: float = 0.5,
  ):
      """
      Apply non-maximum suppression to avoid detecting too many
      overlapping bounding boxes for a given object.
      Args:
          predictions: (tensor) The location preds for the image
              along with the class predscores, Shape: [num_boxes,5].
          match_metric: (str) IOU or IOS
          match_threshold: (float) The overlap thresh for
              match metric.
      Returns:
          A list of filtered indexes, Shape: [ ,]
      """
  
      scores = predictions[:, 4].squeeze()
      category_ids = predictions[:, 5].squeeze()
      keep_mask = torch.zeros_like(category_ids, dtype=torch.bool)
      for category_id in torch.unique(category_ids):
          curr_indices = torch.where(category_ids == category_id)[0]
          curr_keep_indices = nms(
              predictions[curr_indices], match_metric, match_threshold
          )
          keep_mask[curr_indices[curr_keep_indices]] = True
      keep_indices = torch.where(keep_mask)[0]
      # sort selected indices by their scores
      keep_indices = keep_indices[
          scores[keep_indices].sort(descending=True)[1]
      ].tolist()
      return keep_indices
  
imports: import logging
  from typing import List
  import torch
  from sahi.postprocess.utils import ObjectPredictionList, has_match, merge_object_prediction_pair
  from sahi.prediction import ObjectPrediction
  from sahi.utils.import_utils import check_requirements
label_desc: Use image node_id 1 for calling a global function with example usage: batched_nms(predictions, match_metric, match_threshold) and returns: keep_indices