code: def seq2seq_pad_concat_convert(xy_batch, eos_id=2, bos_id=1):
      """
      Args:
          xy_batch (list of tuple of two numpy.ndarray-s or cupy.ndarray-s):
              xy_batch[i][0] is an array
              of token ids of i-th input sentence in a minibatch.
              xy_batch[i][1] is an array
              of token ids of i-th target sentence in a minibatch.
              The shape of each array is `(sentence length, )`.
          eos_id: The index of end-of-sentence special token in the
              dictionary.
  
      Returns:
          Tuple of Converted array.
              (input_sent_batch_array, target_sent_batch_input_array,
              target_sent_batch_output_array).
              The shape of each array is `(batchsize, max_sentence_length)`.
              All sentences are padded with 0 to reach max_sentence_length.
      """
  
      x_seqs, y_seqs = zip(*xy_batch)
      x_block = _concat_examples(x_seqs, padding=0)
      y_block = _concat_examples(y_seqs, padding=0)
  
      # Add EOS
      x_block = np.pad(
          x_block, ((0, 0), (0, 1)), "constant", constant_values=0
      )
      for i_batch, seq in enumerate(x_seqs):
          x_block[i_batch, len(seq)] = eos_id
  
      y_out_block = np.pad(
          y_block, ((0, 0), (0, 1)), "constant", constant_values=0
      )
      for i_batch, seq in enumerate(y_seqs):
          y_out_block[i_batch, len(seq)] = eos_id
  
      # Add BOS in target language
      y_in_block = np.pad(
          y_block, ((0, 0), (1, 0)), "constant", constant_values=bos_id
      )
      return x_block, y_in_block, y_out_block
  
file_path: texar/examples/transformer/utils/data_utils.py
imports: import os
  import codecs
  import six
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: seq2seq_pad_concat_convert(xy_batch, eos_id, bos_id) and returns: x_block,  y_in_block,  y_out_block