code: def _predict_batch(
      model: nn.Module,
      batch: Sequence[torch.Tensor],
      records: Sequence[BaseRecord],
      detection_threshold: float = 0.25,
      nms_iou_threshold: float = 0.45,
      keep_images: bool = False,
      device: Optional[torch.device] = None,
  ) -> List[Prediction]:
      # device issue addressed on discord: https://discord.com/channels/735877944085446747/770279401791160400/832361687855923250
      if device is not None:
          raise ValueError(
              "For YOLOv5 device can only be specified during model creation, "
              "for more info take a look at the discussion here: "
              "https://discord.com/channels/735877944085446747/770279401791160400/832361687855923250"
          )
      grid = model.model[-1].grid[-1]
      # if `grid.numel() == 1` it means the grid isn't initialized yet and we can't
      # trust it's device (will always be CPU)
      device = grid.device if grid.numel() > 1 else model_device(model)
  
      batch = batch[0].to(device)
      model = model.eval().to(device)
  
      raw_preds = model(batch)[0]
      return convert_raw_predictions(
          batch=batch,
          raw_preds=raw_preds,
          records=records,
          detection_threshold=detection_threshold,
          nms_iou_threshold=nms_iou_threshold,
          keep_images=keep_images,
      )
  
file_path: icevision/icevision/models/ultralytics/yolov5/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.ultralytics.yolov5.dataloaders import *
  from yolov5.utils.general import non_max_suppression
  from icevision.models.inference import *
label_desc: Use image node_id 1 for calling a global function with example usage: _predict_batch(model, batch, records, detection_threshold, nms_iou_threshold, keep_images, device) and returns: convert_raw_predictions