original_docstring:  Turns batches of source and target sentences reverse sorted by length of descending order (largest to smallest).
      @param data (list of (src_sent, tgt_sent)): list of tuples containing source and target sentence
      @param batch_size (int): batch size
      @param shuffle (boolean): whether to randomly shuffle the dataset
      
docstring: Turns batches of source and target sentences reverse sorted by length of descending order (largest to smallest).
  @param data (list of (src_sent, tgt_sent)): list of tuples containing source and target sentence
  @param batch_size (int): batch size
  @param shuffle (boolean): whether to randomly shuffle the dataset
docstring_tokens: Turns batches of source and target sentences reverse sorted by length of descending order ( largest to smallest ) . @param data ( list of ( src_sent tgt_sent )) : list of tuples containing source and target sentence @param batch_size ( int ) : batch size @param shuffle ( boolean ) : whether to randomly shuffle the dataset
code: def batch_iter(data, batch_size, shuffle=False):
      """ Turns batches of source and target sentences reverse sorted by length of descending order (largest to smallest).
      @param data (list of (src_sent, tgt_sent)): list of tuples containing source and target sentence
      @param batch_size (int): batch size
      @param shuffle (boolean): whether to randomly shuffle the dataset
      """
  
      batch_num = math.ceil(len(data) / batch_size)
      index_array = list(range(len(data)))
  
      if shuffle:
          np.random.shuffle(index_array)
  
      for i in range(batch_num):
          indices = index_array[i * batch_size: (i + 1) * batch_size]
          examples = [data[idx] for idx in indices]
          examples = sorted(examples, key=lambda e: len(e[0]), reverse=True)
          src_sents = [e[0] for e in examples]
          tgt_sents = [e[1] for e in examples]
  
          yield src_sents, tgt_sents
code_tokens: def batch_iter ( data , batch_size , shuffle = False ) : batch_num = math . ceil ( len ( data ) / batch_size ) index_array = list ( range ( len ( data ) ) ) if shuffle : np . random . shuffle ( index_array ) for i in range ( batch_num ) : indices = index_array [ i * batch_size : ( i + 1 ) * batch_size ] examples = [ data [ idx ] for idx in indices ] examples = sorted ( examples , key = lambda e : len ( e [ 0 ] ) , reverse = True ) src_sents = [ e [ 0 ] for e in examples ] tgt_sents = [ e [ 1 ] for e in examples ] yield src_sents , tgt_sents
short_docstring: Turns batches of source and target sentences reverse sorted by length of descending order (largest to smallest).
short_docstring_tokens: Turns batches of source and target sentences reverse sorted by length of descending order ( largest to smallest ) .
comment: """ Turns batches of source and target sentences reverse sorted by length of descending order (largest to smallest).
      @param data (list of (src_sent, tgt_sent)): list of tuples containing source and target sentence
      @param batch_size (int): batch size
      @param shuffle (boolean): whether to randomly shuffle the dataset
      """