code: def process_img(
      args,
      src_image_root,
      dst_image_root,
      ignore_image_root,
      level,
      preserve_vertical,
      split,
  ):
      # Dirty hack for multi-processing
      img_idx, img_annos = args
      src_img = mmcv.imread(
          osp.join(src_image_root, img_annos["image_id"] + ".jpg")
      )
      labels = []
      for para_idx, paragraph in enumerate(img_annos["paragraphs"]):
          for line_idx, line in enumerate(paragraph["lines"]):
              if level == "line":
                  # Ignore illegible words
                  if line["legible"]:
                      label = process_level(
                          src_img,
                          line,
                          dst_image_root,
                          ignore_image_root,
                          preserve_vertical,
                          split,
                          para_idx,
                          img_idx,
                          line_idx,
                      )
                      if label is not None:
                          labels.append(label)
              elif level == "word":
                  for word_idx, word in enumerate(line["words"]):
                      if not word["legible"]:
                          continue
                      label = process_level(
                          src_img,
                          word,
                          dst_image_root,
                          ignore_image_root,
                          preserve_vertical,
                          split,
                          para_idx,
                          img_idx,
                          line_idx,
                          word_idx,
                      )
                      if label is not None:
                          labels.append(label)
      return labels
  
file_path: mmocr/tools/dataset_converters/textrecog/hiertext_converter.py
imports: import argparse
  import json
  import math
  import os.path
  from functools import partial
  import mmcv
  import mmengine
  import numpy
  from shapely.geometry import Polygon
  from mmocr.utils import dump_ocr_data
label_desc: Use image node_id 3 for calling a global function with example usage: process_img(args, src_image_root, dst_image_root, ignore_image_root, level, preserve_vertical, split) and returns: labels