code: def train_batch_gen(self) -> Iterator:
          
  
          if len(self.train_fns) == 0:
              raise PersephoneException("""No training data available; cannot
                                         generate training batches.""")
  
          # Create batches of batch_size and shuffle them.
          fn_batches = self.make_batches(self.train_fns)
  
  
          if self.rand:
              random.shuffle(fn_batches)
  
          for fn_batch in fn_batches:
              logger.debug("Batch of training filenames: %s",
                            pprint.pformat(fn_batch))
              yield self.load_batch(fn_batch)
          else:
              raise StopIteration
docs: Returns a generator that outputs batches in the training data.