code: def align_ts_output(inputs, metainfo, device):
      bboxes = []
      labels = []
      scores = []
      for i, pred in enumerate(inputs):
          bboxes.append(pred["bbox"])
          labels.append(pred["class_label"])
          scores.append(pred["score"])
      pred_instances = InstanceData(metainfo=metainfo)
      pred_instances.bboxes = torch.tensor(
          bboxes, dtype=torch.float32, device=device
      )
      pred_instances.labels = torch.tensor(
          labels, dtype=torch.int64, device=device
      )
      pred_instances.scores = torch.tensor(
          scores, dtype=torch.float32, device=device
      )
      ts_data_sample = DetDataSample(pred_instances=pred_instances)
      return ts_data_sample
  
file_path: mmdetection/tools/deployment/test_torchserver.py
imports: import os
  from argparse import ArgumentParser
  import mmcv
  import requests
  import torch
  from mmengine.structures import InstanceData
  from mmdet.apis import inference_detector, init_detector
  from mmdet.registry import VISUALIZERS
  from mmdet.structures import DetDataSample
label_desc: Use image node_id 2 for calling a global function with example usage: align_ts_output(inputs, metainfo, device) and returns: ts_data_sample