def encode_cand(self, words):
    if (words is None):
        return None
    if (words.dim() == 3):
        oldshape = words.shape
        words = words.reshape((oldshape[0] * oldshape[1]), oldshape[2])
    else:
        oldshape = None
    encoded = self.cand_encoder(words)
    if (oldshape is not None):
        encoded = encoded.reshape(oldshape[0], oldshape[1], (- 1))
    return encoded
def encode_cand(self, words):
    if (words is None):
        return None
    if (words.dim() == 3):
        oldshape = words.shape
        words = words.reshape((oldshape[0] * oldshape[1]), oldshape[2])
    else:
        oldshape = None
    encoded = self.cand_encoder(words)
    if (oldshape is not None):
        encoded = encoded.reshape(oldshape[0], oldshape[1], (- 1))
    return encoded