class_docstr: Color palette for palette mapped images
  
  :param mode: The mode to use for the palette. See:
      :ref:`concept-modes`. Defaults to "RGB"
  :param palette: An optional palette. If given, it must be a bytearray,
      an array or a list of ints between 0-255. The list must consist of
      all channels for one color followed by the next color (e.g. RGBRGBRGB).
      Defaults to an empty palette.
class_docstr_tok: ["Color","palette","for","palette","mapped","images",":","param","mode",":","The","mode","to","use","for","the","palette",".","See",":",":","ref",":","`","concept-modes","`",".","Defaults","to","``","RGB","''",":","param","palette",":","An","optional","palette",".","If","given",",","it","must","be","a","bytearray",",","an","array","or","a","list","of","ints","between","0-255",".","The","list","must","consist","of","all","channels","for","one","color","followed","by","the","next","color","(","e.g",".","RGBRGBRGB",")",".","Defaults","to","an","empty","palette","."]
docstr: Convert palette to bytes.
  
  .. warning:: This method is experimental.
docstr_tok: ["Convert","palette","to","bytes",".","..","warning",":",":","This","method","is","experimental","."]
code: def tobytes(self):
      """Convert palette to bytes.
  
      .. warning:: This method is experimental.
      """
      if self.rawmode:
          msg = "palette contains raw palette data"
          raise ValueError(msg)
      if isinstance(self.palette, bytes):
          return self.palette
      arr = array.array("B", self.palette)
      return arr.tobytes()
  
imports: import array
  from .None import GimpGradientFile, GimpPaletteFile, ImageColor, PaletteFile
label_desc: Use image node_id 8 for calling the ImagePalette obj's underlying member method code with example usage: obj.tobytes() and returns: arr, self