code: def to_float32(data: np.ndarray) -> np.ndarray:
      """Read an image and returns it as float32
  
      All arrays are rescaled to the range 0...1
      """
      if data.dtype == np.dtype("uint8"):
          data = data.astype("float32") / 255
      elif data.dtype == np.dtype("int8"):
          data = (data.astype("int16") + 128).astype("float32") / 255
      elif data.dtype == np.dtype("uint16"):
          data = data.astype("float32") / 65535
      elif data.dtype == np.dtype("int16"):
          data = (data.astype("float32") + 32768) / 65535
      elif data.dtype in [
          np.dtype("f"),
          np.dtype("float32"),
          np.dtype("float64"),
      ]:
          data = data.astype("float32")
      elif data.dtype == bool:
          data = data.astype("float32")
      else:
          raise Exception(f"Unknown image type: {data.dtype}")
  
      return data
  
file_path: calamari/calamari_ocr/utils/image.py
imports: from dataclasses import dataclass, field
  import numpy
  from PIL import Image
  from paiargparse import pai_dataclass, pai_meta
  import cv2
label_desc: Use image node_id 3 for calling a global function with example usage: to_float32(data) and returns: data