code: def escape(m: Match[str]) -> str:
      all, tail = m.group(0, 1)
      assert all.startswith("\\")
      esc = simple_escapes.get(tail)
      if esc is not None:
          return esc
      if tail.startswith("x"):
          hexes = tail[1:]
          if len(hexes) < 2:
              raise ValueError(
                  "invalid hex string escape ('\\%s')" % tail
              )
          try:
              i = int(hexes, 16)
          except ValueError:
              raise ValueError(
                  "invalid hex string escape ('\\%s')" % tail
              ) from None
      else:
          try:
              i = int(tail, 8)
          except ValueError:
              raise ValueError(
                  "invalid octal string escape ('\\%s')" % tail
              ) from None
      return chr(i)
  
imports: import re
  from typing import Dict, Match
label_desc: Use image node_id 1 for calling a global function with example usage: escape(m) and returns: chr, esc