def gather_topk_anchors(metrics, topk, largest=True, topk_mask=None, eps=1e-09):
    '\n    Args:\n        metrics (Tensor, float32): shape[B, n, L], n: num_gts, L: num_anchors\n        topk (int): The number of top elements to look for along the axis.\n        largest (bool) : largest is a flag, if set to true,\n            algorithm will sort by descending order, otherwise sort by\n            ascending order. Default: True\n        topk_mask (Tensor, bool|None): shape[B, n, topk], ignore bbox mask,\n            Default: None\n        eps (float): Default: 1e-9\n    Returns:\n        is_in_topk (Tensor, float32): shape[B, n, L], value=1. means selected\n    '
    num_anchors = metrics.shape[(- 1)]
    (topk_metrics, topk_idxs) = paddle.topk(metrics, topk, axis=(- 1), largest=largest)
    if (topk_mask is None):
        topk_mask = (topk_metrics.max(axis=(- 1), keepdim=True) > eps).tile([1, 1, topk])
    topk_idxs = paddle.where(topk_mask, topk_idxs, paddle.zeros_like(topk_idxs))
    is_in_topk = F.one_hot(topk_idxs, num_anchors).sum(axis=(- 2))
    is_in_topk = paddle.where((is_in_topk > 1), paddle.zeros_like(is_in_topk), is_in_topk)
    return is_in_topk.astype(metrics.dtype)
Args:
    metrics (Tensor, float32): shape[B, n, L], n: num_gts, L: num_anchors
    topk (int): The number of top elements to look for along the axis.
    largest (bool) : largest is a flag, if set to true,
        algorithm will sort by descending order, otherwise sort by
        ascending order. Default: True
    topk_mask (Tensor, bool|None): shape[B, n, topk], ignore bbox mask,
        Default: None
    eps (float): Default: 1e-9
Returns:
    is_in_topk (Tensor, float32): shape[B, n, L], value=1. means selected
def gather_topk_anchors(metrics, topk, largest=True, topk_mask=None, eps=1e-09):
    '\n    Args:\n        metrics (Tensor, float32): shape[B, n, L], n: num_gts, L: num_anchors\n        topk (int): The number of top elements to look for along the axis.\n        largest (bool) : largest is a flag, if set to true,\n            algorithm will sort by descending order, otherwise sort by\n            ascending order. Default: True\n        topk_mask (Tensor, bool|None): shape[B, n, topk], ignore bbox mask,\n            Default: None\n        eps (float): Default: 1e-9\n    Returns:\n        is_in_topk (Tensor, float32): shape[B, n, L], value=1. means selected\n    '
    num_anchors = metrics.shape[(- 1)]
    (topk_metrics, topk_idxs) = paddle.topk(metrics, topk, axis=(- 1), largest=largest)
    if (topk_mask is None):
        topk_mask = (topk_metrics.max(axis=(- 1), keepdim=True) > eps).tile([1, 1, topk])
    topk_idxs = paddle.where(topk_mask, topk_idxs, paddle.zeros_like(topk_idxs))
    is_in_topk = F.one_hot(topk_idxs, num_anchors).sum(axis=(- 2))
    is_in_topk = paddle.where((is_in_topk > 1), paddle.zeros_like(is_in_topk), is_in_topk)
    return is_in_topk.astype(metrics.dtype)