code: def itk_image_to_metatensor(
      image,
      channel_dim: str | int | None = None,
      dtype: DtypeLike | torch.dtype = float,
  ) -> MetaTensor:
      """
      Converts an ITK image to a MetaTensor object.
  
      Args:
          image: The ITK image to be converted.
          channel_dim: the channel dimension of the input image, default is None.
              This is used to set original_channel_dim in the metadata, EnsureChannelFirst reads this field.
              If None, the channel_dim is inferred automatically.
              If the input array doesn't have a channel dim, this value should be ``'no_channel'``.
          dtype: output dtype, defaults to the Python built-in `float`.
  
      Returns:
          A MetaTensor object containing the array data and metadata in ChannelFirst format.
      """
      reader = ITKReader(
          affine_lps_to_ras=False, channel_dim=channel_dim
      )
      image_array, meta_data = reader.get_data(image)
      image_array = convert_to_dst_type(
          image_array, dst=image_array, dtype=dtype
      )[0]
      metatensor = MetaTensor.ensure_torch_and_prune_meta(
          image_array, meta_data
      )
      metatensor = EnsureChannelFirst(channel_dim=channel_dim)(
          metatensor
      )
  
      return cast(MetaTensor, metatensor)
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, cast
  import numpy
  import torch
  from monai.config.type_definitions import DtypeLike
  from monai.data import ITKReader, ITKWriter
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import orientation_ras_lps
  from monai.transforms import EnsureChannelFirst
  from monai.utils import MetaKeys, SpaceKeys, convert_to_dst_type, optional_import
label_desc: Use image node_id 1 for calling a global function with example usage: itk_image_to_metatensor(image, channel_dim, dtype) and returns: cast