def gibbs_cross_entropy(labels, logits):
    "Average cross entropy for ensemble members (Gibbs cross entropy).\n\n  For each datapoint (x,y), the ensemble's Gibbs cross entropy is:\n\n  ```\n  GCE = - (1/ensemble_size) sum_{m=1}^ensemble_size log p(y|x,theta_m).\n  ```\n\n  The Gibbs cross entropy approximates the average cross entropy of a single\n  model drawn from the (Gibbs) ensemble.\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)
    nll = tf.nn.sparse_softmax_cross_entropy_with_logits(tf.broadcast_to(labels[(tf.newaxis, ...)], tf.shape(logits)[:(- 1)]), logits)
    return tf.reduce_mean(nll, axis=0)
Average cross entropy for ensemble members (Gibbs cross entropy).

For each datapoint (x,y), the ensemble's Gibbs cross entropy is:

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

The Gibbs cross entropy approximates the average cross entropy of a single
model drawn from the (Gibbs) ensemble.

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

Returns:
  tf.Tensor of shape [...].
def gibbs_cross_entropy(labels, logits):
    "Average cross entropy for ensemble members (Gibbs cross entropy).\n\n  For each datapoint (x,y), the ensemble's Gibbs cross entropy is:\n\n  ```\n  GCE = - (1/ensemble_size) sum_{m=1}^ensemble_size log p(y|x,theta_m).\n  ```\n\n  The Gibbs cross entropy approximates the average cross entropy of a single\n  model drawn from the (Gibbs) ensemble.\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)
    nll = tf.nn.sparse_softmax_cross_entropy_with_logits(tf.broadcast_to(labels[(tf.newaxis, ...)], tf.shape(logits)[:(- 1)]), logits)
    return tf.reduce_mean(nll, axis=0)