def __getitem__(self, tokens):
squeeze = False<EOL>if isinstance(tokens, _str_types):<EOL><INDENT>tokens = [tokens]<EOL>squeeze = True<EOL><DEDENT>data = []<EOL>row = []<EOL>col = []<EOL>subwords = self._subword_function(tokens)<EOL>offset = len(self._token_to_idx)<EOL>for i, (token, token_subwords) in enumerate(zip(tokens, subwords)):<EOL><INDENT>if token not in self:<EOL><INDENT>raise KeyError<EOL><DEDENT>if token in self._token_to_idx:<EOL><INDENT>col.append(self._token_to_idx[token])<EOL>num = <NUM_LIT:1> + len(token_subwords)<EOL><DEDENT>else:<EOL><INDENT>num = len(token_subwords)<EOL><DEDENT>data += [<NUM_LIT:1.0> / num] * num<EOL>row += [i] * num<EOL>col += [s + offset for s in token_subwords]<EOL><DEDENT>x = nd.sparse.csr_matrix(<EOL>(data, (row, col)), shape=(len(tokens), self.weight.shape[<NUM_LIT:0>]),<EOL>dtype=self.dtype, ctx=self.weight.list_ctx()[<NUM_LIT:0>])<EOL>emb = self(x)<EOL>if squeeze:<EOL><INDENT>return emb.squeeze()<EOL><DEDENT>else:<EOL><INDENT>return emb<EOL><DEDENT>
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).