class_docstr: The implement of DialogReader.
docstr: Data generator.
docstr_tok: ["Data","generator","."]
code: def data_generator(
      self,
      input_file=None,
      reader=None,
      num_epochs=1,
      num_part=1,
      part_id=0,
      phase=None,
      is_infer=False,
  ):
      """Data generator."""
  
      def __wrapper__():
          if is_infer or phase.endswith("test"):
              self.features[phase] = {}
  
          nonlocal reader
          if reader is None:
              if self.file_format == "filelist":
                  reader = self._read_files(
                      input_file,
                      phase,
                      is_infer,
                      not phase.endswith("test"),
                  )
              else:
                  if phase == "train":
                      self.total_file = 1
                      self.current_file_index = 1
                      self.current_file = input_file
                  reader = self._read_file(input_file, phase, is_infer)
  
          batch_reader = self._batch_reader(
              reader,
              phase,
              is_infer,
              sort_pool_size=self.sort_pool_size if not is_infer else 0,
          )
          if phase == "train":
              batch_reader = self._distributed_batch_reader(
                  batch_reader, num_part, part_id
              )
          elif phase.startswith("distributed"):
              batch_reader = self._distributed_batch_reader(
                  batch_reader, num_part, part_id, is_test=True
              )
  
          for epoch_index in range(num_epochs):
              if phase == "train":
                  self.current_example = 0
                  self.current_epoch = epoch_index + 1
              for batch in batch_reader():
                  yield self._pad_batch_records(batch, is_infer)
  
      return __wrapper__
  
imports: import csv
  from collections import namedtuple
  from contextlib import contextmanager
  import gzip
  import numpy
  from ..utils import pad_batch_data
  from ..utils.args import str2bool
  from ..utils.masking import mask
  from ..utils import tokenization
label_desc: Use image node_id 11 for calling the DialogReader obj's underlying member method code with example usage: obj.data_generator(input_file, reader, num_epochs, num_part, part_id, phase, is_infer) and returns: __wrapper__