def METHOD_NAME(onnx_model, dataloader, workspace, pad_max):
    options = ort.SessionOptions()
    options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
    if isinstance(onnx_model, str):
        model_path = onnx_model
    else:
        onnx.save(onnx_model, os.path.join(workspace, 'eval.onnx'), save_as_external_data=True)
        model_path = os.path.join(workspace, 'eval.onnx')
    session = ort.InferenceSession(model_path, options, providers=ort.get_available_providers())
    inputs_names = [i.name for i in session.get_inputs()]
    total, hit = 0, 0
    pad_len = 0
    for idx, (batch, last_ind) in enumerate(dataloader):
        ort_inputs = dict(zip(inputs_names, batch))
        label = torch.from_numpy(batch[0][torch.arange(len(last_ind)), last_ind])
        pad_len = pad_max - last_ind - 1
        predictions = session.run(None, ort_inputs)
        outputs = torch.from_numpy(predictions[0])
        last_token_logits = outputs[torch.arange(len(last_ind)), -2 - pad_len, :]
        pred = last_token_logits.argmax(dim=-1)
        total += len(label)
        hit += (pred == label).sum().item()
    acc = hit / total
    return acc