<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wr_xlsx_sections(fout_xlsx, xlsx_data, **kws):
 """Write xlsx file containing section names followed by lines of namedtuple data."""

    from goatools.wr_tbl_class import WrXlsx
    items_str = "items" if "items" not in kws else kws["items"]
    prt_hdr_min = 10
    num_items = 0
    if xlsx_data:
        # Basic data checks
        assert len(xlsx_data[0]) == 2, "wr_xlsx_sections EXPECTED: [(section, nts), ..."
        assert xlsx_data[0][1], \
            "wr_xlsx_sections EXPECTED SECTION({S}) LIST TO HAVE DATA".format(S=xlsx_data[0][0])
        # Open xlsx file and write title (optional) and headers.
        xlsxobj = WrXlsx(fout_xlsx, xlsx_data[0][1][0]._fields, **kws)
        worksheet = xlsxobj.add_worksheet()
        row_idx = xlsxobj.wr_title(worksheet)
        hdrs_wrote = False
        # Write data
        for section_text, data_nts in xlsx_data:
            num_items += len(data_nts)
            fmt = xlsxobj.wbfmtobj.get_fmt_section()
            row_idx = xlsxobj.wr_row_mergeall(worksheet, section_text, fmt, row_idx)
            if hdrs_wrote is False or len(data_nts) > prt_hdr_min:
                row_idx = xlsxobj.wr_hdrs(worksheet, row_idx)
                hdrs_wrote = True
            row_idx = xlsxobj.wr_data(data_nts, row_idx, worksheet)
        # Close xlsx file
        xlsxobj.workbook.close()
        sys.stdout.write("  {N:>5} {ITEMS} WROTE: {FOUT} ({S} sections)\n".format(
            N=num_items, ITEMS=items_str, FOUT=fout_xlsx, S=len(xlsx_data)))
    else:
        sys.stdout.write("      0 {ITEMS}. NOT WRITING {FOUT}\n".format(
            ITEMS=items_str, FOUT=fout_xlsx))