code: def load_image_to_tensor(path_file: str, device: Device) -> Tensor:
      # load the file and decodes using kornia_rs. Internally it uses a package that
      # combines image-rs a self maintained version of the dlpack-rs. After the decoding,
      # the obtained stream bits are encapusalted to a cv::Tensor data structure without
      # memory ownership and passed as PyCapsule from rust to python.
      cv_tensor = kornia_rs.read_image_rs(path_file)
      # for convenience use the torch dlpack parser to get a zero copy torch.Tensor
      # TODO: evaluate other potential API so that we can return in numpy, jax, mxnet since
      # the kornia_rs cv::Tensor has this ability.
      th_tensor = dlpack.from_dlpack(cv_tensor)  # HxWx3
      # move the tensor to the desired device, move the data layout to CHW and clone
      # to return an owned data tensor.
      dev = (
          device
          if isinstance(device, torch.device) or device is None
          else torch.device(device)
      )
      return th_tensor.to(device=dev).permute(2, 0, 1).clone()
  
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 1 for calling a global function with example usage: load_image_to_tensor(path_file, device) and returns: th_tensor