code: def write_txt(batch, seqs, w_file, args):
      # converting the prediction to real text.
      ret = []
      for b, seq in enumerate(seqs):
          txt = []
          for token in seq:
              # copy the entity
              if token >= len(args.text_vocab):
                  ent_text = batch["raw_ent_text"][b][
                      token - len(args.text_vocab)
                  ]
                  ent_text = filter(lambda x: x != "<PAD>", ent_text)
                  txt.extend(ent_text)
              else:
                  if int(token) not in [
                      args.text_vocab(x)
                      for x in ["<PAD>", "<BOS>", "<EOS>"]
                  ]:
                      txt.append(args.text_vocab(int(token)))
              if int(token) == args.text_vocab("<EOS>"):
                  break
          w_file.write(" ".join([str(x) for x in txt]) + "\n")
          ret.append([" ".join([str(x) for x in txt])])
      return ret
  
imports: import json
  import pickle
  import random
  import dgl
  import numpy
  import torch
label_desc: Use image node_id 1 for calling a global function with example usage: write_txt(batch, seqs, w_file, args) and returns: ret