def ensemble_negative_log_likelihood(labels, logits):
    "Negative log-likelihood for ensemble.\n\n  For each datapoint (x,y), the ensemble's negative log-likelihood is:\n\n  ```\n  -log p(y|x) = -log sum_{m=1}^{ensemble_size} exp(log p(y|x,theta_m)) +\n                log ensemble_size.\n  ```\n\n  Args:\n    labels: tf.Tensor of shape [...].\n    logits: tf.Tensor of shape [ensemble_size, ..., num_classes].\n\n  Returns:\n    tf.Tensor of shape [...].\n  "
    labels = tf.cast(labels, tf.int32)
    logits = tf.convert_to_tensor(logits)
    ensemble_size = float(logits.shape[0])
    nll = tf.nn.sparse_softmax_cross_entropy_with_logits(tf.broadcast_to(labels[(tf.newaxis, ...)], tf.shape(logits)[:(- 1)]), logits)
    return ((- tf.reduce_logsumexp((- nll), axis=0)) + tf.math.log(ensemble_size))
Negative log-likelihood for ensemble.

For each datapoint (x,y), the ensemble's negative log-likelihood is:

```
-log p(y|x) = -log sum_{m=1}^{ensemble_size} exp(log p(y|x,theta_m)) +
              log ensemble_size.
```

Args:
  labels: tf.Tensor of shape [...].
  logits: tf.Tensor of shape [ensemble_size, ..., num_classes].

Returns:
  tf.Tensor of shape [...].
def ensemble_negative_log_likelihood(labels, logits):
    "Negative log-likelihood for ensemble.\n\n  For each datapoint (x,y), the ensemble's negative log-likelihood is:\n\n  ```\n  -log p(y|x) = -log sum_{m=1}^{ensemble_size} exp(log p(y|x,theta_m)) +\n                log ensemble_size.\n  ```\n\n  Args:\n    labels: tf.Tensor of shape [...].\n    logits: tf.Tensor of shape [ensemble_size, ..., num_classes].\n\n  Returns:\n    tf.Tensor of shape [...].\n  "
    labels = tf.cast(labels, tf.int32)
    logits = tf.convert_to_tensor(logits)
    ensemble_size = float(logits.shape[0])
    nll = tf.nn.sparse_softmax_cross_entropy_with_logits(tf.broadcast_to(labels[(tf.newaxis, ...)], tf.shape(logits)[:(- 1)]), logits)
    return ((- tf.reduce_logsumexp((- nll), axis=0)) + tf.math.log(ensemble_size))