class_docstr: Fetch data from file and generate batches.
  
  Load data from folder as PIL.Images and convert them into batch array.
  
  Args:
      img_folder (Str): Folder path of the training/validation images.
      transforms (Transform):  Preprocess transforms.
docstr: Generate batch arrays from transformed image list.
  
  Args:
      indexes (Sequence): current batch indexes list, e.g. [n, n + 1, ..., n + batch_size]
      batch_size (int): 
      data_size (Tuple): input image size of shape (C, H, W) 
  
  Return:
      batch_x (Numpy ndarray): batch array of input images (B, C, H, W)
      batch_y (Numpy ndarray): batch array of ground truth lables (B,)
docstr_tok: ["Generate","batch","arrays","from","transformed","image","list",".","Args",":","indexes","(","Sequence",")",":","current","batch","indexes","list",",","e.g",".","[","n",",","n","+","1",",","...",",","n","+","batch_size","]","batch_size","(","int",")",":","data_size","(","Tuple",")",":","input","image","size","of","shape","(","C",",","H",",","W",")","Return",":","batch_x","(","Numpy","ndarray",")",":","batch","array","of","input","images","(","B",",","C",",","H",",","W",")","batch_y","(","Numpy","ndarray",")",":","batch","array","of","ground","truth","lables","(","B",",",")"]
code: def batchgenerator(self, indexes, batch_size, data_size):
      """Generate batch arrays from transformed image list.
  
      Args:
          indexes (Sequence): current batch indexes list, e.g. [n, n + 1, ..., n + batch_size]
          batch_size (int):
          data_size (Tuple): input image size of shape (C, H, W)
  
      Return:
          batch_x (Numpy ndarray): batch array of input images (B, C, H, W)
          batch_y (Numpy ndarray): batch array of ground truth lables (B,)
      """
      batch_x = np.zeros((batch_size,) + data_size)
      batch_y = np.zeros((batch_size,) + (1,), dtype=np.int32)
      for idx, i in enumerate(indexes):
          sample_x, sample_y = self.__getitem__(i)
          batch_x[idx, :, :, :] = sample_x
          batch_y[idx, :] = sample_y
  
      return batch_x, batch_y
  
imports: import json
  import os
  import time
  from glob import glob
  import numpy
  from PIL import Image
  from singa import device, layer, model, opt, tensor
  from tqdm import tqdm
  from transforms import Compose, Normalize, ToTensor
label_desc: Use image node_id 4 for calling the ClassDataset obj's underlying member method code with example usage: obj.batchgenerator(indexes, batch_size, data_size) and returns: batch_x,  batch_y