code: def itk_image_to_dicom_seg(label, series_dir, template) -> str:
      output_file = tempfile.NamedTemporaryFile(suffix=".dcm").name
      meta_data = tempfile.NamedTemporaryFile(suffix=".json").name
      with open(meta_data, "w") as fp:
          json.dump(template, fp)
  
      command = "itkimage2segimage"
      args = [
          "--inputImageList",
          label,
          "--inputDICOMDirectory",
          series_dir,
          "--outputDICOM",
          output_file,
          "--inputMetadata",
          meta_data,
      ]
      run_command(command, args)
      os.unlink(meta_data)
      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 4 for calling a global function with example usage: itk_image_to_dicom_seg(label, series_dir, template) and returns: output_file