def _adjust_main_outputs(func):
    """Adjust the outputs in the main func to make sure they have Core ML I/O supported types."""
    _IO_SUPPORTED_TYPES = _get_io_supported_types(func.opset_version, func.input_types)

    new_outputs = []
    for output_var in func.outputs:
        output_type = output_var.sym_type
        # classify outputs contains type int64 output variables, which should not be casted.
        if (
            (types.is_tensor(output_type) or types.is_scalar(output_type))
            and output_var.dtype not in _IO_SUPPORTED_TYPES
            and output_var.op.op_type != "classify"
        ):
            output_dtype_str = types.builtin_to_string(output_var.dtype)
            target_dtype = "int32" if types.is_int(output_var.dtype) else "fp32"
            logger.warning(
                f"\nOutput '{output_var.name}' is of dtype {output_dtype_str}. The "
                f"Core ML runtime does not support outputs with this dtype (supported "
                f"dtypes are: {_IO_SUPPORTED_TYPES}). This output will changed to "
                f"{target_dtype} by adding a cast op at the end of the program.\n"
            )
            if output_var.dtype == types.fp16:
                logger.warning(
                    "fp16 dtype output is supported if function.opset_version is chosen to be at "
                    "least iOS16/macOS13.\n"
                )

            output_var_name = output_var.name
            output_var.set_name(f"{output_var_name}__pre__output__{target_dtype}__cast")
            old_output_var = output_var
            output_var = mb.cast(x=output_var, dtype=target_dtype)
            output_var.set_name(output_var_name)
            Block._copy_scope_info(old_output_var, output_var)
        new_outputs.append(output_var)
    func.set_outputs(new_outputs)
Adjust the outputs in the main func to make sure they have Core ML I/O supported types.
coremltools/converters/mil/backend/mil/passes/adjust_io_to_supported_types.py