import tensorflow as tf


            # Compute examination loss
            self.relevance_weights = self.get_normalized_weights(self.logits_to_prob(train_output))
            self.exam_loss = self.loss_func(self.propensity, reshaped_train_labels, self.relevance_weights)
            rw_list = tf.unstack(self.relevance_weights, axis=1) # Compute propensity weights
            for i in range(len(rw_list)):
                tf.summary.scalar('Relevance weights %d' % i, tf.reduce_mean(rw_list[i]), collections=['train'])
            tf.summary.scalar('Exam Loss', tf.reduce_mean(self.exam_loss), collections=['train'])
            
            # Gradients and SGD update operation for training the model.
            self.loss = self.exam_loss + self.hparams.ranker_loss_weight * self.rank_loss
            
            # Select optimizer
            self.optimizer_func = tf.train.AdagradOptimizer
