    def __call__(  # type: ignore
        self,
        logits: torch.Tensor,
        mask: Optional[torch.BoolTensor] = None,
    ):
        """
        # Parameters

        logits : `torch.Tensor`, required.
            A tensor of unnormalized log probabilities of shape (batch_size, ..., num_classes).
        mask : `torch.BoolTensor`, optional (default = `None`).
            A masking tensor of shape (batch_size, ...).
        """
        logits, mask = self.detach_tensors(logits, mask)

        if mask is None:
            mask = torch.ones(logits.size()[:-1], device=logits.device).bool()

        log_probs = torch.nn.functional.log_softmax(logits, dim=-1)
        probabilities = torch.exp(log_probs) * mask.unsqueeze(-1)
        weighted_negative_likelihood = -log_probs * probabilities
        entropy = weighted_negative_likelihood.sum(-1)

        _entropy = entropy.sum() / mask.sum()

        self._entropy += dist_reduce_sum(_entropy).item()
        self._count += dist_reduce_sum(1)
# Parameters

logits : `torch.Tensor`, required.
A tensor of unnormalized log probabilities of shape (batch_size, ..., num_classes).
mask : `torch.BoolTensor`, optional (default = `None`).
A masking tensor of shape (batch_size, ...).
allennlp/training/metrics/entropy.py