code: def convert_raw_predictions(
      batch,
      raw_preds: torch.Tensor,
      records: Sequence[BaseRecord],
      detection_threshold: float,
      keep_images: bool = False,
  ) -> List[Prediction]:
      tensor_images, *_ = batch
      dets = raw_preds.detach().cpu().numpy()
      preds = []
      for det, record, tensor_image in zip(
          dets, records, tensor_images
      ):
          if detection_threshold > 0:
              scores = det[:, 4]
              keep = scores > detection_threshold
              det = det[keep]
  
          pred = BaseRecord(
              (
                  ScoresRecordComponent(),
                  ImageRecordComponent(),
                  InstancesLabelsRecordComponent(),
                  BBoxesRecordComponent(),
              )
          )
  
          pred.detection.set_class_map(record.detection.class_map)
          pred.detection.set_labels_by_id(det[:, 5].astype(int))
          pred.detection.set_bboxes(
              [BBox.from_xyxy(*xyxy) for xyxy in det[:, :4]]
          )
          pred.detection.set_scores(det[:, 4])
  
          if keep_images:
              record.set_img(tensor_to_image(tensor_image))
  
          preds.append(Prediction(pred=pred, ground_truth=record))
  
      return preds
  
file_path: icevision/icevision/models/ross/efficientdet/prediction.py
imports: from icevision.imports import *
  from icevision.utils import *
  from icevision.core import *
  from icevision.data import *
  from icevision.models.utils import _predict_from_dl
  from icevision.models.ross.efficientdet.dataloaders import *
  from effdet import DetBenchTrain, DetBenchPredict, unwrap_bench
  from icevision.models.inference import *
label_desc: Use image node_id 4 for calling a global function with example usage: convert_raw_predictions(batch, raw_preds, records, detection_threshold, keep_images) and returns: preds