title: adding and accessing auxiliary tf.Dataset attributes with Keras
body: <p>I use a <code>tf.py_func</code> call to parse data (features, labels and sample_weights) from file to a <code>tf.Dataset</code>:</p>
  
  <pre><code>dataset = tf.data.Dataset.from_tensor_slices((records, labels, sample_weights))    
  dataset = dataset.map(
     lambda filename, label, sample_weight: tuple(tf.py_func(
       self._my_parse_function, [filename, label, sample_weights], [tf.float32, label.dtype, tf.float32])))
  </code></pre>
  
  <p>The data is variable-length 1-D sequences, so I also pad the sequences to a fixed length in <code>my_parse_function</code>.  </p>
  
  <p>I use <code>tensorflow.python.keras.models.Sequential.fit(...)</code> to train the data (which now accepts datasets as input, including datasets with sample_weights) and <code>tensorflow.python.keras.models.Sequential.predict</code> to predict outputs.</p>
  
  <p>Once I have predictions I would like to do some post-processing to make sense of the outputs. For example, I'd like to truncate the padded data to the actual sequence length. Also, I'd like to know for sure which file the data came from, since I am not sure that ordering is guaranteed with dataset iterators, especially if batching is used (I do batch the dataset as well) or multi-GPU or multi-workers are involved (I hope to try the multi- scenarios). Even if order was 'guaranteed' this is a decent sanity check.</p>
  
  <p>This information, filename (i.e, a string) and sequence length (i.e, an integer), is not currently conveniently accessible, so I'd like to add these two attributes to the dataset elements and be able to retrieve them during/after the call to predict.</p>
  
  <p>What is the best approach to do this?</p>
  
  <p>Thanks</p>