def _precook(self, s):
        """Takes a string as input and returns an object that can be given to either cook_refs or cook_test.
        This is optional: cook_refs and cook_test can take string arguments as well.

        Inputs:
         - s: string : sentence to be converted into ngrams
         - n: int    : number of ngrams for which representation is calculated

         Returns:
             term frequency vector for occuring ngrams
        """
        words = s.split()
        counts = defaultdict(int)
        for k in range(1, self.n + 1):
            for i in range(len(words) - k + 1):
                ngram = tuple(words[i:i + k])
                counts[ngram] += 1
        return counts
Takes a string as input and returns an object that can be given to either cook_refs or cook_test.
        This is optional: cook_refs and cook_test can take string arguments as well.

        Inputs:
         - s: string : sentence to be converted into ngrams
         - n: int    : number of ngrams for which representation is calculated

         Returns:
             term frequency vector for occuring ngrams
        
torchmm/datasets/preprocess/n_grams.py