def set_embedding(self, *embeddings):
if len(embeddings) == <NUM_LIT:1> and embeddings[<NUM_LIT:0>] is None:<EOL><INDENT>self._embedding = None<EOL>return<EOL><DEDENT>for embs in embeddings:<EOL><INDENT>assert isinstance(embs, emb.TokenEmbedding),'<STR_LIT>''<STR_LIT>'<EOL>assert embs.idx_to_vec is not None,'<STR_LIT>''<STR_LIT>''<STR_LIT>'<EOL><DEDENT>assert all([embs.unknown_token for embs in embeddings]) orall([not embs.unknown_token for embs in embeddings]),'<STR_LIT>''<STR_LIT>'<EOL>new_embedding = emb.TokenEmbedding(self.unknown_token, allow_extend=False)<EOL>new_embedding._token_to_idx = self.token_to_idx<EOL>new_embedding._idx_to_token = self.idx_to_token<EOL>new_vec_len = sum(embs.idx_to_vec.shape[<NUM_LIT:1>] for embs in embeddings)<EOL>new_idx_to_vec = nd.zeros(shape=(len(self), new_vec_len))<EOL>col_start = <NUM_LIT:0><EOL>for embs in embeddings:<EOL><INDENT>if embs and embs.idx_to_vec is not None:<EOL><INDENT>col_end = col_start + embs.idx_to_vec.shape[<NUM_LIT:1>]<EOL>new_idx_to_vec[<NUM_LIT:0>, col_start:col_end] = embs.idx_to_vec[<NUM_LIT:0>]<EOL>new_idx_to_vec[<NUM_LIT:1>:, col_start:col_end] = embs[self._idx_to_token[<NUM_LIT:1>:]]<EOL>col_start = col_end<EOL><DEDENT><DEDENT>new_embedding._idx_to_vec = new_idx_to_vec<EOL>self._embedding = new_embedding<EOL>
Attaches one or more embeddings to the indexed text tokens.


        Parameters
        ----------
        embeddings : None or tuple of :class:`gluonnlp.embedding.TokenEmbedding` instances
            The embedding to be attached to the indexed tokens. If a tuple of multiple embeddings
            are provided, their embedding vectors will be concatenated for the same token.