def _build_inputs_and_targets(
      self, from_seqs=None, from_tags=None, to_seqs=None, to_tags=None):
    """Given from and to sequences and tags, construct inputs and targets."""
    del from_tags  # Unused.
    if from_seqs is not None:
      inputs = from_seqs
      inputs_length = common_layers.length_from_embedding(inputs)
      if to_tags is not None:
        # Add to-tags to the inputs and adjust lengths.
        # <float32> [batch_size, seq_len + 1, 1, emb_size].
        inputs = tf.concat([to_tags, inputs], axis=1)
        inputs_length = inputs_length + 1
      inputs = common_layers.flatten4d3d(inputs)
    else:
      inputs = None
      inputs_length = None

    if to_seqs is not None:
      # Shift to-sequences to form targets.
      # <float32> [batch_size, seq_len, 1, emb_size].
      targets = common_layers.shift_right(to_seqs)
      # Add 1 to account for the padding added to the left from shift_right.
      targets_length = common_layers.length_from_embedding(targets) + 1
      targets = common_layers.flatten4d3d(targets)
    else:
      targets = None
      targets_length = None

    return (inputs, inputs_length), (targets, targets_length)
Given from and to sequences and tags, construct inputs and targets.
language/labs/consistent_zero_shot_nmt/models/agreement.py