code: def batched_nmm(
      object_predictions_as_tensor: torch.tensor,
      match_metric: str = "IOU",
      match_threshold: float = 0.5,
  ):
      """
      Apply non-maximum merging per category to avoid detecting too many
      overlapping bounding boxes for a given object.
      Args:
          object_predictions_as_tensor: (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:
          keep_to_merge_list: (Dict[int:List[int]]) mapping from prediction indices
          to keep to a list of prediction indices to be merged.
      """
      category_ids = object_predictions_as_tensor[:, 5].squeeze()
      keep_to_merge_list = {}
      for category_id in torch.unique(category_ids):
          curr_indices = torch.where(category_ids == category_id)[0]
          curr_keep_to_merge_list = nmm(
              object_predictions_as_tensor[curr_indices],
              match_metric,
              match_threshold,
          )
          curr_indices_list = curr_indices.tolist()
          for (
              curr_keep,
              curr_merge_list,
          ) in curr_keep_to_merge_list.items():
              keep = curr_indices_list[curr_keep]
              merge_list = [
                  curr_indices_list[curr_merge_ind]
                  for curr_merge_ind in curr_merge_list
              ]
              keep_to_merge_list[keep] = merge_list
      return keep_to_merge_list
  
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 5 for calling a global function with example usage: batched_nmm(object_predictions_as_tensor, match_metric, match_threshold) and returns: keep_to_merge_list