title: how to batch with tf.data.Dataset.from_generator? Do i needto modify generator
body: <p>I'm using the <code>batch(8)</code> function, it modifies the shape and adds batch dimension, but only getting one image per batch. Below is my code:-</p>
  <pre><code>import cv2
  import numpy as np
  import os
  import tensorflow as tf
  import random
  
  folder_path = &quot;./real/&quot;
  files = os.listdir(folder_path)
  
  def get_image():
      index = random.randint(0,len(files)-1)
      img = cv2.imread(folder_path+files[index])
      img = cv2.resize(img,(128,128))
      img = img/255.
      #More complex transformation
      yield img
  
  dset = tf.data.Dataset.from_generator(get_image,(tf.float32)).batch(8)
  
  for img in dset:
      print(img.shape)
      break
  </code></pre>
  <p>The output still is (1, 128, 128, 3) even after using batch(8). Do I need to modify the generator to manually crate the batch? Also, how can it be wrapped in the generator in tensorflow so that it runs faster?</p>