code: def _map_roles(
      messages: List[llama_types.ChatCompletionRequestMessage],
      role_map: Dict[str, str],
  ) -> List[Tuple[str, Optional[str]]]:
      """Map the message roles."""
      output: List[Tuple[str, Optional[str]]] = []
      for message in messages:
          role = message["role"]
          if role in role_map:
              output.append((role_map[role], message["content"]))
      return output
  
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 4 for calling a global function with example usage: _map_roles(messages, role_map) and returns: output