code: def precook(s, n=4, out=False):
      """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."""
      words = s.split()
      counts = defaultdict(int)
      for k in range(1, n + 1):
          for i in range(len(words) - k + 1):
              ngram = tuple(words[i : i + k])
              counts[ngram] += 1
      return (len(words), counts)
  
imports: import copy
  import math
  from builtins import dict, range
  from collections import defaultdict
label_desc: Use image node_id 1 for calling a global function with example usage: precook(s, n, out) and returns: len,  counts