code: def do_eval(m, tq, ta, test, meta_data, args):
      q, candis, ans_count = limit_encode_eval(
          test,
          meta_data["label2answer"],
          meta_data["idx2word"],
          args.q_seq_limit,
          args.ans_seq_limit,
          meta_data["idx2vec"],
          args.number_of_candidates,
      )
      m.eval()
      candi_pool_size = candis.shape[1]
      correct = 0
      start = time.time()
      for i in tqdm(range(len(q))):
          # batch size bs must satisfy: bs == repeated q, bs == number of answers//2
          # 1 question repeat n times, n == number of answers//2
          _q = np.repeat([q[i]], candi_pool_size // 2, axis=0)
          tq.copy_from_numpy(_q)
          ta.copy_from_numpy(candis[i])
  
          (first_half_score, second_half_score) = m.forward(tq, ta)
  
          first_half_score = tensor.to_numpy(first_half_score)
          second_half_score = tensor.to_numpy(second_half_score)
          scores = np.concatenate((first_half_score, second_half_score))
          pred_max_idx = np.argmax(scores)
  
          if pred_max_idx < ans_count[i]:
              correct += 1
  
      print(
          "eval top %s " % (candi_pool_size),
          " accuracy",
          correct / len(q),
          " time used %d sec" % (time.time() - start),
      )
  
file_path: singa/examples/qabot/qabot_train.py
imports: import numpy
  import time
  import random
  from tqdm import tqdm
  import argparse
  from singa import autograd, tensor, device, opt
  from qabot_data import limit_encode_train, limit_encode_eval, prepare_data
  from qabot_model import QAModel_maxpooling
label_desc: Use image node_id 2 for calling a global function with example usage: do_eval(m, tq, ta, test, meta_data, args) without return types