<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _generate_ngram_table(self, output_dir, labels, results):
 """Returns an HTML table containing data on each n-gram in `results`."""

        html = []
        grouped = results.groupby(constants.NGRAM_FIELDNAME)
        row_template = self._generate_ngram_row_template(labels)
        for name, group in grouped:
            html.append(self._render_ngram_row(name, group, row_template,
                                               labels))
        return '\n'.join(html)