code: def create_dataset(
      sources,
      batch_size,
      epochs=1,
      augmentations=None,
      cache_path=None,
      train_phase=False,
      reverse=False,
      limit=0,
      exception_box=None,
      process_ahead=None,
      buffering=1 * MEGABYTE,
      split_dataset=False,
  ):
      epoch_counter = (
          Counter()
      )  # survives restarts of the dataset and its generator
  
      def generate_values():
          epoch = epoch_counter["epoch"]
          if train_phase:
              epoch_counter["epoch"] += 1
          samples = samples_from_sources(
              sources,
              buffering=buffering,
              labeled=True,
              reverse=reverse,
          )
          num_samples = len(samples)
          if limit > 0:
              num_samples = min(limit, num_samples)
          samples = apply_sample_augmentations(
              samples,
              augmentations,
              buffering=buffering,
              process_ahead=2 * batch_size
              if process_ahead is None
              else process_ahead,
              clock=epoch / epochs,
              final_clock=(epoch + 1) / epochs,
          )
          for sample_index, sample in enumerate(samples):
              if sample_index >= num_samples:
                  break
              clock = (
                  (epoch * num_samples + sample_index)
                  / (epochs * num_samples)
                  if train_phase and epochs > 0
                  else 0.0
              )
              transcript = text_to_char_array(
                  sample.transcript,
                  Config.alphabet,
                  context=sample.sample_id,
              )
              transcript = to_sparse_tuple(transcript)
              yield sample.sample_id, sample.audio, sample.audio_format.rate, transcript, clock
  
      # Batching a dataset of 2D SparseTensors creates 3D batches, which fail
      # when passed to tf.nn.ctc_loss, so we reshape them to remove the extra
      # dimension here.
      def sparse_reshape(sparse):
          shape = sparse.dense_shape
          return tf.sparse.reshape(sparse, [shape[0], shape[2]])
  
      def batch_fn(sample_ids, features, features_len, transcripts):
          features = tf.data.Dataset.zip((features, features_len))
          features = features.padded_batch(
              batch_size, padded_shapes=([None, Config.n_input], [])
          )
          transcripts = transcripts.batch(batch_size).map(
              sparse_reshape
          )
          sample_ids = sample_ids.batch(batch_size)
          return tf.data.Dataset.zip(
              (sample_ids, features, transcripts)
          )
  
      process_fn = partial(
          entry_to_features,
          train_phase=train_phase,
          augmentations=augmentations,
      )
  
      dataset = tf.data.Dataset.from_generator(
          remember_exception(generate_values, exception_box),
          output_types=(
              tf.string,
              tf.float32,
              tf.int32,
              (tf.int64, tf.int32, tf.int64),
              tf.float64,
          ),
      )
      if split_dataset:
          # Using horovod Iterator.get_next() is not aware of different devices.
          # A.shard(n, i) will contain all elements of A whose index mod n = i.
          import horovod.tensorflow as hvd
  
          dataset = dataset.shard(hvd.size(), hvd.rank())
      dataset = dataset.map(
          process_fn, num_parallel_calls=tf.data.experimental.AUTOTUNE
      )
      if cache_path:
          dataset = dataset.cache(cache_path)
      dataset = dataset.window(
          batch_size, drop_remainder=train_phase
      ).flat_map(batch_fn)
      if split_dataset:
          # TODO is there a way to get a proper value?
          dataset = dataset.prefetch(2)
      else:
          dataset = dataset.prefetch(Config.num_devices)
      return dataset
  
file_path: DeepSpeech/training/deepspeech_training/util/feeding.py
imports: from __future__ import absolute_import, division, print_function
  from collections import Counter
  from functools import partial
  import numpy
  import tensorflow
  from tensorflow.python.ops import gen_audio_ops
  from .config import Config
  from .text import text_to_char_array
  from .flags import FLAGS
  from .augmentations import apply_sample_augmentations, apply_graph_augmentations
  from .audio import read_frames_from_file, vad_split, pcm_to_np, DEFAULT_FORMAT
  from .sample_collections import samples_from_sources
  from .helpers import remember_exception, MEGABYTE
label_desc: Use image node_id 5 for calling a global function with example usage: create_dataset(sources, batch_size, epochs, augmentations, cache_path, train_phase, reverse, limit, exception_box, process_ahead, buffering, split_dataset) and returns: dataset, tf, tf