'Calculate log-prob of action sampled from distribution.'

def log_prob_action(self, action, logits, sampling_dim, act_dim, act_type):

    if self.env_spec.is_discrete(act_type):
        act_log_prob = tf.reduce_sum((tf.one_hot(action, act_dim) * tf.nn.log_softmax(logits)), (-1))
    elif self.env_spec.is_box(act_type):
        means = logits[:, :(sampling_dim / 2)]
        std = logits[:, (sampling_dim / 2):]
        act_log_prob = (((-0.5) * tf.log(((2 * np.pi) * tf.square(std)))) - ((0.5 * tf.square((action - means))) / tf.square(std)))
        act_log_prob = tf.reduce_sum(act_log_prob, (-1))
    else:
        assert False
    return act_log_prob
