def METHOD_NAME(tmpdir, batch_size, variable_batch_size, model_def, input_shape, expect_batch_size, save_model, load_model_and_forward):
    nn.clear_parameters()
    # step1: Create and save the network model
    tmpdir.ensure(dir=True)
    nnp_file = tmpdir.join('tmp.nnp').strpath
    save_model(nnp_file, model_def, input_shape, variable_batch_size)
    # step2: Load network model and forward.
    out = load_model_and_forward(nnp_file, batch_size)
    # step3: Varify batch_size
    if expect_batch_size != -1:
        batch_size = expect_batch_size
    assert (batch_size == out.shape[0])