code: def evaluate(ref_file, trans_file, metric, subword_option=None):
      """Pick a metric and evaluate depending on task."""
      # BLEU scores for translation task
      if metric.lower() == "bleu":
          evaluation_score = _bleu(
              ref_file, trans_file, subword_option=subword_option
          )
      # ROUGE scores for summarization tasks
      elif metric.lower() == "rouge":
          evaluation_score = _rouge(
              ref_file, trans_file, subword_option=subword_option
          )
      elif metric.lower() == "accuracy":
          evaluation_score = _accuracy(ref_file, trans_file)
      elif metric.lower() == "word_accuracy":
          evaluation_score = _word_accuracy(ref_file, trans_file)
      else:
          raise ValueError("Unknown metric %s" % metric)
  
      return evaluation_score
  
file_path: nlp-architect/examples/sparse_gnmt/gnmt/utils/evaluation_utils.py
imports: import codecs
  import os
  import re
  import subprocess
  import tensorflow
  from .None import rouge, bleu
label_desc: Use image node_id 1 for calling a global function with example usage: evaluate(ref_file, trans_file, metric, subword_option) and returns: evaluation_score