    def gumbel(self, phi) -> torch.Tensor:
        """
        Sample `Gumbel(phi)`.

        `phi` should have shape `(batch_size, num_classes)`.
        """
        return -torch.log(-torch.log(torch.rand_like(phi))) + phi
Sample `Gumbel(phi)`.

`phi` should have shape `(batch_size, num_classes)`.
allennlp/nn/beam_search.py