class_docstr: Cache which maps (r, g, b) tuples to 16 ansi colors.
  
  :param bg: Cache for background colors, instead of foreground.
class_docstr_tok: ["Cache","which","maps","(","r",",","g",",","b",")","tuples","to","16","ansi","colors",".",":","param","bg",":","Cache","for","background","colors",",","instead","of","foreground","."]
code: def _get(
      self, value: tuple[int, int, int], exclude: Sequence[str] = ()
  ) -> _ColorCodeAndName:
      r, g, b = value
      match = _get_closest_ansi_color(r, g, b, exclude=exclude)
  
      # Turn color name into code.
      if self.bg:
          code = BG_ANSI_COLORS[match]
      else:
          code = FG_ANSI_COLORS[match]
  
      return code, match
  
imports: from __future__ import annotations
  import io
  import os
  import sys
  from typing import Callable, Dict, Hashable, Iterable, Sequence, TextIO, Tuple
  from prompt_toolkit.cursor_shapes import CursorShape
  from prompt_toolkit.data_structures import Size
  from prompt_toolkit.output import Output
  from prompt_toolkit.styles import ANSI_COLOR_NAMES, Attrs
  from prompt_toolkit.utils import is_dumb_terminal
  from .color_depth import ColorDepth
  from .flush_stdout import flush_stdout
label_desc: Use image node_id 3 for calling the _16ColorCache obj's underlying member method code with example usage: obj._get(value, exclude) and returns: code,  match