    def to_tabulate(data, headers):
        """Convert two dimensional data structure into tabulate

        Args:
            data (List)
            headers (Iterable[str]): The names of columns defined by user.

        Returns:
            str: tabulate str
        """
        tb_contents = []
        for r in data:
            cells = []
            for x in r:
                if isinstance(x, dict) and 'headers' in x and 'data' in x:
                    cells.append(NestedConsoleTable.to_tabulate(x['data'], x['headers']))
                else:
                    cells.append(_to_plain_cell(x))
            tb_contents.append(cells)
        return tabulate(tb_contents, headers=headers, tablefmt='grid')
Convert two dimensional data structure into tabulate

Args:
data (List)
headers (Iterable[str]): The names of columns defined by user.

Returns:
str: tabulate str
towhee/utils/console_table.py