class_docstr: Base Data Geneartor
class_docstr_tok: ["Base","Data","Geneartor"]
docstr: batch dict generator
docstr_tok: ["batch","dict","generator"]
code: def generator(self):
      """batch dict generator"""
  
      def worker(filter_id, perm):
          """multiprocess worker"""
  
          def func_run():
              """func_run"""
              pid = os.getpid()
              np.random.seed(pid + int(time.time()))
              for batch_examples in self.batch_iter(filter_id, perm):
                  try:
                      batch_dict = self.batch_fn(batch_examples)
                  except Exception as e:
                      traceback.print_exc()
                      log.info(traceback.format_exc())
                      log.info(str(e))
                      continue
  
                  if batch_dict is None:
                      continue
                  yield batch_dict
  
          return func_run
  
      # consume a seed
      np.random.rand()
  
      if self.shuffle:
          perm = np.arange(0, len(self))
          np.random.shuffle(perm)
      else:
          perm = None
  
      if self.num_workers == 1:
          # r = paddle.reader.buffered(worker(0, perm), self.buf_size)
          r = worker(0, perm)
      else:
          worker_pool = [
              worker(wid, perm) for wid in range(self.num_workers)
          ]
          worker = mp_reader.multiprocess_reader(
              worker_pool, use_pipe=True, queue_size=1000
          )
          r = paddle.reader.buffered(worker, self.buf_size)
  
      for batch in r():
          yield batch
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from __future__ import absolute_import
  import os
  import sys
  import six
  from io import open
  from collections import namedtuple
  import numpy
  import tqdm
  import paddle
  from pgl.utils import mp_reader
  import collections
  import time
  from pgl.utils.logger import log
  import traceback
label_desc: Use image node_id 6 for calling the BaseDataGenerator obj's underlying member method code with example usage: obj.generator() and returns: func_run