code: def infer(self):
      self.model.eval()
      pred_list = []
      ground_truth_list = []
  
      for data in self.inference_data_loader:
          # eval_input_graph, _, batch_original_tree_list = (
          eval_input_graph, _, _ = (
              data["graph_data"],
              data["dec_tree_batch"],
              data["original_dec_tree_batch"],
          )
          eval_input_graph = eval_input_graph.to(self.device)
          oov_dict = self.prepare_ext_vocab(
              eval_input_graph, self.src_vocab
          )
  
          # if self.use_copy:
          #     assert len(batch_original_tree_list) == 1
          #     reference = oov_dict.get_symbol_idx_for_list(batch_original_tree_list[0].split())
          #     eval_vocab = oov_dict
          # else:
          #     assert len(batch_original_tree_list) == 1
          #     reference = self.model.tgt_vocab.get_symbol_idx_for_list(
          #         batch_original_tree_list[0].split()
          #     )
          #     eval_vocab = self.tgt_vocab
  
          candidate = self.model.translate(
              eval_input_graph,
              oov_dict=oov_dict,
              use_beam_search=True,
              beam_size=self.opt["beam_size"],
          )
  
          candidate = [int(c) for c in candidate]
          input_str = " ".join(
              x["token"] for x in eval_input_graph.node_attributes
          )
          pred_str = " ".join(
              self.model.tgt_vocab.get_idx_symbol_for_list(candidate)
          )
          print(input_str)
          print(pred_str + "\n")
  
          pred_list.append(pred_str)
          ground_truth_list.append(data["original_dec_tree_batch"][0])
  
      # If the file for inference have meaningful ground truth,
      # we calculate a exact match score for the result.
      if all(DUMMY_STR not in i for i in ground_truth_list):
          print(
              "Exact match score: {0:.2f}%".format(
                  self.evaluation_metric.calculate_scores(
                      ground_truth_list, pred_list
                  )
              )
          )
  
file_path: graph4nlp/examples/pytorch/semantic_parsing/graph2tree/jobs/src/inference_advance.py
imports: import copy
  import random
  import time
  import warnings
  import numpy
  import torch
  from torch.utils.data import DataLoader
  from graph4nlp.pytorch.datasets.jobs import JobsDatasetForTree
  from graph4nlp.pytorch.models.graph2tree import Graph2Tree
  from evaluation import ExactMatch
label_desc: Use image node_id 6 for calling the Jobs obj's underlying member method code with example usage: obj.infer() without return types