def init(textCNN, vocab, model_mode, context, lr):
textCNN.initialize(mx.init.Xavier(), ctx=context, force_reinit=True)<EOL>if model_mode != '<STR_LIT>':<EOL><INDENT>textCNN.embedding.weight.set_data(vocab.embedding.idx_to_vec)<EOL><DEDENT>if model_mode == '<STR_LIT>':<EOL><INDENT>textCNN.embedding_extend.weight.set_data(vocab.embedding.idx_to_vec)<EOL><DEDENT>if model_mode == '<STR_LIT>' or model_mode == '<STR_LIT>':<EOL><INDENT>textCNN.embedding.collect_params().setattr('<STR_LIT>', '<STR_LIT:null>')<EOL><DEDENT>trainer = gluon.Trainer(textCNN.collect_params(), '<STR_LIT>', {'<STR_LIT>': lr})<EOL>return textCNN, trainer<EOL>
Initialize parameters.