code: def collect_hiertext_info(root_path, level, split, print_every=1000):
      """Collect the annotation information.
  
      The annotation format is as the following:
      {
          "info": {
              "date": "release date",
              "version": "current version"
          },
          "annotations": [  // List of dictionaries, one for each image.
              {
              "image_id": "the filename of corresponding image.",
              "image_width": image_width,  // (int) The image width.
              "image_height": image_height, // (int) The image height.
              "paragraphs": [  // List of paragraphs.
                  {
                  "vertices": [[x1, y1], [x2, y2],...,[xn, yn]]
                  "legible": true
                  "lines": [
                      {
                      "vertices": [[x1, y1], [x2, y2],...,[x4, y4]]
                      "text": L
                      "legible": true,
                      "handwritten": false
                      "vertical": false,
                      "words": [
                          {
                          "vertices": [[x1, y1], [x2, y2],...,[xm, ym]]
                          "text": "the text content of this word",
                          "legible": true
                          "handwritten": false,
                          "vertical": false,
                          }, ...
                      ]
                      }, ...
                  ]
                  }, ...
              ]
              }, ...
          ]
          }
  
      Args:
          root_path (str): Root path to the dataset
          level (str): Level of annotations,  which should be 'word', 'line',
              or 'paragraphs'
          split (str): Dataset split, which should be 'train' or 'validation'
          print_every (int): Print log information per iter
  
      Returns:
          img_info (dict): The dict of the img and annotation information
      """
  
      annotation_path = osp.join(
          root_path, "annotations/" + split + ".jsonl"
      )
      if not osp.exists(annotation_path):
          raise Exception(
              f"{annotation_path} not exists, please check and try again."
          )
  
      annotation = json.load(open(annotation_path))["annotations"]
      img_infos = []
      for i, img_annos in enumerate(annotation):
          if i > 0 and i % print_every == 0:
              print(f"{i}/{len(annotation)}")
          img_info = {}
          img_info["file_name"] = img_annos["image_id"] + ".jpg"
          img_info["height"] = img_annos["image_height"]
          img_info["width"] = img_annos["image_width"]
          img_info["segm_file"] = annotation_path
          anno_info = []
          for paragraph in img_annos["paragraphs"]:
              if level == "paragraph":
                  anno = collect_level_info(paragraph)
                  anno_info.append(anno)
              elif level == "line":
                  for line in paragraph["lines"]:
                      anno = collect_level_info(line)
                      anno_info.append(anno)
              elif level == "word":
                  for line in paragraph["lines"]:
                      for word in line["words"]:
                          anno = collect_level_info(line)
                          anno_info.append(anno)
          img_info.update(anno_info=anno_info)
          img_infos.append(img_info)
      return img_infos
  
file_path: mmocr/tools/dataset_converters/textdet/hiertext_converter.py
imports: import argparse
  import json
  import os.path
  import numpy
  from shapely.geometry import Polygon
  from mmocr.utils import dump_ocr_data
label_desc: Use image node_id 2 for calling a global function with example usage: collect_hiertext_info(root_path, level, split, print_every) and returns: img_infos