Evaluate the model on a mini-batch.

def evaluate(data_source):
    """Evaluate the model on a mini-batch.
    """
    log.info('Start predict')
    tic = time.time()
    for batch in data_source:
        inputs, token_types, valid_length = batch
        out = net(inputs.astype('float32').as_in_context(ctx),
                  token_types.astype('float32').as_in_context(ctx),
                  valid_length.astype('float32').as_in_context(ctx))
    toc = time.time()
    log.info('Inference time cost={:.2f} s, Thoughput={:.2f} samples/s'
             .format(toc - tic,
                     len(data_source) / (toc - tic)))