code: def table(
      ax,
      cellText=None,
      cellColours=None,
      cellLoc="right",
      colWidths=None,
      rowLabels=None,
      rowColours=None,
      rowLoc="left",
      colLabels=None,
      colColours=None,
      colLoc="center",
      loc="bottom",
      bbox=None,
      edges="closed",
      **kwargs,
  ):
      """
      Add a table to an `~.axes.Axes`.
  
      At least one of *cellText* or *cellColours* must be specified. These
      parameters must be 2D lists, in which the outer lists define the rows and
      the inner list define the column values per row. Each row must have the
      same number of elements.
  
      The table can optionally have row and column headers, which are configured
      using *rowLabels*, *rowColours*, *rowLoc* and *colLabels*, *colColours*,
      *colLoc* respectively.
  
      For finer grained control over tables, use the `.Table` class and add it to
      the Axes with `.Axes.add_table`.
  
      Parameters
      ----------
      cellText : 2D list of str, optional
          The texts to place into the table cells.
  
          *Note*: Line breaks in the strings are currently not accounted for and
          will result in the text exceeding the cell boundaries.
  
      cellColours : 2D list of colors, optional
          The background colors of the cells.
  
      cellLoc : {'right', 'center', 'left'}
          The alignment of the text within the cells.
  
      colWidths : list of float, optional
          The column widths in units of the axes. If not given, all columns will
          have a width of *1 / ncols*.
  
      rowLabels : list of str, optional
          The text of the row header cells.
  
      rowColours : list of colors, optional
          The colors of the row header cells.
  
      rowLoc : {'left', 'center', 'right'}
          The text alignment of the row header cells.
  
      colLabels : list of str, optional
          The text of the column header cells.
  
      colColours : list of colors, optional
          The colors of the column header cells.
  
      colLoc : {'center', 'left', 'right'}
          The text alignment of the column header cells.
  
      loc : str, default: 'bottom'
          The position of the cell with respect to *ax*. This must be one of
          the `~.Table.codes`.
  
      bbox : `.Bbox` or [xmin, ymin, width, height], optional
          A bounding box to draw the table into. If this is not *None*, this
          overrides *loc*.
  
      edges : {'closed', 'open', 'horizontal', 'vertical'} or substring of 'BRTL'
          The cell edges to be drawn with a line. See also
          `~.Cell.visible_edges`.
  
      Returns
      -------
      `~matplotlib.table.Table`
          The created table.
  
      Other Parameters
      ----------------
      **kwargs
          `.Table` properties.
  
      %(Table:kwdoc)s
      """
  
      if cellColours is None and cellText is None:
          raise ValueError(
              'At least one argument from "cellColours" or '
              '"cellText" must be provided to create a table.'
          )
  
      # Check we have some cellText
      if cellText is None:
          # assume just colours are needed
          rows = len(cellColours)
          cols = len(cellColours[0])
          cellText = [[""] * cols] * rows
  
      rows = len(cellText)
      cols = len(cellText[0])
      for row in cellText:
          if len(row) != cols:
              raise ValueError(
                  f"Each row in 'cellText' must have {cols} " "columns"
              )
  
      if cellColours is not None:
          if len(cellColours) != rows:
              raise ValueError(f"'cellColours' must have {rows} rows")
          for row in cellColours:
              if len(row) != cols:
                  raise ValueError(
                      "Each row in 'cellColours' must have "
                      f"{cols} columns"
                  )
      else:
          cellColours = ["w" * cols] * rows
  
      # Set colwidths if not given
      if colWidths is None:
          colWidths = [1.0 / cols] * cols
  
      # Fill in missing information for column
      # and row labels
      rowLabelWidth = 0
      if rowLabels is None:
          if rowColours is not None:
              rowLabels = [""] * rows
              rowLabelWidth = colWidths[0]
      elif rowColours is None:
          rowColours = "w" * rows
  
      if rowLabels is not None:
          if len(rowLabels) != rows:
              raise ValueError(f"'rowLabels' must be of length {rows}")
  
      # If we have column labels, need to shift
      # the text and colour arrays down 1 row
      offset = 1
      if colLabels is None:
          if colColours is not None:
              colLabels = [""] * cols
          else:
              offset = 0
      elif colColours is None:
          colColours = "w" * cols
  
      # Set up cell colours if not given
      if cellColours is None:
          cellColours = ["w" * cols] * rows
  
      # Now create the table
      table = Table(ax, loc, bbox, **kwargs)
      table.edges = edges
      height = table._approx_text_height()
  
      # Add the cells
      for row in range(rows):
          for col in range(cols):
              table.add_cell(
                  row + offset,
                  col,
                  width=colWidths[col],
                  height=height,
                  text=cellText[row][col],
                  facecolor=cellColours[row][col],
                  loc=cellLoc,
              )
      # Do column labels
      if colLabels is not None:
          for col in range(cols):
              table.add_cell(
                  0,
                  col,
                  width=colWidths[col],
                  height=height,
                  text=colLabels[col],
                  facecolor=colColours[col],
                  loc=colLoc,
              )
  
      # Do row labels
      if rowLabels is not None:
          for row in range(rows):
              table.add_cell(
                  row + offset,
                  -1,
                  width=rowLabelWidth or 1e-15,
                  height=height,
                  text=rowLabels[row],
                  facecolor=rowColours[row],
                  loc=rowLoc,
              )
          if rowLabelWidth == 0:
              table.auto_set_column_width(-1)
  
      ax.add_table(table)
      return table
  
imports: import numpy
  from .None import _api, _docstring
  from .artist import Artist, allow_rasterization
  from .patches import Rectangle
  from .text import Text
  from .transforms import Bbox
  from .path import Path
label_desc: Use image node_id 1 for calling a global function with example usage: table(ax, cellText, cellColours, cellLoc, colWidths, rowLabels, rowColours, rowLoc, colLabels, colColours, colLoc, loc, bbox, edges) and returns: table