code: def prepare_yolov5_input(
      im_: PILImage.Image,
      size: int | tuple[int, int] = (640, 640),
      auto: bool = False,
      device: str = "cpu",
      fp16: bool = False,
      stride: int = 32,
  ) -> TensorContainer:
      p = torch.empty(1, device=torch.device(device))
      # Automatic Mixed Precision (AMP) inference
      autocast = fp16 and p.device.type != "cpu"
  
      im0 = np.asarray(exif_transpose(im_))
      # padded resize
      im, _, _ = letterbox(im0, size, stride=stride, auto=auto)
      im = im.transpose((2, 0, 1))[::-1]  # HWC to CHW, BGR to RGB
      im = np.ascontiguousarray(im)  # contiguous
  
      im = torch.from_numpy(im).to(p.device)
      im = im.half() if fp16 else im.float()  # unit8 to fp16/fp32
      im /= 255  # 0-255 to 0.0-1.0
      if len(im.shape) == 3:
          im = im[None]  # extends to batch_dim
  
      return TensorContainer(im, im0, autocast)
  
imports: from __future__ import annotations
  import json
  import os
  import time
  import typing
  from pathlib import Path
  import attr
  import cv2
  import numpy
  import torch
  import torchvision
  from PIL import Image
label_desc: Use image node_id 3 for calling a global function with example usage: prepare_yolov5_input(im_, size, auto, device, fp16, stride) and returns: TensorContainer