def get_model_loss(ctx, model, pretrained, dataset_name, dtype, ckpt_dir=None, start_step=None):
<EOL>model, vocabulary = nlp.model.get_model(model,<EOL>dataset_name=dataset_name,<EOL>pretrained=pretrained, ctx=ctx)<EOL>if not pretrained:<EOL><INDENT>model.initialize(init=mx.init.Normal(<NUM_LIT>), ctx=ctx)<EOL><DEDENT>model.cast(dtype)<EOL>if ckpt_dir and start_step:<EOL><INDENT>param_path = os.path.join(ckpt_dir, '<STR_LIT>'%start_step)<EOL>model.load_parameters(param_path, ctx=ctx)<EOL>logging.info('<STR_LIT>', start_step, param_path)<EOL><DEDENT>model.hybridize(static_alloc=True)<EOL>nsp_loss = mx.gluon.loss.SoftmaxCELoss()<EOL>mlm_loss = mx.gluon.loss.SoftmaxCELoss()<EOL>nsp_loss.hybridize(static_alloc=True)<EOL>mlm_loss.hybridize(static_alloc=True)<EOL>return model, nsp_loss, mlm_loss, vocabulary<EOL>
Get model for pre-training.