<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _ngrams(self, sequence, degree):
 """Returns the n-grams generated from `sequence`. Based on the ngrams function from the Natural Language Toolkit. Each n-gram in the returned list is a string with whitespace removed. :param sequence: the source data to be converted into n-grams :type sequence: sequence :param degree: the degree of the n-grams :type degree: `int` :rtype: `list` of `str` """

        count = max(0, len(sequence) - degree + 1)
        # The extra split and join are due to having to handle
        # whitespace within a CBETA token (eg, [(禾*尤)\n/上/日]).
        return [self._tokenizer.joiner.join(
            self._tokenizer.joiner.join(sequence[i:i+degree]).split())
                for i in range(count)]