def __getitem__(self, tokens):
to_reduce = not isinstance(tokens, (list, tuple))<EOL>if to_reduce:<EOL><INDENT>tokens = [tokens]<EOL><DEDENT>if self.unknown_lookup is not None:<EOL><INDENT>if self.idx_to_vec is None:<EOL><INDENT>vecs = self.unknown_lookup[tokens]<EOL><DEDENT>else:<EOL><INDENT>vecs = [<EOL>self.idx_to_vec[self.token_to_idx[token]] if<EOL>(token in self.token_to_idx<EOL>or token not in self.unknown_lookup) else<EOL>self.unknown_lookup[token] for token in tokens]<EOL>vecs = nd.stack(*vecs, axis=<NUM_LIT:0>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>indices = [self._token_to_idx[token] for token in tokens]<EOL>vecs = nd.Embedding(<EOL>nd.array(indices), self.idx_to_vec, self.idx_to_vec.shape[<NUM_LIT:0>],<EOL>self.idx_to_vec.shape[<NUM_LIT:1>])<EOL><DEDENT>return vecs[<NUM_LIT:0>] if to_reduce else vecs<EOL>
Looks up embedding vectors of text tokens.

        Parameters
        ----------
        tokens : str or list of strs
            A token or a list of tokens.

        Returns
        -------
        mxnet.ndarray.NDArray:
            The embedding vector(s) of the token(s). According to numpy conventions, if `tokens` is
            a string, returns a 1-D NDArray (vector); if `tokens` is a list of
            strings, returns a 2-D NDArray (matrix) of shape=(len(tokens), vec_len).