code: def predict_labeled_dataset(opts, **kwargs):
      device = getattr(opts, "dev.device", torch.device("cpu"))
  
      # set-up data loaders
      test_loader = create_test_loader(opts)
  
      # set-up the model
      model = get_model(opts)
      model.eval()
      model.info()
      model = model.to(device=device)
  
      if model.training:
          logger.warning(
              "Model is in training mode. Switching to evaluation mode"
          )
          model.eval()
  
      with torch.no_grad():
          predictions = []
          for img_idx, batch in tqdm(enumerate(test_loader)):
              samples, targets = batch["samples"], batch["targets"]
  
              batch_size = get_batch_size(samples)
              if isinstance(samples, Dict):
                  assert (
                      "image" in samples
                  ), "samples does not contain image key"
                  input_tensor = samples["image"]
              else:
                  input_tensor = samples
  
              assert (
                  batch_size == 1
              ), "We recommend to run detection evaluation with a batch size of 1"
  
              orig_w = targets["image_width"].item()
              orig_h = targets["image_height"].item()
              image_id = targets["image_id"].item()
  
              boxes, labels, scores, masks = predict_and_save(
                  opts=opts,
                  input_tensor=input_tensor,
                  model=model,
                  device=device,
                  is_coco_evaluation=True,
                  orig_w=orig_w,
                  orig_h=orig_h,
              )
  
              predictions.append(
                  [image_id, boxes, labels, scores, masks]
              )
  
          compute_quant_scores(opts=opts, predictions=predictions)
  
imports: import glob
  import os.path
  from typing import Dict, List, Optional
  import numpy
  import torch
  from PIL import Image
  from torch import Tensor, nn
  from torch.nn import functional
  from torchvision.transforms import functional
  from tqdm import tqdm
  from common import SUPPORTED_IMAGE_EXTNS
  from cvnets import get_model
  from cvnets.models.detection import DetectionPredTuple
  from data import create_test_loader
  from data.datasets.detection.coco_base import COCODetection
  from engine.detection_utils.coco_map import compute_quant_scores
  from engine.utils import autocast_fn, get_batch_size
  from options.opts import get_training_arguments
  from utils import logger, resources
  from utils.common_utils import create_directories, device_setup
  from utils.ddp_utils import is_master
  from utils.download_utils import get_local_path
  from utils.tensor_utils import image_size_from_opts, to_numpy
  from utils.visualization_utils import draw_bounding_boxes
label_desc: Use image node_id 2 for calling a global function with example usage: predict_labeled_dataset(opts) without return types