def __call__(self, raw_boxes: Mapping[(str, tf.Tensor)], raw_scores: Mapping[(str, tf.Tensor)], anchor_boxes: tf.Tensor, image_shape: tf.Tensor, raw_attributes: Optional[Mapping[(str, tf.Tensor)]]=None):
    'Generates final detections.\n\n    Args:\n      raw_boxes: A `dict` with keys representing FPN levels and values\n        representing box tenors of shape `[batch, feature_h, feature_w,\n        num_anchors * 4]`.\n      raw_scores: A `dict` with keys representing FPN levels and values\n        representing logit tensors of shape `[batch, feature_h, feature_w,\n        num_anchors]`.\n      anchor_boxes: A `tf.Tensor` of shape of [batch_size, K, 4] representing\n        the corresponding anchor boxes w.r.t `box_outputs`.\n      image_shape: A `tf.Tensor` of shape of [batch_size, 2] storing the image\n        height and width w.r.t. the scaled image, i.e. the same image space as\n        `box_outputs` and `anchor_boxes`.\n      raw_attributes: If not None, a `dict` of (attribute_name,\n        attribute_prediction) pairs. `attribute_prediction` is a dict that\n        contains keys representing FPN levels and values representing tenors of\n        shape `[batch, feature_h, feature_w, num_anchors * attribute_size]`.\n\n    Returns:\n      If `apply_nms` = True, the return is a dictionary with keys:\n        `detection_boxes`: A `float` tf.Tensor of shape\n          [batch, max_num_detections, 4] representing top detected boxes in\n          [y1, x1, y2, x2].\n        `detection_scores`: A `float` tf.Tensor of shape\n          [batch, max_num_detections] representing sorted confidence scores for\n          detected boxes. The values are between [0, 1].\n        `detection_classes`: An `int` tf.Tensor of shape\n          [batch, max_num_detections] representing classes for detected boxes.\n        `num_detections`: An `int` tf.Tensor of shape [batch] only the first\n          `num_detections` boxes are valid detections\n        `detection_attributes`: A dict. Values of the dict is a `float`\n          tf.Tensor of shape [batch, max_num_detections, attribute_size]\n          representing attribute predictions for detected boxes.\n      If `apply_nms` = False, the return is a dictionary with keys:\n        `decoded_boxes`: A `float` tf.Tensor of shape [batch, num_raw_boxes, 4]\n          representing all the decoded boxes.\n        `decoded_box_scores`: A `float` tf.Tensor of shape\n          [batch, num_raw_boxes] representing socres of all the decoded boxes.\n        `decoded_box_attributes`: A dict. Values in the dict is a\n          `float` tf.Tensor of shape [batch, num_raw_boxes, attribute_size]\n          representing attribute predictions of all the decoded boxes.\n    '
    (boxes, scores, attributes) = self._decode_multilevel_outputs(raw_boxes, raw_scores, anchor_boxes, image_shape, raw_attributes)
    if (not self._config_dict['apply_nms']):
        return {'decoded_boxes': boxes, 'decoded_box_scores': scores, 'decoded_box_attributes': attributes}
    if self._config_dict['use_cpu_nms']:
        nms_context = tf.device('cpu:0')
    else:
        nms_context = contextlib.nullcontext()
    with nms_context:
        if (raw_attributes and (self._config_dict['nms_version'] != 'v1')):
            raise ValueError('Attribute learning is only supported for NMSv1 but NMS {} is used.'.format(self._config_dict['nms_version']))
        if (self._config_dict['nms_version'] == 'batched'):
            (nmsed_boxes, nmsed_scores, nmsed_classes, valid_detections) = _generate_detections_batched(boxes, scores, self._config_dict['pre_nms_score_threshold'], self._config_dict['nms_iou_threshold'], self._config_dict['max_num_detections'])
            nmsed_attributes = {}
        elif (self._config_dict['nms_version'] == 'v1'):
            (nmsed_boxes, nmsed_scores, nmsed_classes, valid_detections, nmsed_attributes) = _generate_detections_v1(boxes, scores, attributes=(attributes if raw_attributes else None), pre_nms_top_k=self._config_dict['pre_nms_top_k'], pre_nms_score_threshold=self._config_dict['pre_nms_score_threshold'], nms_iou_threshold=self._config_dict['nms_iou_threshold'], max_num_detections=self._config_dict['max_num_detections'], soft_nms_sigma=self._config_dict['soft_nms_sigma'])
        elif (self._config_dict['nms_version'] == 'v2'):
            (nmsed_boxes, nmsed_scores, nmsed_classes, valid_detections) = _generate_detections_v2(boxes, scores, pre_nms_top_k=self._config_dict['pre_nms_top_k'], pre_nms_score_threshold=self._config_dict['pre_nms_score_threshold'], nms_iou_threshold=self._config_dict['nms_iou_threshold'], max_num_detections=self._config_dict['max_num_detections'])
            nmsed_attributes = {}
        else:
            raise ValueError('NMS version {} not supported.'.format(self._config_dict['nms_version']))
    nmsed_classes += 1
    return {'num_detections': valid_detections, 'detection_boxes': nmsed_boxes, 'detection_classes': nmsed_classes, 'detection_scores': nmsed_scores, 'detection_attributes': nmsed_attributes}
