<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _render_ngram_row(self, ngram, ngram_group, row_template, labels):
 """Returns the HTML for an n-gram row."""

        cell_data = {'ngram': ngram}
        label_data = {}
        for label in labels:
            label_data[label] = []
        work_grouped = ngram_group.groupby(constants.WORK_FIELDNAME)
        for work, group in work_grouped:
            min_count = group[constants.COUNT_FIELDNAME].min()
            max_count = group[constants.COUNT_FIELDNAME].max()
            if min_count == max_count:
                count = min_count
            else:
                count = '{}\N{EN DASH}{}'.format(min_count, max_count)
            label_data[group[constants.LABEL_FIELDNAME].iloc[0]].append(
                '{} ({})'.format(work, count))
        for label, data in label_data.items():
            label_data[label] = '; '.join(data)
        cell_data.update(label_data)
        html = row_template.format(**cell_data)
        return '<tr>\n{}\n</tr>'.format(html)