code: def dicom_seg_to_itk_image(label, output_ext=".seg.nrrd"):
      filename = (
          label
          if not os.path.isdir(label)
          else os.path.join(label, os.listdir(label)[0])
      )
  
      dcm = pydicom.dcmread(filename)
      reader = pydicom_seg.MultiClassReader()
      result = reader.read(dcm)
      image = result.image
  
      output_file = tempfile.NamedTemporaryFile(suffix=output_ext).name
  
      SimpleITK.WriteImage(image, output_file, True)
  
      if not os.path.exists(output_file):
          logger.warning(
              f"Failed to convert DICOM-SEG {label} to ITK image"
          )
          return None
  
      logger.info(f"Result/Output File: {output_file}")
      return output_file
  
imports: import json
  import logging
  import os
  import pathlib
  import tempfile
  import time
  import numpy
  import pydicom
  import pydicom_seg
  import SimpleITK
  from monai.transforms import LoadImage
  from pydicom.filereader import dcmread
  from monailabel.datastore.utils.colors import GENERIC_ANATOMY_COLORS
  from monailabel.transform.writer import write_itk
  from monailabel.utils.others.generic import run_command
label_desc: Use image node_id 5 for calling a global function with example usage: dicom_seg_to_itk_image(label, output_ext) and returns: output_file, None