Generates final detections.

Args:
  raw_boxes: A `dict` with keys representing FPN levels and values
    representing box tenors of shape `[batch, feature_h, feature_w,
    num_anchors * 4]`.
  raw_scores: A `dict` with keys representing FPN levels and values
    representing logit tensors of shape `[batch, feature_h, feature_w,
    num_anchors]`.
  anchor_boxes: A `tf.Tensor` of shape of [batch_size, K, 4] representing
    the corresponding anchor boxes w.r.t `box_outputs`.
  image_shape: A `tf.Tensor` of shape of [batch_size, 2] storing the image
    height and width w.r.t. the scaled image, i.e. the same image space as
    `box_outputs` and `anchor_boxes`.
  raw_attributes: If not None, a `dict` of (attribute_name,
    attribute_prediction) pairs. `attribute_prediction` is a dict that
    contains keys representing FPN levels and values representing tenors of
    shape `[batch, feature_h, feature_w, num_anchors * attribute_size]`.

Returns:
  If `apply_nms` = True, the return is a dictionary with keys:
    `detection_boxes`: A `float` tf.Tensor of shape
      [batch, max_num_detections, 4] representing top detected boxes in
      [y1, x1, y2, x2].
    `detection_scores`: A `float` tf.Tensor of shape
      [batch, max_num_detections] representing sorted confidence scores for
      detected boxes. The values are between [0, 1].
    `detection_classes`: An `int` tf.Tensor of shape
      [batch, max_num_detections] representing classes for detected boxes.
    `num_detections`: An `int` tf.Tensor of shape [batch] only the first
      `num_detections` boxes are valid detections
    `detection_attributes`: A dict. Values of the dict is a `float`
      tf.Tensor of shape [batch, max_num_detections, attribute_size]
      representing attribute predictions for detected boxes.
  If `apply_nms` = False, the return is a dictionary with keys:
    `decoded_boxes`: A `float` tf.Tensor of shape [batch, num_raw_boxes, 4]
      representing all the decoded boxes.
    `decoded_box_scores`: A `float` tf.Tensor of shape
      [batch, num_raw_boxes] representing socres of all the decoded boxes.
    `decoded_box_attributes`: A dict. Values in the dict is a
      `float` tf.Tensor of shape [batch, num_raw_boxes, attribute_size]
      representing attribute predictions of all the decoded boxes.
