code: def _build_train_sample(
      record: RecordType,
  ) -> Tuple[torch.Tensor, Dict[str, torch.Tensor]]:
      assert len(record.detection.label_ids) == len(
          record.detection.bboxes
      )
  
      image = im2tensor(record.img)
  
      # If no labels and bboxes are present, use as negative samples
      if len(record.detection.label_ids) == 0:
          target = torch.zeros((0, 6))
      else:
          labels = (
              tensor(record.detection.label_ids, dtype=torch.int64) - 1
          )
  
          img_width, img_height = record.width, record.height
          xyxys = [
              bbox.relative_xcycwh(img_width, img_height)
              for bbox in record.detection.bboxes
          ]
          boxes = tensor(xyxys, dtype=torch.float32)
  
          target = torch.zeros((len(labels), 6))
          target[:, 1:] = torch.cat([labels.unsqueeze(1), boxes], 1)
  
      return image, target
  
file_path: icevision/icevision/models/ultralytics/yolov5/dataloaders.py
imports: from icevision.imports import *
  from icevision.core import *
  from icevision.models.utils import *
label_desc: Use image node_id 2 for calling a global function with example usage: _build_train_sample(record) and returns: image,  target