docs: def write_xpm(matrix, version, out, scale=1, border=None, color='#000',
                background='#fff', name='img'):
      """\
      Serializes the matrix as `XPM <https://en.wikipedia.org/wiki/X_PixMap>`_ image.
  
      :param matrix: The matrix to serialize.
      :param int version: The (Micro) QR code version
      :param out: Filename or a file-like object supporting to write binary data.
      :param scale: Indicates the size of a single module (default: 1 which
              corresponds to 1 x 1 pixel per module).
      :param int border: Integer indicating the size of the quiet zone.
              If set to ``None`` (default), the recommended border size
              will be used (``4`` for QR Codes, ``2`` for a Micro QR Codes).
      :param color: Color of the modules (default: black). The
              color can be provided as ``(R, G, B)`` tuple, as web color name
              (like "red") or in hexadecimal format (``#RGB`` or ``#RRGGBB``).
      :param background: Optional background color (default: white).
              See `color` for valid values. ``None`` indicates a transparent
              background.
      :param str name: Name of the image (must be a valid C-identifier).
              Default: "img".
      """
      row_iter = matrix_iter(matrix, version, scale, border)
      width, height = get_symbol_size(version, scale=scale, border=border)
      stroke_color = colors.color_to_rgb_hex(color)
      bg_color = colors.color_to_rgb_hex(background) if background is not None else 'None'
      with writable(out, 'wt') as f:
          write = f.write
          write('/* XPM */\n'
                'static char *{0}[] = {{\n'
                '"{1} {2} 2 1",\n'
                '"  c {3}",\n'
                '"X c {4}",\n'.format(name, width, height, bg_color, stroke_color))
          for i, row in enumerate(row_iter):
              write(''.join(chain(['"'],  (' ' if not b else 'X' for b in row),
                                  ['"{0}\n'.format(',' if i < height - 1 else '')])))
          write('};\n')