code: def results_from_detections(
      detections: Tensor, format: str | BoundingBoxDataFormat
  ) -> list[ObjectDetectorResult]:
      """Convert a detection tensor to a list of :py:class:`ObjectDetectorResult`.
  
      Args:
          detections: tensor with shape :math:`(D, 6)`, where :math:`D` is the number of detections in the given image,
              :math:`6` represents class id, score, and `xywh` bounding box.
  
      Returns:
          list of :py:class:`ObjectDetectorResult`.
      """
      KORNIA_CHECK_SHAPE(detections, ["D", "6"])
  
      if isinstance(format, str):
          format = BoundingBoxDataFormat[format.upper()]
  
      results: list[ObjectDetectorResult] = []
      for det in detections:
          det = det.squeeze().tolist()
          if len(det) != 6:
              continue
          results.append(
              ObjectDetectorResult(
                  class_id=int(det[0]),
                  confidence=det[1],
                  bbox=BoundingBox(
                      data=(det[2], det[3], det[4], det[5]),
                      data_format=format,
                  ),
              )
          )
      return results
  
imports: from __future__ import annotations
  from dataclasses import dataclass
  from enum import Enum
  from typing import Optional
  import torch
  from kornia.core import Module, Tensor, concatenate
  from kornia.core.check import KORNIA_CHECK_SHAPE
  from kornia.image.base import ImageSize
label_desc: Use image node_id 1 for calling a global function with example usage: results_from_detections(detections, format) and returns: results