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