code: def draw_bounding_boxes_and_save(
      orig_img_paths,
      output_img_paths,
      all_predictions,
      class_labels,
      iou_threshold=0.5,
  ):
      color_dict = {
          label: tuple(
              (
                  ((i + 1) * 50) % 256,
                  ((i + 1) * 100) % 256,
                  ((i + 1) * 150) % 256,
              )
          )
          for i, label in enumerate(class_labels)
      }
      font = cv2.FONT_HERSHEY_SIMPLEX
  
      def is_bright_color(color):
          r, g, b = color
          brightness = (r * 299 + g * 587 + b * 114) / 1000
          return brightness > 127
  
      for img_idx, (
          orig_img_path,
          output_img_path,
          predictions,
      ) in enumerate(
          zip(orig_img_paths, output_img_paths, all_predictions)
      ):
          predictions = np.array(predictions)
          orig_img = (
              cv2.imread(orig_img_path)
              if not isinstance(orig_img_path, np.ndarray)
              else cv2.imdecode(orig_img_path, 1)
          )
          height, width, _ = orig_img.shape
          box_thickness = int((height + width) / 400)
          font_scale = (height + width) / 2500
  
          grouped_preds = defaultdict(list)
          object_count = defaultdict(int)
  
          for pred_np in predictions:
              grouped_preds[int(pred_np[-1])].append(pred_np)
  
          def draw_box_and_label(pred, color):
              x1, y1, x2, y2, conf, _ = pred
              x1, y1, x2, y2 = map(int, (x1, y1, x2, y2))
              cv2.rectangle(
                  orig_img, (x1, y1), (x2, y2), color, box_thickness
              )
              label = f"{class_labels[class_id]} {conf:.2f}"
              text_size, _ = cv2.getTextSize(label, font, font_scale, 1)
              label_y, bg_y = (
                  (y1 - 4, y1 - text_size[1] - 4)
                  if y1 - text_size[1] - 4 > 0
                  else (y1 + text_size[1], y1)
              )
              cv2.rectangle(
                  orig_img,
                  (x1, bg_y),
                  (x1 + text_size[0], bg_y + text_size[1]),
                  color,
                  -1,
              )
              font_color = (
                  (0, 0, 0)
                  if is_bright_color(color)
                  else (255, 255, 255)
              )
              cv2.putText(
                  orig_img,
                  label,
                  (x1, label_y),
                  font,
                  font_scale,
                  font_color,
                  1,
                  cv2.LINE_AA,
              )
  
          for class_id, pred_list in grouped_preds.items():
              pred_list = np.array(pred_list)
              while len(pred_list) > 0:
                  max_conf_idx = np.argmax(pred_list[:, 4])
                  max_conf_pred = pred_list[max_conf_idx]
                  pred_list = np.delete(pred_list, max_conf_idx, axis=0)
                  color = color_dict[class_labels[class_id]]
                  draw_box_and_label(max_conf_pred, color)
                  object_count[class_labels[class_id]] += 1
                  iou_scores = box_iou(
                      np.array([max_conf_pred[:4]]), pred_list[:, :4]
                  )
                  low_iou_indices = np.where(
                      iou_scores[0] < iou_threshold
                  )[0]
                  pred_list = pred_list[low_iou_indices]
                  for low_conf_pred in pred_list:
                      draw_box_and_label(low_conf_pred, color)
  
          print(f"Image {img_idx + 1}:")
          print("Objects detected:")
          for obj, count in object_count.items():
              print(f"- {obj}: {count}")
  
          cv2.imwrite(output_img_path, orig_img)
          print(f"saved detections at {output_img_path}")
  
imports: from tinygrad.nn import Conv2d, BatchNorm2d
  from tinygrad.tensor import Tensor
  import numpy
  from itertools import chain
  from pathlib import Path
  import cv2
  from collections import defaultdict
  import time, sys
  from tinygrad.helpers import fetch
  from tinygrad.nn.state import safe_load, load_state_dict
label_desc: Use image node_id 8 for calling a global function with example usage: draw_bounding_boxes_and_save(orig_img_paths, output_img_paths, all_predictions, class_labels, iou_threshold) and returns: unknown