def compute_average_precision_recall(groundtruth_coordinates, coordinates,
                                     iou_threshold):
    """Computes the average precision (AP) and average recall (AR).

  Args:
      groundtruth_info_dict: the groundtruth_info_dict holds all the groundtruth
        information for an evaluation dataset. The format of this groundtruth_info_dict is
        as follows:
        {'image_id_0':
         [xmin_0,ymin_0,xmax_0,ymax_0,...,xmin_N0,ymin_N0,xmax_N0,ymax_N0],
         ...,
         'image_id_M':
         [xmin_0,ymin_0,xmax_0,ymax_0,...,xmin_NM,ymin_NM,xmax_NM,ymax_NM]},
        where
          image_id_* is an image_id that has the groundtruth rectangles labeled.
          xmin_*,ymin_*,xmax_*,ymax_* is the top-left and bottom-right corners
            of one groundtruth rectangle.

      test_info_dict: the test_info_dict holds all the test information for an
        evaluation dataset.
         The format of this test_info_dict is the same
        as the above groundtruth_info_dict.

      iou_threshold_range: the IOU threshold range to compute the average
        precision (AP) and average recall (AR). For example:
        iou_threshold_range = [0.50:0.05:0.95]
  Returns:
      average_precision, average_recall, as well as the precision_recall_dict,
      where precision_recall_dict holds the full precision/recall information
      for each of the iou_threshold in the iou_threshold_range.
  Raises:
      ValueError: if the input groundtruth_info_dict and test_info_dict show
      inconsistent information.
  """

    # Start to build up the Matching instances for each of the image_id_*, which
    # is to hold the IOU computation between the rectangle pairs for the same
    # image_id_*.
    matchings = {}
    if (len(groundtruth_coordinates) % 4 != 0) or (len(coordinates) % 4 != 0):
        raise ValueError(
            'groundtruth_info_dict and test_info_dict should hold '
            'only 4 * N numbers.')

    groundtruth_rects = convert_to_rectangle_list(groundtruth_coordinates)
    rects = convert_to_rectangle_list(coordinates)
    matching = Matching(groundtruth_rects, rects)

    image_statistics_list = []
    groundtruth_rects_matched, rects_matched = (
        matching.matching_by_greedy_assignment(iou_threshold))

    image_statistics = compute_statistics_given_rectangle_matches(
        groundtruth_rects_matched, rects_matched)
    image_statistics_list.append(image_statistics)

    # Compute the precision and recall under this iou_threshold.
    precision_recall = compute_precision_recall_given_image_statistics_list(
        iou_threshold, image_statistics_list)

    # Compute the average_precision and average_recall.
    #average_precision, average_recall = (
    #    compute_average_precision_recall_given_precision_recall_dict(
    #        precision_recall_dict))

    return precision_recall