<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def init(textCNN, vocab, model_mode, context, lr):
 """Initialize parameters."""


    textCNN.initialize(mx.init.Xavier(), ctx=context, force_reinit=True)
    if model_mode != 'rand':
        textCNN.embedding.weight.set_data(vocab.embedding.idx_to_vec)
    if model_mode == 'multichannel':
        textCNN.embedding_extend.weight.set_data(vocab.embedding.idx_to_vec)
    if model_mode == 'static' or model_mode == 'multichannel':
        # Parameters of textCNN.embedding are not updated during training.
        textCNN.embedding.collect_params().setattr('grad_req', 'null')
    trainer = gluon.Trainer(textCNN.collect_params(), 'adam', {'learning_rate': lr})
    return textCNN, trainer