docstr: Extend the master token(insert virtual master token), and format matching result.
  :param match_result:
  :param file_name:
  :return:
docstr_tok: ["Extend","the","master","token","(","insert","virtual","master","token",")",",","and","format","matching","result",".",":","param","match_result",":",":","param","file_name",":",":","return",":"]
code: def _format(self, match_result, file_name):
      """
      Extend the master token(insert virtual master token), and format matching result.
      :param match_result:
      :param file_name:
      :return:
      """
      end2end_info = self.end2end_results[file_name]
      master_info = self.structure_master_results[file_name]
      master_token = master_info["text"]
      sorted_groups = match_result["sorted_groups"]
  
      # creat virtual master token
      virtual_master_token_list = []
      for line_group in sorted_groups:
          tmp_list = ["<tr>"]
          item_nums = len(line_group)
          for _ in range(item_nums):
              tmp_list.append("<td></td>")
          tmp_list.append("</tr>")
          virtual_master_token_list.extend(tmp_list)
  
      # insert virtual master token
      master_token_list = master_token.split(",")
      if master_token_list[-1] == "</tbody>":
          # complete predict(no cut by max length)
          # This situation insert virtual master token will drop TEDs score in val set.
          # So we will not extend virtual token in this situation.
  
          # fake extend virtual
          master_token_list[:-1].extend(virtual_master_token_list)
  
          # real extend virtual
          # master_token_list = master_token_list[:-1]
          # master_token_list.extend(virtual_master_token_list)
          # master_token_list.append('</tbody>')
  
      elif master_token_list[-1] == "<td></td>":
          master_token_list.append("</tr>")
          master_token_list.extend(virtual_master_token_list)
          master_token_list.append("</tbody>")
      else:
          master_token_list.extend(virtual_master_token_list)
          master_token_list.append("</tbody>")
  
      # format output
      match_result.setdefault(
          "matched_master_token_list", master_token_list
      )
      return match_result
  
imports: import os
  import re
  import cv2
  import glob
  import copy
  import math
  import pickle
  import numpy
  from shapely.geometry import Polygon, MultiPoint
label_desc: Use image node_id 3 for calling the Matcher obj's underlying member method code with example usage: obj._format(match_result, file_name) and returns: match_result