@templatedoc()
def detection_map(detect_res, label, class_num, background_label=0, overlap_threshold=0.3, evaluate_difficult=True, has_state=None, input_states=None, out_states=None, ap_version='integral'):
    "\n    ${comment}\n\n    Args:\n        detect_res: ${detect_res_comment}\n        label:  ${label_comment}\n        class_num: ${class_num_comment}\n        background_label: ${background_label_comment}\n        overlap_threshold: ${overlap_threshold_comment}\n        evaluate_difficult: ${evaluate_difficult_comment}\n        has_state: ${has_state_comment}\n        input_states: (tuple|None) If not None, It contains 3 elements:\n            (1) pos_count ${pos_count_comment}.\n            (2) true_pos ${true_pos_comment}.\n            (3) false_pos ${false_pos_comment}.\n        out_states: (tuple|None) If not None, it contains 3 elements.\n            (1) accum_pos_count ${accum_pos_count_comment}.\n            (2) accum_true_pos ${accum_true_pos_comment}.\n            (3) accum_false_pos ${accum_false_pos_comment}.\n        ap_version: ${ap_type_comment}\n\n    Returns:\n        ${map_comment}\n\n\n    Examples:\n          .. code-block:: python\n\n            import paddle.fluid as fluid\n            from fluid.layers import detection\n            detect_res = fluid.data(\n                name='detect_res',\n                shape=[10, 6],\n                dtype='float32')\n            label = fluid.data(\n                name='label',\n                shape=[10, 6],\n                dtype='float32')\n\n            map_out = detection.detection_map(detect_res, label, 21)\n    "
    helper = LayerHelper('detection_map', **locals())

    def __create_var(type):
        return helper.create_variable_for_type_inference(dtype=type)
    map_out = __create_var('float32')
    accum_pos_count_out = (out_states[0] if (out_states is not None) else __create_var('int32'))
    accum_true_pos_out = (out_states[1] if (out_states is not None) else __create_var('float32'))
    accum_false_pos_out = (out_states[2] if (out_states is not None) else __create_var('float32'))
    pos_count = (input_states[0] if (input_states is not None) else None)
    true_pos = (input_states[1] if (input_states is not None) else None)
    false_pos = (input_states[2] if (input_states is not None) else None)
    helper.append_op(type='detection_map', inputs={'Label': label, 'DetectRes': detect_res, 'HasState': has_state, 'PosCount': pos_count, 'TruePos': true_pos, 'FalsePos': false_pos}, outputs={'MAP': map_out, 'AccumPosCount': accum_pos_count_out, 'AccumTruePos': accum_true_pos_out, 'AccumFalsePos': accum_false_pos_out}, attrs={'overlap_threshold': overlap_threshold, 'evaluate_difficult': evaluate_difficult, 'ap_type': ap_version, 'class_num': class_num})
    return map_out
${comment}

Args:
    detect_res: ${detect_res_comment}
    label:  ${label_comment}
    class_num: ${class_num_comment}
    background_label: ${background_label_comment}
    overlap_threshold: ${overlap_threshold_comment}
    evaluate_difficult: ${evaluate_difficult_comment}
    has_state: ${has_state_comment}
    input_states: (tuple|None) If not None, It contains 3 elements:
        (1) pos_count ${pos_count_comment}.
        (2) true_pos ${true_pos_comment}.
        (3) false_pos ${false_pos_comment}.
    out_states: (tuple|None) If not None, it contains 3 elements.
        (1) accum_pos_count ${accum_pos_count_comment}.
        (2) accum_true_pos ${accum_true_pos_comment}.
        (3) accum_false_pos ${accum_false_pos_comment}.
    ap_version: ${ap_type_comment}

Returns:
    ${map_comment}


Examples:
      .. code-block:: python

        import paddle.fluid as fluid
        from fluid.layers import detection
        detect_res = fluid.data(
            name='detect_res',
            shape=[10, 6],
            dtype='float32')
        label = fluid.data(
            name='label',
            shape=[10, 6],
            dtype='float32')

        map_out = detection.detection_map(detect_res, label, 21)
@templatedoc()
def detection_map(detect_res, label, class_num, background_label=0, overlap_threshold=0.3, evaluate_difficult=True, has_state=None, input_states=None, out_states=None, ap_version='integral'):
    "\n    ${comment}\n\n    Args:\n        detect_res: ${detect_res_comment}\n        label:  ${label_comment}\n        class_num: ${class_num_comment}\n        background_label: ${background_label_comment}\n        overlap_threshold: ${overlap_threshold_comment}\n        evaluate_difficult: ${evaluate_difficult_comment}\n        has_state: ${has_state_comment}\n        input_states: (tuple|None) If not None, It contains 3 elements:\n            (1) pos_count ${pos_count_comment}.\n            (2) true_pos ${true_pos_comment}.\n            (3) false_pos ${false_pos_comment}.\n        out_states: (tuple|None) If not None, it contains 3 elements.\n            (1) accum_pos_count ${accum_pos_count_comment}.\n            (2) accum_true_pos ${accum_true_pos_comment}.\n            (3) accum_false_pos ${accum_false_pos_comment}.\n        ap_version: ${ap_type_comment}\n\n    Returns:\n        ${map_comment}\n\n\n    Examples:\n          .. code-block:: python\n\n            import paddle.fluid as fluid\n            from fluid.layers import detection\n            detect_res = fluid.data(\n                name='detect_res',\n                shape=[10, 6],\n                dtype='float32')\n            label = fluid.data(\n                name='label',\n                shape=[10, 6],\n                dtype='float32')\n\n            map_out = detection.detection_map(detect_res, label, 21)\n    "
    helper = LayerHelper('detection_map', **locals())

    def __create_var(type):
        return helper.create_variable_for_type_inference(dtype=type)
    map_out = __create_var('float32')
    accum_pos_count_out = (out_states[0] if (out_states is not None) else __create_var('int32'))
    accum_true_pos_out = (out_states[1] if (out_states is not None) else __create_var('float32'))
    accum_false_pos_out = (out_states[2] if (out_states is not None) else __create_var('float32'))
    pos_count = (input_states[0] if (input_states is not None) else None)
    true_pos = (input_states[1] if (input_states is not None) else None)
    false_pos = (input_states[2] if (input_states is not None) else None)
    helper.append_op(type='detection_map', inputs={'Label': label, 'DetectRes': detect_res, 'HasState': has_state, 'PosCount': pos_count, 'TruePos': true_pos, 'FalsePos': false_pos}, outputs={'MAP': map_out, 'AccumPosCount': accum_pos_count_out, 'AccumTruePos': accum_true_pos_out, 'AccumFalsePos': accum_false_pos_out}, attrs={'overlap_threshold': overlap_threshold, 'evaluate_difficult': evaluate_difficult, 'ap_type': ap_version, 'class_num': class_num})
    return map_out