code: def load_image(
      path_file: str | Path,
      desired_type: ImageLoadType,
      device: Device = "cpu",
  ) -> Tensor:
      """Read an image file and decode using the Kornia Rust backend.
  
      Args:
          path_file: Path to a valid image file.
          desired_type: the desired image type, defined by color space and dtype.
          device: the device where you want to get your image placed.
  
      Return:
          Image tensor with shape :math:`(3,H,W)`.
      """
      if kornia_rs is None:  # pragma: no cover
          raise ModuleNotFoundError(
              "The io API is not available: `pip install kornia_rs` in a Linux system."
          )
  
      if isinstance(path_file, Path):
          path_file = str(path_file)
  
      KORNIA_CHECK(
          os.path.isfile(path_file), f"Invalid file: {path_file}"
      )
      image: Tensor = load_image_to_tensor(path_file, device)  # CxHxW
  
      if desired_type == ImageLoadType.UNCHANGED:
          return image
      elif desired_type == ImageLoadType.GRAY8:
          if image.shape[0] == 1 and image.dtype == torch.uint8:
              return image
          elif image.shape[0] == 3 and image.dtype == torch.uint8:
              gray8 = rgb_to_grayscale(image)
              return gray8
          elif image.shape[0] == 4 and image.dtype == torch.uint8:
              gray32 = rgb_to_grayscale(rgba_to_rgb(to_float32(image)))
              return to_uint8(gray32)
  
      elif desired_type == ImageLoadType.RGB8:
          if image.shape[0] == 3 and image.dtype == torch.uint8:
              return image
          elif image.shape[0] == 1 and image.dtype == torch.uint8:
              rgb8 = grayscale_to_rgb(image)
              return rgb8
  
      elif desired_type == ImageLoadType.RGBA8:
          if image.shape[0] == 3 and image.dtype == torch.uint8:
              rgba32 = rgb_to_rgba(to_float32(image), 0.0)
              return to_uint8(rgba32)
  
      elif desired_type == ImageLoadType.GRAY32:
          if image.shape[0] == 1 and image.dtype == torch.uint8:
              return to_float32(image)
          elif image.shape[0] == 3 and image.dtype == torch.uint8:
              gray32 = rgb_to_grayscale(to_float32(image))
              return gray32
          elif image.shape[0] == 4 and image.dtype == torch.uint8:
              gray32 = rgb_to_grayscale(rgba_to_rgb(to_float32(image)))
              return gray32
  
      elif desired_type == ImageLoadType.RGB32:
          if image.shape[0] == 3 and image.dtype == torch.uint8:
              return to_float32(image)
          elif image.shape[0] == 1 and image.dtype == torch.uint8:
              rgb32 = grayscale_to_rgb(to_float32(image))
              return rgb32
  
      raise NotImplementedError(f"Unknown type: {desired_type}")
  
file_path: kornia/kornia/io/io.py
imports: from __future__ import annotations
  import os
  from enum import Enum
  from pathlib import Path
  import torch
  from torch.utils import dlpack
  from kornia.color import rgb_to_grayscale, rgba_to_rgb
  from kornia.color.gray import grayscale_to_rgb
  from kornia.color.rgb import rgb_to_rgba
  from kornia.core import Device, Tensor
  from kornia.core.check import KORNIA_CHECK
label_desc: Use image node_id 4 for calling a global function with example usage: load_image(path_file, desired_type, device) and returns: image, image, gray8, image, to_uint8, rgb8, to_uint8, to_float32, gray32, to_float32, gray32, rgb32