def _compare(self, boxlist1, boxlist2):
    """Compute pairwise DETR similarity between the two BoxLists.

    Args:
      boxlist1: BoxList holding N groundtruth boxes.
      boxlist2: BoxList holding M predicted boxes.

    Returns:
      A tensor with shape [N, M] representing pairwise DETR similarity scores.
    """
    groundtruth_labels = boxlist1.get_field(fields.BoxListFields.classes)
    predicted_labels = boxlist2.get_field(fields.BoxListFields.classes)
    classification_scores = tf.matmul(groundtruth_labels,
                                      predicted_labels,
                                      transpose_b=True)
    loss = self.l1_weight * box_list_ops.l1(
        boxlist1, boxlist2) + self.giou_weight * (1 - box_list_ops.giou(
            boxlist1, boxlist2)) - classification_scores
    return -loss
Compute pairwise DETR similarity between the two BoxLists.

    Args:
      boxlist1: BoxList holding N groundtruth boxes.
      boxlist2: BoxList holding M predicted boxes.

    Returns:
      A tensor with shape [N, M] representing pairwise DETR similarity scores.
    
inference_api/src/main/object_detection/core/region_similarity_calculator.py