class_docstr: Dataset iterator to create a batch of sentences.
  
  This iterator returns a pair of sentences, where one token is shifted
  between the sentences like '<sos> w1 w2 w3' and 'w1 w2 w3 <eos>'
  Sentence batches are made in order of longer sentences, and then
  randomly shuffled.
class_docstr_tok: ["Dataset","iterator","to","create","a","batch","of","sentences",".","This","iterator","returns","a","pair","of","sentences",",","where","one","token","is","shifted","between","the","sentences","like","'","<","sos",">","w1","w2","w3","'","and","'w1","w2","w3","<","eos",">","'","Sentence","batches","are","made","in","order","of","longer","sentences",",","and","then","randomly","shuffled","."]
code: def __next__(self):
      # This iterator returns a list representing a mini-batch. Each item
      # indicates a sentence pair like '<sos> w1 w2 w3' and 'w1 w2 w3 <eos>'
      # represented by token IDs.
      n_batches = len(self.batch_indices)
      if not self.repeat and self.iteration >= n_batches:
          # If not self.repeat, this iterator stops at the end of the first
          # epoch (i.e., when all words are visited once).
          raise StopIteration
  
      batch = []
      for idx in self.batch_indices[self.iteration % n_batches]:
          batch.append(
              (
                  np.append([self.sos], self.dataset[idx]),
                  np.append(self.dataset[idx], [self.eos]),
              )
          )
  
      self._previous_epoch_detail = self.epoch_detail
      self.iteration += 1
  
      epoch = self.iteration // n_batches
      self.is_new_epoch = self.epoch < epoch
      if self.is_new_epoch:
          self.epoch = epoch
  
      return batch
  
imports: import logging
  import os
  import random
  import chainer
  import h5py
  import numpy
  from chainer.training import extension
  from tqdm import tqdm
label_desc: Use image node_id 2 for calling the ParallelSentenceIterator obj's underlying member method code with example usage: obj.__next__() and returns: batch