code: def save_result_df(
      pred: Iterable,
      data: Union[pd.DataFrame, Dict],
      detection_classes: List[str],
      result_path: Optional[str] = None,
  ):
      """
      Saving detection results in pd.DataFrame format (per image)
  
      Parameters
      ----------
      pred
          List containing detection results for one image
      data
          pandas data frame or dict containing the image information to be tested
      result_path
          path to save result
      detection_classes
          all available classes for this detection
      Returns
      -------
      The detection results as pandas DataFrame
      """
      if isinstance(data, dict):
          image_names = data["image"]
      else:
          image_names = data["image"].to_list()
      results = []
      idx2classname = {
          i: classname
          for (i, classname) in enumerate(detection_classes)
      }
  
      for image_pred, image_name in zip(pred, image_names):
          box_info = []
          N_preds = len(image_pred["bboxes"])
          for i in range(N_preds):
              box_info.append(
                  {
                      "class": idx2classname[
                          image_pred["labels"][i].item()
                      ],
                      "class_id": image_pred["labels"][i].item(),
                      "bbox": image_pred["bboxes"][i].tolist(),
                      "score": image_pred["scores"][i].item(),
                  }
              )
          results.append([image_name, box_info])
      result_df = pd.DataFrame(results, columns=["image", "bboxes"])
      if result_path:
          result_df.to_csv(result_path, index=False)
          logger.info(
              "Saved detection results to {}".format(result_path)
          )
      return result_df
  
imports: import json
  import logging
  import os
  import warnings
  from pathlib import Path
  from typing import Dict, Iterable, List, Optional, Union
  import defusedxml.ElementTree
  import numpy
  import pandas
  import PIL
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  from ..constants import BBOX, LABEL, MAP, MAP_50, MAP_75, MAP_LARGE, MAP_MEDIUM, MAP_SMALL, MAR_1, MAR_10, MAR_100, MAR_LARGE, MAR_MEDIUM, MAR_SMALL, MEAN_AVERAGE_PRECISION
  from .download import download, is_url
label_desc: Use image node_id 35 for calling a global function with example usage: save_result_df(pred, data, detection_classes, result_path) and returns: result_df