def METHOD_NAME(self, assignment_weights, x, codewords):
    num_codes, channels = paddle.shape(codewords)
    reshaped_codewords = codewords.reshape([1, 1, num_codes, channels])
    expanded_x = paddle.tile(x.unsqueeze(2), [1, 1, num_codes, 1])
    encoded_feat = paddle.multiply(
        assignment_weights.unsqueeze(3),
        (expanded_x - reshaped_codewords)).sum(axis=1)
    encoded_feat = paddle.reshape(encoded_feat,
                                  [-1, self.num_codes, self.channels])
    return encoded_feat