import torch


def xexpx(a):
    """Computes `a*exp(a)`.

    This function makes the outputs more stable when the inputs of this function converge to :math:`-\\infty`.

    :param torch.Tensor a:
    :return: Equivalent of `a*torch.exp(a)`.
    """
    mask = (a == float('-inf'))
    y = a*torch.exp(a)
    y[mask] = 0.
    return y