code: def samples_from_sources(
      sample_sources, buffering=BUFFER_SIZE, labeled=None, reverse=False
  ):
      """
      Loads and combines samples from a list of source files. Sources are combined in an interleaving way to
      keep default sample order from shortest to longest.
  
      Note that when using distributed training, it is much faster to call this function with single pre-
      sorted sample source, because this allows for parallelization of the file I/O. (If this function is
      called with multiple sources, the samples have to be unpacked on a single parent process to allow
      for reading their durations.)
  
      Parameters
      ----------
      sample_sources : list of str
          Paths to sample source files (SDBs or CSVs)
      buffering : int
          Read-buffer size to use while reading files
      labeled : bool or None
          If True: Reads LabeledSample instances. Fails, if not all sources provide transcripts.
          If False: Ignores transcripts (if available) and always reads (unlabeled) util.audio.Sample instances.
          If None: Reads util.sample_collections.LabeledSample instances from sources with transcripts and
          util.audio.Sample instances from sources with no transcripts.
      reverse : bool
          If the order of the samples should be reversed
  
      Returns
      -------
      iterable of util.sample_collections.PackedSample if a single collection is provided, wrapping
          LabeledSample (labeled=True) or util.audio.Sample (labeled=False) supporting len
      or LabeledSample / util.audio.Sample directly, if multiple collections are provided
      """
      sample_sources = list(sample_sources)
      if len(sample_sources) == 0:
          raise ValueError("No files")
      if len(sample_sources) == 1:
          return samples_from_source(
              sample_sources[0],
              buffering=buffering,
              labeled=labeled,
              reverse=reverse,
          )
  
      # If we wish to interleave based on duration, we have to unpack the audio. Note that this unpacking should
      # be done lazily onn the fly so that it respects the LimitingPool logic used in the feeding code.
      cols = [
          LenMap(
              unpack_maybe,
              samples_from_source(
                  source,
                  buffering=buffering,
                  labeled=labeled,
                  reverse=reverse,
              ),
          )
          for source in sample_sources
      ]
  
      return Interleaved(
          *cols, key=lambda s: s.duration, reverse=reverse
      )
  
imports: import os
  import io
  import csv
  import json
  import tarfile
  from pathlib import Path
  from functools import partial
  from .helpers import KILOBYTE, MEGABYTE, GIGABYTE, Interleaved, LenMap
  from .audio import Sample, AUDIO_TYPE_PCM, AUDIO_TYPE_OPUS, SERIALIZABLE_AUDIO_TYPES, get_loadable_audio_type_from_extension, write_wav
  from .io import open_remote, is_remote_path
label_desc: Use image node_id 4 for calling a global function with example usage: samples_from_sources(sample_sources, buffering, labeled, reverse) and returns: Interleaved, samples_from_source