def label_anchors(self, anchors, gt_instances):
        """
        Same interface as :meth:`RetinaNet.label_anchors`, but implemented with FCOS
        anchor matching rule.

        Unlike RetinaNet, there are no ignored anchors.
        """
        matched_indices = self.match_anchors(anchors, gt_instances)

        matched_labels, matched_boxes = [], []
        for gt_index, gt_per_image in zip(matched_indices, gt_instances):
            label = gt_per_image.gt_classes[gt_index.clip(min=0)]
            label[gt_index < 0] = self.num_classes  # background

            matched_gt_boxes = gt_per_image.gt_boxes[gt_index.clip(min=0)]

            matched_labels.append(label)
            matched_boxes.append(matched_gt_boxes)
        return matched_labels, matched_boxes

        Same interface as :meth:`RetinaNet.label_anchors`, but implemented with FCOS
        anchor matching rule.

        Unlike RetinaNet, there are no ignored anchors.
        
video_chat_with_ChatGPT/models/grit_src/third_party/CenterNet2/detectron2/modeling/meta_arch/fcos.py