title: parallelising tf.data.Dataset.from_generator
body: <p>
  I have a non trivial input pipeline that <code>from_generator</code> is perfect for...</p>
  
  <pre class="lang-py prettyprint-override"><code>dataset = tf.data.Dataset.from_generator(complex_img_label_generator,
                                          (tf.int32, tf.string))
  dataset = dataset.batch(64)
  iter = dataset.make_one_shot_iterator()
  imgs, labels = iter.get_next()
  </code></pre>
  
  <p>Where <code>complex_img_label_generator</code> dynamically generates images and returns a numpy array representing a <code>(H, W, 3)</code> image and a simple <code>string</code> label. The processing not something I can represent as reading from files and <code>tf.image</code> operations.</p>
  
  <p>My question is about how to parallise the generator? How do I have N of these generators running in their own threads.</p>
  
  <p>One thought was to use <code>dataset.map</code> with <code>num_parallel_calls</code> to handle the threading; but the map operates on tensors... Another thought was to create multiple generators each with it's own <code>prefetch</code> and somehow join them, but I can't see how I'd join N generator streams?</p>
  
  <p>Any canonical examples I could follow?</p>