code: def compute_metrics(
      greedy,
      answer,
      rouge=False,
      bleu=False,
      corpus_f1=False,
      logical_form=False,
      args=None,
      dialogue=False,
  ):
      metric_keys = []
      metric_values = []
      if not isinstance(answer[0], list):
          answer = [[a] for a in answer]
      if logical_form:
          lfem, answer = computeLFEM(greedy, answer, args)
          metric_keys += ["lfem"]
          metric_values += [lfem]
      if dialogue:
          (
              joint_goal_em,
              request_em,
              turn_goal_em,
              answer,
          ) = computeDialogue(greedy, answer)
          avg_dialogue = (joint_goal_em + request_em) / 2
          metric_keys += [
              "joint_goal_em",
              "turn_request_em",
              "turn_goal_em",
              "avg_dialogue",
          ]
          metric_values += [
              joint_goal_em,
              request_em,
              turn_goal_em,
              avg_dialogue,
          ]
      em = computeEM(greedy, answer)
      metric_keys += ["em"]
      metric_values += [em]
      if bleu:
          bleu = computeBLEU(greedy, answer)
          metric_keys.append("bleu")
          metric_values.append(bleu)
      if rouge:
          rouge = computeROUGE(greedy, answer)
          metric_keys += ["rouge1", "rouge2", "rougeL", "avg_rouge"]
          avg_rouge = (
              rouge["rouge_1_f_score"]
              + rouge["rouge_2_f_score"]
              + rouge["rouge_l_f_score"]
          ) / 3
          metric_values += [
              rouge["rouge_1_f_score"],
              rouge["rouge_2_f_score"],
              rouge["rouge_l_f_score"],
              avg_rouge,
          ]
      norm_greedy = [normalize_text(g) for g in greedy]
      norm_answer = [[normalize_text(a) for a in al] for al in answer]
      nf1 = computeF1(norm_greedy, norm_answer)
      nem = computeEM(norm_greedy, norm_answer)
      metric_keys.extend(["nf1", "nem"])
      metric_values.extend([nf1, nem])
      if corpus_f1:
          corpus_f1, precision, recall = computeCF1(
              norm_greedy, norm_answer
          )
          metric_keys += ["corpus_f1", "precision", "recall"]
          metric_values += [corpus_f1, precision, recall]
      metric_dict = collections.OrderedDict(
          list(zip(metric_keys, metric_values))
      )
      return metric_dict, answer
  
imports: from subprocess import Popen, PIPE, CalledProcessError
  import json
  from text.torchtext.datasets.generic import Query
  import logging
  import os
  import re
  import string
  import numpy
  import collections
  from multiprocessing import Pool, cpu_count
  from contextlib import closing
  from pyrouge import Rouge155
  from sacrebleu import corpus_bleu
label_desc: Use image node_id 20 for calling a global function with example usage: compute_metrics(greedy, answer, rouge, bleu, corpus_f1, logical_form, args, dialogue) and returns: metric_dict,  answer