code: def generate_ann(root_path, split, image_infos):
      dst_image_root = osp.join(root_path, "crops", split)
      dst_label_file = osp.join(root_path, f"{split}_label.json")
      os.makedirs(dst_image_root, exist_ok=True)
  
      img_info = []
      for image_info in image_infos:
          index = 1
          src_img_path = osp.join(
              root_path, "imgs", image_info["file_name"]
          )
          image = mmcv.imread(src_img_path)
          src_img_root = image_info["file_name"].split(".")[0]
  
          for anno in image_info["anno_info"]:
              word = anno["word"]
              dst_img = crop_img(image, anno["bbox"], 0, 0)
  
              # Skip invalid annotations
              if min(dst_img.shape) == 0:
                  continue
  
              dst_img_name = f"{src_img_root}_{index}.png"
              index += 1
              dst_img_path = osp.join(dst_image_root, dst_img_name)
              mmcv.imwrite(dst_img, dst_img_path)
  
              img_info.append(
                  {
                      "file_name": dst_img_name,
                      "anno_info": [{"text": word}],
                  }
              )
  
      dump_ocr_data(img_info, dst_label_file, "textrecog")
  
file_path: mmocr/tools/dataset_converters/textrecog/imgur_converter.py
imports: import argparse
  import math
  import os
  import os.path
  import mmcv
  import mmengine
  import numpy
  from mmocr.utils import crop_img, dump_ocr_data
label_desc: Use image node_id 6 for calling a global function with example usage: generate_ann(root_path, split, image_infos) without return types