code: def cook_refs(
      refs, eff=None, n=4
  ):  # lhuang: oracle will call with "average"
      """Takes a list of reference sentences for a single segment
      and returns an object that encapsulates everything that BLEU
      needs to know about them."""
  
      reflen = []
      maxcounts = dict()
      for ref in refs:
          rl, counts = precook(ref, n)
          reflen.append(rl)
          for ngram, count in counts.items():
              maxcounts[ngram] = max(maxcounts.get(ngram, 0), count)
  
      # Calculate effective reference sentence length.
      if eff == "shortest":
          reflen = min(reflen)
      elif eff == "average":
          reflen = float(sum(reflen)) / len(reflen)
  
      # lhuang: N.B.: leave reflen computaiton to the very end!!
  
      # lhuang: N.B.: in case of "closest", keep a list of reflens!! (bad design)
  
      return (reflen, maxcounts)
  
imports: import copy
  import math
  from builtins import dict, range
  from collections import defaultdict
label_desc: Use image node_id 2 for calling a global function with example usage: cook_refs(refs, eff, n) and returns: reflen,  maxcounts