code: def collect_files(data_dir):
      """Collect all images and their corresponding groundtruth files.
  
      Args:
          data_dir (str): The directory to dataset
  
      Returns:
          files (list): The list of tuples (img_file, groundtruth_file)
      """
      assert isinstance(data_dir, str)
      assert data_dir
  
      ann_list, imgs_list = [], []
      for video_dir in os.listdir(data_dir):
          for frame_dir in os.listdir(osp.join(data_dir, video_dir)):
              crt_dir = osp.join(data_dir, video_dir, frame_dir)
              if not osp.isdir(crt_dir):
                  continue
              for crt_file in os.listdir(crt_dir):
                  if crt_file.endswith("xml"):
                      ann_path = osp.join(crt_dir, crt_file)
                      img_path = osp.join(
                          crt_dir, crt_file.replace("xml", "png")
                      )
                      if os.path.exists(img_path):
                          ann_list.append(ann_path)
                          imgs_list.append(img_path)
                      else:
                          continue
  
      files = list(zip(imgs_list, ann_list))
      assert len(files), f"No images found in {data_dir}"
      print(f"Loaded {len(files)} images from {data_dir}")
  
      return files
  
file_path: mmocr/tools/dataset_converters/textdet/lv_converter.py
imports: import argparse
  import os
  import os.path
  import xml.etree.ElementTree
  import mmcv
  import mmengine
  from mmocr.utils import dump_ocr_data
label_desc: Use image node_id 1 for calling a global function with example usage: collect_files(data_dir) and returns: files