def serialize(self, file_path, compress=True):
if self.unknown_lookup is not None:<EOL><INDENT>warnings.warn(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>unknown_token = np.array(self.unknown_token)<EOL>idx_to_token = np.array(self.idx_to_token, dtype='<STR_LIT:O>')<EOL>idx_to_vec = self.idx_to_vec.asnumpy()<EOL>if not unknown_token:  <EOL><INDENT>unknown_token = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>assert unknown_token == idx_to_token[C.UNK_IDX]<EOL><DEDENT>if not compress:<EOL><INDENT>np.savez(file=file_path, unknown_token=unknown_token,<EOL>idx_to_token=idx_to_token, idx_to_vec=idx_to_vec)<EOL><DEDENT>else:<EOL><INDENT>np.savez_compressed(file=file_path, unknown_token=unknown_token,<EOL>idx_to_token=idx_to_token,<EOL>idx_to_vec=idx_to_vec)<EOL><DEDENT>
Serializes the TokenEmbedding to a file specified by file_path.

        TokenEmbedding is serialized by converting the list of tokens, the
        array of word embeddings and other metadata to numpy arrays, saving all
        in a single (optionally compressed) Zipfile. See
        https://docs.scipy.org/doc/numpy-1.14.2/neps/npy-format.html for more
        information on the format.


        Parameters
        ----------
        file_path : str or file
            The path at which to create the file holding the serialized
            TokenEmbedding. If file is a string or a Path, the .npz extension
            will be appended to the file name if it is not already there.
        compress : bool, default True
            Compress the Zipfile or leave it uncompressed.