docstr: generate a batch of records, usually used in dynamic graph mode.
  Args:
      phase (str): the dataset phase, can be 'train', 'dev', 'val', 'test' or 'predict'.
      batch_size (int): the data batch size
      shuffle (bool): if set to True, will shuffle the dataset.
      pad_to_batch_max_seq_len (bool): if set to True, will dynamically pad to the max sequence length of the batch data.
                                       Only recommended to set to True when the model has used RNN.
docstr_tok: ["generate","a","batch","of","records",",","usually","used","in","dynamic","graph","mode",".","Args",":","phase","(","str",")",":","the","dataset","phase",",","can","be","'train","'",",","'dev","'",",","'val","'",",","'test","'","or","'predict","'",".","batch_size","(","int",")",":","the","data","batch","size","shuffle","(","bool",")",":","if","set","to","True",",","will","shuffle","the","dataset",".","pad_to_batch_max_seq_len","(","bool",")",":","if","set","to","True",",","will","dynamically","pad","to","the","max","sequence","length","of","the","batch","data",".","Only","recommended","to","set","to","True","when","the","model","has","used","RNN","."]
code: def batch_records_generator(
      self,
      phase,
      batch_size,
      shuffle=True,
      pad_to_batch_max_seq_len=False,
  ):
      """generate a batch of records, usually used in dynamic graph mode.
      Args:
          phase (str): the dataset phase, can be 'train', 'dev', 'val', 'test' or 'predict'.
          batch_size (int): the data batch size
          shuffle (bool): if set to True, will shuffle the dataset.
          pad_to_batch_max_seq_len (bool): if set to True, will dynamically pad to the max sequence length of the batch data.
                                           Only recommended to set to True when the model has used RNN.
      """
      records = self.get_records(phase, shuffle=shuffle)
  
      batch_records = []
      batch_lens = []
      for record in records:
          batch_records.append(record)
          if pad_to_batch_max_seq_len:
              # This may reduce the processing speed
              tokens_wo_pad = [
                  token
                  for token in self.tokenizer.decode(
                      record, only_convert_to_tokens=True
                  )
                  if token != self.tokenizer.pad_token
              ]
              batch_lens.append(len(tokens_wo_pad))
          if len(batch_records) == batch_size:
              if pad_to_batch_max_seq_len:
                  # This may reduce the processing speed.
                  batch_max_seq_len = max(batch_lens)
                  for record in batch_records:
                      for key, value in record.items():
                          if isinstance(value, list):
                              # This may not be universal
                              record[key] = value[:batch_max_seq_len]
              rev_batch_records = {
                  key: [record[key] for record in batch_records]
                  for key in batch_records[0]
              }
              yield rev_batch_records
              batch_records = []
              batch_lens = []
  
      if batch_records:
          if pad_to_batch_max_seq_len:
              # This may reduce the processing speed.
              batch_max_seq_len = max(batch_lens)
              for record in batch_records:
                  for key in record.keys():
                      if isinstance(record[key], list):
                          record[key] = record[key][:batch_max_seq_len]
          rev_batch_records = {
              key: [record[key] for record in batch_records]
              for key in batch_records[0]
          }
          yield rev_batch_records
  
imports: import io
  import csv
  import collections
  import numpy
  from tqdm import tqdm
  from paddlehub.compat.datasets.base_dataset import InputExample, BaseDataset
  from paddlehub.utils.log import logger
  from paddlehub.text.tokenizer import CustomTokenizer
  from paddlehub.text.bert_tokenizer import BertTokenizer
label_desc: Use image node_id 15 for calling the BaseNLPDataset obj's underlying member method code with example usage: obj.batch_records_generator(phase, batch_size, shuffle, pad_to_batch_max_seq_len) without return types