code: def _maybe_import_data(
      xml_file, audio_source, target_dir, rel_tol=1e-1
  ):
      dataset_basename = os.path.splitext(os.path.split(xml_file)[1])[0]
      wav_root = os.path.join(target_dir, dataset_basename)
      if not os.path.exists(wav_root):
          os.makedirs(wav_root)
  
      source_frames = int(
          subprocess.check_output(
              ["soxi", "-s", audio_source], stderr=subprocess.STDOUT
          )
      )
      print(
          "Source audio length: %s"
          % secs_to_hours(source_frames / SAMPLE_RATE)
      )
  
      # Get audiofile path and transcript for each sentence in tsv
      samples = []
      tree = ET.parse(xml_file)
      root = tree.getroot()
      seq_id = 0
      this_time = 0.0
      this_duration = 0.0
      prev_time = 0.0
      prev_duration = 0.0
      this_text = ""
      for child in root:
          if child.tag == "row":
              cur_time = float(child.attrib["timestamp"])
              cur_duration = float(child.attrib["timedur"])
              cur_text = child.text
  
              if this_time == 0.0:
                  this_time = cur_time
  
              delta = cur_time - (prev_time + prev_duration)
              # rel_tol value is made from trial/error to try and compromise between:
              # - cutting enough to skip missing words
              # - not too short, not too long sentences
              is_close = math.isclose(
                  cur_time, this_time + this_duration, rel_tol=rel_tol
              )
              is_short = (
                  this_duration + cur_duration + delta
              ) < MAX_SECS
  
              # when the previous element is close enough **and** this does not
              # go over MAX_SECS, we append content
              if is_close and is_short:
                  this_duration += cur_duration + delta
                  this_text += cur_text
              else:
                  samples.append(
                      (
                          audio_source,
                          target_dir,
                          dataset_basename,
                          this_time,
                          this_duration,
                          this_text,
                          seq_id,
                      )
                  )
  
                  this_time = cur_time
                  this_duration = cur_duration
                  this_text = cur_text
  
                  seq_id += 1
  
              prev_time = cur_time
              prev_duration = cur_duration
  
      # Keep track of how many samples are good vs. problematic
      _counter = get_counter()
      num_samples = len(samples)
      _rows = []
  
      print("Processing XML data: {}".format(xml_file))
      pool = Pool()
      bar = progressbar.ProgressBar(
          max_value=num_samples, widgets=SIMPLE_BAR
      )
      for i, processed in enumerate(
          pool.imap_unordered(one_sample, samples), start=1
      ):
          _counter += processed[0]
          _rows += processed[1]
          bar.update(i)
      bar.update(num_samples)
      pool.close()
      pool.join()
  
      imported_samples = get_imported_samples(_counter)
      assert _counter["all"] == num_samples
      assert len(_rows) == imported_samples
  
      print_import_report(_counter, SAMPLE_RATE, MAX_SECS)
      print(
          "Import efficiency: %.1f%%"
          % ((_counter["total_time"] / source_frames) * 100)
      )
      print("")
  
      return _counter, _rows
  
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 9 for calling a global function with example usage: _maybe_import_data(xml_file, audio_source, target_dir, rel_tol) and returns: _counter,  _rows