def evaluate(dataloader_eval, metric):
metric.reset()<EOL>for _, seqs in enumerate(dataloader_eval):<EOL><INDENT>input_ids, valid_len, type_ids, label = seqs<EOL>out = model(<EOL>input_ids.as_in_context(ctx), type_ids.as_in_context(ctx),<EOL>valid_len.astype('<STR_LIT>').as_in_context(ctx))<EOL>metric.update([label], [out])<EOL><DEDENT>metric_nm, metric_val = metric.get()<EOL>if not isinstance(metric_nm, list):<EOL><INDENT>metric_nm = [metric_nm]<EOL>metric_val = [metric_val]<EOL><DEDENT>metric_str = '<STR_LIT>' + '<STR_LIT:U+002C>'.join(<EOL>[i + '<STR_LIT>' for i in metric_nm])<EOL>logging.info(metric_str, *metric_val)<EOL>
Evaluate the model on validation dataset.