keras/src/utils/audio_dataset_utils.py/prepare_dataset
def prepare_dataset(
    dataset,
    batch_size,
    class_names,
    output_sequence_length,
    ragged,
):
    dataset = dataset.prefetch(tf.data.AUTOTUNE)
    if batch_size is not None:
        if output_sequence_length is None and not ragged:
            dataset = dataset.padded_batch(
                batch_size, padded_shapes=([None, None], [])
            )
        else:
            dataset = dataset.batch(batch_size)

    # Users may need to reference `class_names`.
    dataset.class_names = class_names
    return dataset