code: def _emit_main_prologue(
      main_file,
      custom_prologue,
      workspace_bytes,
      data_linkage,
      compiled_models,
      interface_api,
      use_stack_allocator=True,
      debug_last_error=False,
  ):
      if use_stack_allocator:
          workspace_define = (
              f"#define WORKSPACE_SIZE ({workspace_bytes}"
          )
          if interface_api == "c":
              for compiled_model in compiled_models:
                  model = compiled_model.model
                  workspace_define += (
                      f" + TVMGEN_{model.name.upper()}_WORKSPACE_SIZE"
                  )
          # Add TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES because of memory alignment.
          workspace_define += " + TVM_RUNTIME_ALLOC_ALIGNMENT_BYTES)\n"
          main_file.write(workspace_define)
          _emit_data_linkage(main_file, data_linkage)
          main_file.write(
              "static uint8_t g_aot_memory[WORKSPACE_SIZE];\n"
          )
          main_file.write("tvm_workspace_t app_workspace;\n")
          main_file.write(
              """\n
  tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) {
      return StackMemoryManager_Allocate(&app_workspace, num_bytes, out_ptr);
  }
  tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
      return StackMemoryManager_Free(&app_workspace,ptr);
  }
          """
          )
      else:
          # An implementation is not needed for these if the stack allocator is not used
          main_file.write(
              """\n
  tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) {
      return kTvmErrorFunctionCallNotImplemented;
  }
  tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
      return kTvmErrorFunctionCallNotImplemented;
  }
              """
          )
      main_file.write(
          """\n
  void TVMPlatformAbort(tvm_crt_error_t code) { exit(-1); }
  void TVMLogf(const char* msg, ...) {
    va_list args;
    va_start(args, msg);
    vfprintf(stdout, msg, args);
    va_end(args);
  }
      """
      )
      if debug_last_error:
          main_file.write(
              """\n
  tvm_crt_error_t TVMPlatformTimerStart() {
    return kTvmErrorFunctionCallNotImplemented;
  }
  tvm_crt_error_t TVMPlatformTimerStop(double* elapsed_time_seconds) {
    return kTvmErrorFunctionCallNotImplemented;
  }
  const TVMModule* TVMSystemLibEntryPoint(void) { return NULL; }
  """
          )
      else:
          main_file.write(
              """\n
  TVM_DLL int TVMFuncRegisterGlobal(const char* name, TVMFunctionHandle f, int override) {}
  """
          )
      main_file.write("\nint main(){\n")
      main_file.write(custom_prologue)
  
imports: import contextlib
  import datetime
  import os
  import pathlib
  import re
  import subprocess
  import tarfile
  import logging
  from typing import Any, NamedTuple, Union, Tuple, Optional, List, Dict, Callable
  import numpy
  import tvm
  from tvm import relay
  from tvm import autotvm
  from tvm.contrib import utils, graph_executor
  from tvm.relay.backend import Executor, Runtime
  from tvm.relay.backend.utils import mangle_module_name
  from tvm.micro import export_model_library_format
  from tvm.micro.testing.utils import mlf_extract_workspace_size_bytes
label_desc: Use image node_id 4 for calling a global function with example usage: _emit_main_prologue(main_file, custom_prologue, workspace_bytes, data_linkage, compiled_models, interface_api, use_stack_allocator, debug_last_error) without return types