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","."]
docstr: Return a (ansi_code, ansi_name) tuple. (E.g. ``(44, 'ansiblue')``.) for
  a given (r,g,b) value.
docstr_tok: ["Return","a","(","ansi_code",",","ansi_name",")","tuple",".","(","E.g",".","``","(","44",",","'ansiblue","'",")","``",".",")","for","a","given","(","r",",","g",",","b",")","value","."]
code: def get_code(
      self, value: tuple[int, int, int], exclude: Sequence[str] = ()
  ) -> _ColorCodeAndName:
      """
      Return a (ansi_code, ansi_name) tuple. (E.g. ``(44, 'ansiblue')``.) for
      a given (r,g,b) value.
      """
      key: Hashable = (value, tuple(exclude))
      cache = self._cache
  
      if key not in cache:
          cache[key] = self._get(value, exclude)
  
      return cache[key]
  
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 2 for calling the _16ColorCache obj's underlying member method code with example usage: obj.get_code(value, exclude) and returns: cache