def encode(self, vecs):
assert vecs.dtype == np.float32<EOL>assert vecs.ndim == <NUM_LIT:2><EOL>N, D = vecs.shape<EOL>assert D == self.Ds * self.M, "<STR_LIT>"<EOL>codes = np.empty((N, self.M), dtype=self.code_dtype)<EOL>for m in range(self.M):<EOL><INDENT>if self.verbose:<EOL><INDENT>print("<STR_LIT>".format(m, self.M))<EOL><DEDENT>vecs_sub = vecs[:, m * self.Ds : (m+<NUM_LIT:1>) * self.Ds]<EOL>codes[:, m], _ = vq(vecs_sub, self.codewords[m])<EOL><DEDENT>return codes<EOL>
Encode input vectors into PQ-codes.

        Args:
            vecs (np.ndarray): Input vectors with shape=(N, D) and dtype=np.float32.

        Returns:
            np.ndarray: PQ codes with shape=(N, M) and dtype=self.code_dtype