code: def format_llama2(
      messages: List[llama_types.ChatCompletionRequestMessage],
      **kwargs: Any,
  ) -> ChatFormatterResponse:
      _system_template = "<s>[INST] <<SYS>>\n{system_message}\n<</SYS>>"
      _roles = dict(user="<s>[INST]", assistant="[/INST]")
      _messages = _map_roles(messages, _roles)
      system_message = _get_system_message(messages)
      if system_message:
          system_message = _system_template.format(
              system_message=system_message
          )
      _prompt = (
          _format_llama2(system_message, _messages, " ", "</s>")
          + "[/INST]"
      )
      return ChatFormatterResponse(prompt=_prompt)
  
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 18 for calling a global function with example usage: format_llama2(messages) and returns: ChatFormatterResponse