import tensorflow as tf

        self._loss = None
        if mode_gen in ('ce_train', 'loss', ):
            xent = CE_loss(vocab_scores, answer_batch, loss_weights) # [batch_size]
            if mode_gen == 'loss': xent *= self.placeholders.reward # multiply with rewards
            self._loss = tf.reduce_mean(xent)
            # Calculate coverage loss from the attention distributions
            if options.use_coverage:
                with tf.variable_scope('coverage_loss'):
                    self._coverage_loss = _coverage_loss(attn_dists, loss_weights)
                self._loss = self._loss + options.cov_loss_wt * self._coverage_loss

        # accuracy is calculated only under 'ce_train', where true answer is given
        if mode_gen == 'ce_train':
            accuracy = _mask_and_accuracy(vocab_scores, answer_batch, loss_weights)
