class_docstr: Concatenate with padding operating on pairs to combine with rev-nets.
class_docstr_tok: ["Concatenate","with","padding","operating","on","pairs","to","combine","with","rev-nets","."]
code: def forward(self, inputs):
      vecs_e1, vecs_e2, vecs_d, mask_e, toks_e, toks_d = inputs
  
      # In training/eval mode or at the first step predict mode i.e. when
      # state.shape is (), i.e. at first step, we return the concatenated output.
      if self._mode != "predict" or not self.state.shape:
          # Now state.shape will not evaluate to false.
          self.state = self.state.reshape((1,))
          # Calculate mask and concat_with_padding on the pairs.
          vecs_ed1 = _ConcatWithPadding(vecs_e1, vecs_d, mask_e)
          vecs_ed2 = _ConcatWithPadding(vecs_e2, vecs_d, mask_e)
          return vecs_ed1, vecs_ed2, toks_e, toks_d
  
      # In predict mode and on subsequent steps (i.e. after the first step) we
      # don't concatenate anymore, but just return the decoder vector.
      return vecs_d, vecs_d, toks_e, toks_d
  
imports: from trax import fastmath
  from trax import layers
  from trax.fastmath import numpy
  from trax.models.research import configurable_transformer
label_desc: Use image node_id 3 for calling the ConcatWithPadding2 obj's underlying member method code with example usage: obj.forward(inputs) and returns: vecs_d,  vecs_d,  toks_e,  toks_d, vecs_ed1,  vecs_ed2,  toks_e,  toks_d