import tensorflow as tf

    def _to_chars(line):
        """string scalar -> Dataset of characters (string scalars)."""
        chars, = tf.py_func(_split_string, [line + "\n"], [tf.string])
        chars.set_shape([None])
        return tf.data.Dataset.from_tensor_slices(chars)

    return (tf.data.TextLineDataset([filename])
            .flat_map(_to_chars)
            .repeat()
            .batch(tf.to_int64(sequence_size))
            .shuffle(1000)
            .batch(tf.to_int64(batch_size)))
