code: def _maybe_create_sources(dir):
      dataset_sources = os.path.join(dir, "data.txt")
      MP3 = glob(os.path.join(dir, "**", "*.mp3"))
      XML = glob(os.path.join(dir, "**", "*.xml"))
  
      MP3_XML_Scores = []
      MP3_XML_Fin = {}
  
      for f_mp3 in MP3:
          for f_xml in XML:
              b_mp3 = os.path.splitext(os.path.basename(f_mp3))[0]
              b_xml = os.path.splitext(os.path.basename(f_xml))[0]
              a_mp3 = b_mp3.split("_")
              a_xml = b_xml.split("_")
              score = 0
              date_mp3 = a_mp3[0]
              date_xml = a_xml[0]
  
              if date_mp3 != date_xml:
                  continue
  
              for i in range(min(len(a_mp3), len(a_xml))):
                  if a_mp3[i] == a_xml[i]:
                      score += 1
  
              if score >= 1:
                  MP3_XML_Scores.append((f_mp3, f_xml, score))
  
      # sort by score
      MP3_XML_Scores.sort(key=lambda x: x[2], reverse=True)
      for s_mp3, s_xml, score in MP3_XML_Scores:
          # print(s_mp3, s_xml, score)
          if score not in MP3_XML_Fin:
              MP3_XML_Fin[score] = {}
  
          if s_mp3 not in MP3_XML_Fin[score]:
              try:
                  MP3.index(s_mp3)
                  MP3.remove(s_mp3)
                  MP3_XML_Fin[score][s_mp3] = s_xml
              except ValueError as ex:
                  pass
          else:
              print(
                  "here:",
                  MP3_XML_Fin[score][s_mp3],
                  s_xml,
                  file=sys.stderr,
              )
  
      with open(dataset_sources, "w") as ds:
          for score in MP3_XML_Fin:
              for mp3 in MP3_XML_Fin[score]:
                  xml = MP3_XML_Fin[score][mp3]
                  if (
                      os.path.getsize(mp3) > 0
                      and os.path.getsize(xml) > 0
                  ):
                      mp3 = os.path.relpath(mp3, dir)
                      xml = os.path.relpath(xml, dir)
                      ds.write(
                          "{},{},{:0.2e}\n".format(xml, mp3, 2.5e-4)
                      )
                  else:
                      print(
                          "Empty file {} or {}".format(mp3, xml),
                          file=sys.stderr,
                      )
  
      print("Missing XML pairs:", MP3, file=sys.stderr)
      return dataset_sources
  
imports: import csv
  import sys
  import os
  import progressbar
  import subprocess
  import zipfile
  from glob import glob
  from multiprocessing import Pool
  import hashlib
  import decimal
  import math
  import unicodedata
  import re
  import sox
  import xml.etree.ElementTree
  import requests
  import json
  from deepspeech_training.util.downloader import SIMPLE_BAR, maybe_download
  from deepspeech_training.util.helpers import secs_to_hours
  from deepspeech_training.util.importers import get_counter, get_importers_parser, get_imported_samples, get_validate_label, print_import_report
  from ds_ctcdecoder import Alphabet
label_desc: Use image node_id 3 for calling a global function with example usage: _maybe_create_sources(dir) and returns: dataset_sources