code: def compute_bleu_matches(
      reference_corpus, translation_corpus, max_order=4
  ):
      """Computes BLEU match stats of translations against one or more references.
  
      Args:
        reference_corpus: list of references for each translation. Each reference
          should be tokenized into a list of tokens.
        translation_corpus: list of translations to score. Each translation should
          be tokenized into a list of tokens.
        max_order: Maximum n-gram order to use when computing BLEU score.
  
      Returns:
        Aggregated n-gram stats for BLEU calculation.
      """
      reference_length = 0
      translation_length = 0
      bp = 1.0
      geo_mean = 0
  
      matches_by_order = [0] * max_order
      possible_matches_by_order = [0] * max_order
      precisions = []
  
      for references, translations in zip(
          reference_corpus, translation_corpus
      ):
          reference_length += len(references)
          translation_length += len(translations)
          ref_ngram_counts = _get_ngrams(references, max_order)
          translation_ngram_counts = _get_ngrams(
              translations, max_order
          )
  
          overlap = {
              ngram: min(count, translation_ngram_counts[ngram])
              for ngram, count in ref_ngram_counts.items()
          }
  
          for ngram in overlap:
              matches_by_order[len(ngram) - 1] += overlap[ngram]
          for ngram in translation_ngram_counts:
              possible_matches_by_order[
                  len(ngram) - 1
              ] += translation_ngram_counts[ngram]
  
      return (
          np.array(matches_by_order),
          np.array(possible_matches_by_order),
          np.array(reference_length),
          np.array(translation_length),
      )
  
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 3 for calling a global function with example usage: compute_bleu_matches(reference_corpus, translation_corpus, max_order) and returns: np,  np,  np,  np