code: def cook_test(test, refs, eff=None, n=4):
      """Takes a test sentence and returns an object that
      encapsulates everything that BLEU needs to know about it."""
  
      reflen, refmaxcounts = refs
      testlen, counts = precook(test, n, True)
  
      result = dict()
  
      # Calculate effective reference sentence length.
  
      if eff == "closest":
          result["reflen"] = min((abs(l - testlen), l) for l in reflen)[
              1
          ]
      else:  # i.e., "average" or "shortest" or None
          result["reflen"] = reflen
  
      result["testlen"] = testlen
  
      result["guess"] = [
          max(0, testlen - k + 1) for k in range(1, n + 1)
      ]
  
      result["correct"] = [0] * n
      for ngram, count in counts.items():
          result["correct"][len(ngram) - 1] += min(
              refmaxcounts.get(ngram, 0), count
          )
  
      return result
  
imports: import copy
  import math
  from builtins import dict, range
  from collections import defaultdict
label_desc: Use image node_id 3 for calling a global function with example usage: cook_test(test, refs, eff, n) and returns: result