def forward(self, xs, mems, cands):
    (weights, context_h) = self.encode_context_memory(xs, mems)
    cands_h = self.encode_cand(cands)
    if self.opt['normalize_sent_emb']:
        context_h = (context_h / context_h.norm(2, dim=1, keepdim=True))
        cands_h = (cands_h / cands_h.norm(2, dim=1, keepdim=True))
    scores = self._score(context_h, cands_h)
    if (self.scores_norm == 'dot'):
        pass
    elif (self.scores_norm == 'sqrt'):
        scores /= math.sqrt(self.opt['embedding_size'])
    elif (self.scores_norm == 'dim'):
        scores /= self.opt['embedding_size']
    else:
        raise ValueError('Invalid --scores-norm')
    return scores
def forward(self, xs, mems, cands):
    (weights, context_h) = self.encode_context_memory(xs, mems)
    cands_h = self.encode_cand(cands)
    if self.opt['normalize_sent_emb']:
        context_h = (context_h / context_h.norm(2, dim=1, keepdim=True))
        cands_h = (cands_h / cands_h.norm(2, dim=1, keepdim=True))
    scores = self._score(context_h, cands_h)
    if (self.scores_norm == 'dot'):
        pass
    elif (self.scores_norm == 'sqrt'):
        scores /= math.sqrt(self.opt['embedding_size'])
    elif (self.scores_norm == 'dim'):
        scores /= self.opt['embedding_size']
    else:
        raise ValueError('Invalid --scores-norm')
    return scores