code: def collect_files(img_dir, gt_dir, split_info):
      """Collect all images and their corresponding groundtruth files.
  
      Args:
          img_dir (str): The image directory
          gt_dir (str): The groundtruth directory
          split_info (dict): The split information for train/val/test
  
      Returns:
          files (list): The list of tuples (img_file, groundtruth_file)
      """
      assert isinstance(img_dir, str)
      assert img_dir
      assert isinstance(gt_dir, str)
      assert gt_dir
      assert isinstance(split_info, dict)
      assert split_info
  
      ann_list, imgs_list = [], []
      for group in split_info:
          for img in split_info[group]:
              image_path = osp.join(img_dir, img)
              anno_path = osp.join(
                  gt_dir, "groups", group, img.replace("jpg", "json")
              )
  
              # Filtering out the missing images
              if not osp.exists(image_path) or not osp.exists(
                  anno_path
              ):
                  continue
  
              imgs_list.append(image_path)
              ann_list.append(anno_path)
  
      files = list(zip(imgs_list, ann_list))
      assert len(files), f"No images found in {img_dir}"
      print(f"Loaded {len(files)} images from {img_dir}")
  
      return files
  
file_path: mmocr/tools/dataset_converters/textrecog/naf_converter.py
imports: import argparse
  import os.path
  import mmcv
  import mmengine
  import numpy
  from mmocr.utils import crop_img, dump_ocr_data
label_desc: Use image node_id 1 for calling a global function with example usage: collect_files(img_dir, gt_dir, split_info) and returns: files