def METHOD_NAME(
    op,
    args,
    kwargs,
    device,
    num_threads,
    op_name,
    args_description,
    additional_description=None,
):
    assert device in ["cpu", "cuda"]
    if device == "cpu":
        # NOTE: there is no flow.get_num_threads()
        flow.set_num_threads(num_threads)
        activities = [flow.profiler.ProfilerActivity.CPU]
    else:
        activities = [flow.profiler.ProfilerActivity.CUDA]
    def tensor_to_device(x):
        if isinstance(x, flow.Tensor):
            return x.to(device)
        return x
    args = [tensor_to_device(arg) for arg in args]
    kwargs = {k: tensor_to_device(v) for k, v in kwargs.items()}
    for _ in range(WARMUP_NUM):
        op(*args, **kwargs)
    if PROF_VERBOSE:
        print(
            f'OneFlow ({f"CPU, num_threads={num_threads}" if device == "cpu" else "GPU"}):'
        )
    with flow.profiler.profile(
        activities=activities,
        record_bandwidth_for_cuda=flow.profiler.ProfilerActivity.CUDA in activities,
    ) as prof:
        with flow.profiler.record_function(END_TO_END):
            for _ in range(RUN_NUM):
                op(*args, **kwargs)
    if PROF_VERBOSE:
        print(prof.key_averages())
    return ProfResult(
        prof,
        RUN_NUM,
        "OneFlow",
        device,
        num_threads,
        op_name,
        args_description,
        additional_description,
    )