code: def complete_bleu(
      matches_by_order,
      possible_matches_by_order,
      reference_length,
      translation_length,
      max_order=4,
      use_bp=True,
  ):
      """Compute BLEU score from aggregated n-gram statistics."""
      precisions = [0] * max_order
      smooth = 1.0
      geo_mean = 0.0
      for i in range(0, max_order):
          if possible_matches_by_order[i] > 0:
              precisions[i] = (
                  matches_by_order[i] / possible_matches_by_order[i]
              )
              if matches_by_order[i] > 0:
                  precisions[i] = (
                      matches_by_order[i] / possible_matches_by_order[i]
                  )
              else:
                  smooth *= 2
                  precisions[i] = 1.0 / (
                      smooth * possible_matches_by_order[i]
                  )
          else:
              precisions[i] = 0.0
  
      if max(precisions) > 0:
          p_log_sum = sum(math.log(p) for p in precisions if p)
          geo_mean = math.exp(p_log_sum / max_order)
  
      if use_bp:
          if not reference_length:
              bp = 1.0
          else:
              ratio = translation_length / reference_length
              if ratio <= 0.0:
                  bp = 0.0
              elif ratio >= 1.0:
                  bp = 1.0
              else:
                  bp = math.exp(1 - 1.0 / ratio)
      bleu = geo_mean * bp
      return float(bleu) * 100.0
  
file_path: flax/examples/wmt/bleu.py
imports: import collections
  import math
  import re
  import sys
  import unicodedata
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: complete_bleu(matches_by_order, possible_matches_by_order, reference_length, translation_length, max_order, use_bp) and returns: unknown