'Computes the loss for this model.
Returns a tuple `(losses, loss)`, where `losses` are the per-batch
losses and loss is a single scalar tensor to minimize.'

def compute_loss(self, decoder_output, _features, labels):

    losses = seq2seq_losses.cross_entropy_sequence_loss(logits=decoder_output.logits[:, :, :], targets=tf.transpose(labels[u'target_ids'][:, 1:], [1, 0]), sequence_length=(labels[u'target_len'] - 1))
    loss = (tf.reduce_sum(losses) / tf.to_float(tf.reduce_sum((labels[u'target_len'] - 1))))
    return (losses, loss)
