<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_label_count(self):
 """Adds to each result row a count of the number of occurrences of that n-gram across all works within the label. This count uses the highest witness count for each work. """

        self._logger.info('Adding label count')

        def add_label_count(df):
            # For each n-gram and label pair, we need the maximum count
            # among all witnesses to each work, and then the sum of those
            # across all works.
            work_maxima = df.groupby(constants.WORK_FIELDNAME,
                                     sort=False).max()
            df.loc[:, constants.LABEL_COUNT_FIELDNAME] = work_maxima[
                constants.COUNT_FIELDNAME].sum()
            return df

        if self._matches.empty:
            self._matches[constants.LABEL_COUNT_FIELDNAME] = 0
        else:
            self._matches.loc[:, constants.LABEL_COUNT_FIELDNAME] = 0
            self._matches = self._matches.groupby(
                [constants.LABEL_FIELDNAME, constants.NGRAM_FIELDNAME],
                sort=False).apply(add_label_count)
        self._logger.info('Finished adding label count')