code: def test(model, dataloader, args):
      scorer = Bleu(4)
      m_scorer = Meteor()
      r_scorer = Rouge()
      hyp = []
      ref = []
      model.eval()
      gold_file = open("tmp_gold.txt", "w")
      pred_file = open("tmp_pred.txt", "w")
      with tqdm(dataloader, desc="Test ", mininterval=1) as tq:
          for batch in tq:
              with torch.no_grad():
                  seq = model(batch, beam_size=args.beam_size)
              r = write_txt(batch, batch["tgt_text"], gold_file, args)
              h = write_txt(batch, seq, pred_file, args)
              hyp.extend(h)
              ref.extend(r)
      hyp = dict(zip(range(len(hyp)), hyp))
      ref = dict(zip(range(len(ref)), ref))
      print(hyp[0], ref[0])
      print("BLEU INP", len(hyp), len(ref))
      print("BLEU", scorer.compute_score(ref, hyp)[0])
      print("METEOR", m_scorer.compute_score(ref, hyp)[0])
      print("ROUGE_L", r_scorer.compute_score(ref, hyp)[0])
      gold_file.close()
      pred_file.close()
  
file_path: dgl/examples/pytorch/graphwriter/train.py
imports: import os
  import sys
  import time
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from graphwriter import *
  from opts import *
  from tqdm import tqdm
  from utlis import *
  from pycocoevalcap.bleu.bleu import Bleu
  from pycocoevalcap.meteor.meteor import Meteor
  from pycocoevalcap.rouge.rouge import Rouge
label_desc: Use image node_id 3 for calling a global function with example usage: test(model, dataloader, args) without return types