def __call__(self, x):
    if (self.coeff == 0.0):
        return tf.constant(0.0)
    (contextual_weights, features, outputs) = x
    features_shape = tf.shape(features)
    features_noise = tf.random.normal(shape=(features_shape[0], self.num_samples, features_shape[1]), stddev=self.stddev)
    features_prime = (tf.expand_dims(features, axis=1) + features_noise)
    logits = tf.einsum('ipk,ijp->ijk', contextual_weights['kernels'], features_prime)
    if ('biases' in contextual_weights):
        biases = tf.expand_dims(contextual_weights['biases'], axis=1)
        logits = tf.add(logits, biases)
    probs = (tf.reduce_mean(tf.nn.softmax(logits), axis=1) + self.epsilon)
    probs_sum = tf.reduce_sum(probs, axis=(- 1), keepdims=True)
    log_probs = tf.math.log((probs / probs_sum))
    loss = (- tf.nn.softmax_cross_entropy_with_logits(labels=tf.nn.softmax(outputs), logits=log_probs))
    return (self.coeff * tf.reduce_mean(loss))
def __call__(self, x):
    if (self.coeff == 0.0):
        return tf.constant(0.0)
    (contextual_weights, features, outputs) = x
    features_shape = tf.shape(features)
    features_noise = tf.random.normal(shape=(features_shape[0], self.num_samples, features_shape[1]), stddev=self.stddev)
    features_prime = (tf.expand_dims(features, axis=1) + features_noise)
    logits = tf.einsum('ipk,ijp->ijk', contextual_weights['kernels'], features_prime)
    if ('biases' in contextual_weights):
        biases = tf.expand_dims(contextual_weights['biases'], axis=1)
        logits = tf.add(logits, biases)
    probs = (tf.reduce_mean(tf.nn.softmax(logits), axis=1) + self.epsilon)
    probs_sum = tf.reduce_sum(probs, axis=(- 1), keepdims=True)
    log_probs = tf.math.log((probs / probs_sum))
    loss = (- tf.nn.softmax_cross_entropy_with_logits(labels=tf.nn.softmax(outputs), logits=log_probs))
    return (self.coeff * tf.reduce_mean(loss))