def _score(self, output, cands):
    if (cands.dim() == 2):
        return torch.matmul(output, cands.t())
    elif (cands.dim() == 3):
        return torch.bmm(output.unsqueeze(1), cands.transpose(1, 2)).squeeze(1)
    else:
        raise RuntimeError('Unexpected candidate dimensions {}'.format(cands.dim()))
def _score(self, output, cands):
    if (cands.dim() == 2):
        return torch.matmul(output, cands.t())
    elif (cands.dim() == 3):
        return torch.bmm(output.unsqueeze(1), cands.transpose(1, 2)).squeeze(1)
    else:
        raise RuntimeError('Unexpected candidate dimensions {}'.format(cands.dim()))