def _dec_out_formatter(out):
    """Converts PyTorch int sequences (word ids) to Python integers."""
    res = []
    for seq in out:
        tmp = []
        for elem in seq:
            elem = elem.to('cpu').numpy()
            if len(elem.shape) == 0:
                elem = elem.item()
            tmp.append(elem)
        res.append(tmp)
    return res