'Calculate entropy of distribution.'

def entropy(self, logits, sampling_dim, act_dim, act_type):

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