import tensorflow as tf

        cutoff_vf_manager = tf.reshape(tf.stop_gradient(self.manager_vf), [-1])
        dot = tf.reduce_sum(tf.multiply(self.s_diff, self.g), axis=1)
        gcut = tf.stop_gradient(self.g)
        mag = tf.norm(self.s_diff, axis=1) * tf.norm(gcut, axis=1) + .0001
        dcos = dot / mag
        manager_loss = -tf.reduce_sum((self.r - cutoff_vf_manager) * dcos)

        cutoff_vf_worker = tf.reshape(tf.stop_gradient(self.worker_vf), [-1])
        log_p = tf.reduce_sum(self.log_pi * self.ac, [1])
        worker_loss = (self.r + self.alpha * self.ri - cutoff_vf_worker) * log_p
        worker_loss = -tf.reduce_sum(worker_loss, axis=0)

        Am = self.r - self.manager_vf
        manager_vf_loss = .5 * tf.reduce_sum(tf.square(Am))

        Aw = (self.r + self.alpha * self.ri) - self.worker_vf
        worker_vf_loss = .5 * tf.reduce_sum(tf.square(Aw))

        entropy = -tf.reduce_sum(self.pi * self.log_pi)

