code: def cast_to_framework_io_dtype(var, is_output):
      if var.dtype == types.fp32:
          return ft.ArrayFeatureType.ArrayDataType.FLOAT32
      elif var.dtype == types.int32:
          return ft.ArrayFeatureType.ArrayDataType.INT32
      elif var.dtype == types.fp16:
          return ft.ArrayFeatureType.ArrayDataType.FLOAT16
      else:
          ioname = "Output " if is_output else "Input "
          ioname2 = "outputs" if is_output else "inputs"
          raise NotImplementedError(
              ioname
              + var.name
              + " has data type "
              + builtin_to_string(var.dtype)
              + ". ML Program models only support fp32 and int32 "
              + ioname2
              + "."
          )
  
imports: import os
  import numpy
  import coremltools.proto.FeatureTypes_pb2
  import coremltools.proto.MIL_pb2
  from coremltools.converters.mil.mil import types
  from coremltools.converters.mil.mil.types import BUILTIN_TO_PROTO_TYPES, builtin_to_string, numpy_type_to_builtin_type, type_to_builtin_type
  from coremltools.converters.mil.mil.types.type_mapping import np_val_to_py_type
  from coremltools.models.utils import _WEIGHTS_DIR_NAME, _WEIGHTS_FILE_NAME
label_desc: Use image node_id 20 for calling a global function with example usage: cast_to_framework_io_dtype(var, is_output) and returns: ft, ft, ft