code: def _format_chatglm3(
      system_message: str,
      messages: List[Tuple[str, Optional[str]]],
      sep: str,
  ) -> str:
      """Format the prompt with the chatglm3 style."""
      ret = ""
      if system_message:
          ret += system_message
      for role, message in messages:
          if message:
              ret += role + "\n" + " " + message
          else:
              ret += role
      return ret
  
imports: from __future__ import annotations
  import os
  import json
  import ctypes
  import dataclasses
  from typing import Any, Dict, Iterator, List, Optional, Tuple, Union, Protocol
  import llama_cpp.llama
  import llama_cpp.llama_types
  import llama_cpp.llama_grammar
  from ._utils import suppress_stdout_stderr
label_desc: Use image node_id 11 for calling a global function with example usage: _format_chatglm3(system_message, messages, sep) and returns: ret