def fit(self, vecs, iter=<NUM_LIT:20>, seed=<NUM_LIT>):
assert vecs.dtype == np.float32<EOL>assert vecs.ndim == <NUM_LIT:2><EOL>N, D = vecs.shape<EOL>assert self.Ks < N, "<STR_LIT>"<EOL>assert D % self.M == <NUM_LIT:0>, "<STR_LIT>"<EOL>self.Ds = int(D / self.M)<EOL>np.random.seed(seed)<EOL>if self.verbose:<EOL><INDENT>print("<STR_LIT>".format(iter, seed))<EOL><DEDENT>self.codewords = np.zeros((self.M, self.Ks, self.Ds), dtype=np.float32)<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>self.codewords[m], _ = kmeans2(vecs_sub, self.Ks, iter=iter, minit='<STR_LIT>')<EOL><DEDENT>return self<EOL>
Given training vectors, run k-means for each sub-space and create
        codewords for each sub-space.

        This function should be run once first of all.

        Args:
            vecs (np.ndarray): Training vectors with shape=(N, D) and dtype=np.float32.
            iter (int): The number of iteration for k-means
            seed (int): The seed for random process

        Returns:
            object: self