@classmethod<EOL><INDENT>def load_fasttext_format(cls, path, ctx=cpu(), **kwargs):<DEDENT>
with open(path, '<STR_LIT:rb>') as f:<EOL><INDENT>new_format, dim, bucket, minn, maxn, = cls._read_model_params(f)<EOL>idx_to_token = cls._read_vocab(f, new_format)<EOL>dim, matrix = cls._read_vectors(f, new_format, bucket,<EOL>len(idx_to_token))<EOL><DEDENT>token_to_idx = {token: idx for idx, token in enumerate(idx_to_token)}<EOL>if len(token_to_idx) != len(idx_to_token):<EOL><INDENT>warnings.warn(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>len(idx_to_token) - len(token_to_idx)))<EOL>for _ in range(len(token_to_idx), len(idx_to_token)):<EOL><INDENT>token_to_idx[object()] = -<NUM_LIT:1><EOL><DEDENT><DEDENT>assert len(token_to_idx) == len(idx_to_token)<EOL>subword_function = create_subword_function(<EOL>'<STR_LIT>', num_subwords=matrix.shape[<NUM_LIT:0>] - len(idx_to_token),<EOL>ngrams=list(range(minn, maxn + <NUM_LIT:1>)), special_tokens={'<STR_LIT>'})<EOL>self = cls(token_to_idx, subword_function, output_dim=dim, **kwargs)<EOL>self.initialize(ctx=ctx)<EOL>self.weight.set_data(nd.array(matrix))<EOL>return self<EOL>
Create an instance of the class and load weights.

        Load the weights from the fastText binary format created by
        https://github.com/facebookresearch/fastText

        Parameters
        ----------
        path : str
            Path to the .bin model file.
        ctx : mx.Context, default mx.cpu()
            Context to initialize the weights on.
        kwargs : dict
            Keyword arguments are passed to the class initializer.