def __call__(self, raw_boxes: Mapping[(str, tf.Tensor)], raw_scores: Mapping[(str, tf.Tensor)], anchor_boxes: tf.Tensor, image_shape: tf.Tensor, raw_attributes: Optional[Mapping[(str, tf.Tensor)]]=None):
    'Generates final detections.\n\n    Args:\n      raw_boxes: A `dict` with keys representing FPN levels and values\n        representing box tenors of shape `[batch, feature_h, feature_w,\n        num_anchors * 4]`.\n      raw_scores: A `dict` with keys representing FPN levels and values\n        representing logit tensors of shape `[batch, feature_h, feature_w,\n        num_anchors]`.\n      anchor_boxes: A `tf.Tensor` of shape of [batch_size, K, 4] representing\n        the corresponding anchor boxes w.r.t `box_outputs`.\n      image_shape: A `tf.Tensor` of shape of [batch_size, 2] storing the image\n        height and width w.r.t. the scaled image, i.e. the same image space as\n        `box_outputs` and `anchor_boxes`.\n      raw_attributes: If not None, a `dict` of (attribute_name,\n        attribute_prediction) pairs. `attribute_prediction` is a dict that\n        contains keys representing FPN levels and values representing tenors of\n        shape `[batch, feature_h, feature_w, num_anchors * attribute_size]`.\n\n    Returns:\n      If `apply_nms` = True, the return is a dictionary with keys:\n        `detection_boxes`: A `float` tf.Tensor of shape\n          [batch, max_num_detections, 4] representing top detected boxes in\n          [y1, x1, y2, x2].\n        `detection_scores`: A `float` tf.Tensor of shape\n          [batch, max_num_detections] representing sorted confidence scores for\n          detected boxes. The values are between [0, 1].\n        `detection_classes`: An `int` tf.Tensor of shape\n          [batch, max_num_detections] representing classes for detected boxes.\n        `num_detections`: An `int` tf.Tensor of shape [batch] only the first\n          `num_detections` boxes are valid detections\n        `detection_attributes`: A dict. Values of the dict is a `float`\n          tf.Tensor of shape [batch, max_num_detections, attribute_size]\n          representing attribute predictions for detected boxes.\n      If `apply_nms` = False, the return is a dictionary with keys:\n        `decoded_boxes`: A `float` tf.Tensor of shape [batch, num_raw_boxes, 4]\n          representing all the decoded boxes.\n        `decoded_box_scores`: A `float` tf.Tensor of shape\n          [batch, num_raw_boxes] representing socres of all the decoded boxes.\n        `decoded_box_attributes`: A dict. Values in the dict is a\n          `float` tf.Tensor of shape [batch, num_raw_boxes, attribute_size]\n          representing attribute predictions of all the decoded boxes.\n    '
    (boxes, scores, attributes) = self._decode_multilevel_outputs(raw_boxes, raw_scores, anchor_boxes, image_shape, raw_attributes)
    if (not self._config_dict['apply_nms']):
        return {'decoded_boxes': boxes, 'decoded_box_scores': scores, 'decoded_box_attributes': attributes}
    if self._config_dict['use_cpu_nms']:
        nms_context = tf.device('cpu:0')
    else:
        nms_context = contextlib.nullcontext()
    with nms_context:
        if (raw_attributes and (self._config_dict['nms_version'] != 'v1')):
            raise ValueError('Attribute learning is only supported for NMSv1 but NMS {} is used.'.format(self._config_dict['nms_version']))
        if (self._config_dict['nms_version'] == 'batched'):
            (nmsed_boxes, nmsed_scores, nmsed_classes, valid_detections) = _generate_detections_batched(boxes, scores, self._config_dict['pre_nms_score_threshold'], self._config_dict['nms_iou_threshold'], self._config_dict['max_num_detections'])
            nmsed_attributes = {}
        elif (self._config_dict['nms_version'] == 'v1'):
            (nmsed_boxes, nmsed_scores, nmsed_classes, valid_detections, nmsed_attributes) = _generate_detections_v1(boxes, scores, attributes=(attributes if raw_attributes else None), pre_nms_top_k=self._config_dict['pre_nms_top_k'], pre_nms_score_threshold=self._config_dict['pre_nms_score_threshold'], nms_iou_threshold=self._config_dict['nms_iou_threshold'], max_num_detections=self._config_dict['max_num_detections'], soft_nms_sigma=self._config_dict['soft_nms_sigma'])
        elif (self._config_dict['nms_version'] == 'v2'):
            (nmsed_boxes, nmsed_scores, nmsed_classes, valid_detections) = _generate_detections_v2(boxes, scores, pre_nms_top_k=self._config_dict['pre_nms_top_k'], pre_nms_score_threshold=self._config_dict['pre_nms_score_threshold'], nms_iou_threshold=self._config_dict['nms_iou_threshold'], max_num_detections=self._config_dict['max_num_detections'])
            nmsed_attributes = {}
        else:
            raise ValueError('NMS version {} not supported.'.format(self._config_dict['nms_version']))
    nmsed_classes += 1
    return {'num_detections': valid_detections, 'detection_boxes': nmsed_boxes, 'detection_classes': nmsed_classes, 'detection_scores': nmsed_scores, 'detection_attributes': nmsed_attributes}