def retinanet_target_assign(bbox_pred, cls_logits, anchor_box, anchor_var, gt_boxes, gt_labels, is_crowd, im_info, num_classes=1, positive_overlap=0.5, negative_overlap=0.4):
    "\n    **Target Assign Layer for the detector RetinaNet.**\n\n    This OP finds out positive and negative samples from all anchors\n    for training the detector `RetinaNet <https://arxiv.org/abs/1708.02002>`_ ,\n    and assigns target labels for classification along with target locations for\n    regression to each sample, then takes out the part belonging to positive and\n    negative samples from category prediction( :attr:`cls_logits`) and location\n    prediction( :attr:`bbox_pred`) which belong to all anchors.\n\n    The searching principles for positive and negative samples are as followed:\n\n    1. Anchors are assigned to ground-truth boxes when it has the highest IoU\n    overlap with a ground-truth box.\n\n    2. Anchors are assigned to ground-truth boxes when it has an IoU overlap\n    higher than :attr:`positive_overlap` with any ground-truth box.\n\n    3. Anchors are assigned to background when its IoU overlap is lower than\n    :attr:`negative_overlap` for all ground-truth boxes.\n\n    4. Anchors which do not meet the above conditions do not participate in\n    the training process.\n\n    Retinanet predicts a :math:`C`-vector for classification and a 4-vector for box\n    regression for each anchor, hence the target label for each positive(or negative)\n    sample is a :math:`C`-vector and the target locations for each positive sample\n    is a 4-vector. As for a positive sample, if the category of its assigned\n    ground-truth box is class :math:`i`, the corresponding entry in its length\n    :math:`C` label vector is set to 1 and all other entries is set to 0, its box\n    regression targets are computed as the offset between itself and its assigned\n    ground-truth box. As for a negative sample, all entries in its length :math:`C`\n    label vector are set to 0 and box regression targets are omitted because\n    negative samples do not participate in the training process of location\n    regression.\n\n    After the assignment, the part belonging to positive and negative samples is\n    taken out from category prediction( :attr:`cls_logits` ), and the part\n    belonging to positive samples is taken out from location\n    prediction( :attr:`bbox_pred` ).\n\n    Args:\n        bbox_pred(Variable): A 3-D Tensor with shape :math:`[N, M, 4]` represents\n            the predicted locations of all anchors. :math:`N` is the batch size( the\n            number of images in a mini-batch), :math:`M` is the number of all anchors\n            of one image, and each anchor has 4 coordinate values. The data type of\n            :attr:`bbox_pred` is float32 or float64.\n        cls_logits(Variable): A 3-D Tensor with shape :math:`[N, M, C]` represents\n            the predicted categories of all anchors. :math:`N` is the batch size,\n            :math:`M` is the number of all anchors of one image, and :math:`C` is\n            the number of categories (**Notice: excluding background**). The data type\n            of :attr:`cls_logits` is float32 or float64.\n        anchor_box(Variable): A 2-D Tensor with shape :math:`[M, 4]` represents\n            the locations of all anchors. :math:`M` is the number of all anchors of\n            one image, each anchor is represented as :math:`[xmin, ymin, xmax, ymax]`,\n            :math:`[xmin, ymin]` is the left top coordinate of the anchor box,\n            :math:`[xmax, ymax]` is the right bottom coordinate of the anchor box.\n            The data type of :attr:`anchor_box` is float32 or float64. Please refer\n            to the OP :ref:`api_fluid_layers_anchor_generator` \n            for the generation of :attr:`anchor_box`.\n        anchor_var(Variable): A 2-D Tensor with shape :math:`[M,4]` represents the expanded \n            factors of anchor locations used in loss function. :math:`M` is number of\n            all anchors of one image, each anchor possesses a 4-vector expanded factor.\n            The data type of :attr:`anchor_var` is float32 or float64. Please refer\n            to the OP :ref:`api_fluid_layers_anchor_generator`\n            for the generation of :attr:`anchor_var`.\n        gt_boxes(Variable): A 1-level 2-D LoDTensor with shape :math:`[G, 4]` represents\n            locations of all ground-truth boxes. :math:`G` is the total number of\n            all ground-truth boxes in a mini-batch, and each ground-truth box has 4\n            coordinate values. The data type of :attr:`gt_boxes` is float32 or\n            float64.\n        gt_labels(variable): A 1-level 2-D LoDTensor with shape :math:`[G, 1]` represents\n            categories of all ground-truth boxes, and the values are in the range of\n            :math:`[1, C]`. :math:`G` is the total number of all ground-truth boxes\n            in a mini-batch, and each ground-truth box has one category. The data type\n            of :attr:`gt_labels` is int32.\n        is_crowd(Variable): A 1-level 1-D LoDTensor with shape :math:`[G]` which\n            indicates whether a ground-truth box is a crowd. If the value is 1, the\n            corresponding box is a crowd, it is ignored during training. :math:`G` is\n            the total number of all ground-truth boxes in a mini-batch. The data type\n            of :attr:`is_crowd` is int32.\n        im_info(Variable): A 2-D Tensor with shape [N, 3] represents the size\n            information of input images. :math:`N` is the batch size, the size\n            information of each image is a 3-vector which are the height and width\n            of the network input along with the factor scaling the origin image to\n            the network input. The data type of :attr:`im_info` is float32.\n        num_classes(int32): The number of categories for classification, the default\n            value is 1.\n        positive_overlap(float32): Minimum overlap required between an anchor\n            and ground-truth box for the anchor to be a positive sample, the default\n            value is 0.5.\n        negative_overlap(float32): Maximum overlap allowed between an anchor\n            and ground-truth box for the anchor to be a negative sample, the default\n            value is 0.4. :attr:`negative_overlap` should be less than or equal to\n            :attr:`positive_overlap`, if not, the actual value of\n            :attr:`positive_overlap` is :attr:`negative_overlap`.\n\n    Returns:\n        A tuple with 6 Variables:\n        \n        **predict_scores** (Variable): A 2-D Tensor with shape :math:`[F+B, C]` represents\n        category prediction belonging to positive and negative samples. :math:`F`\n        is the number of positive samples in a mini-batch, :math:`B` is the number\n        of negative samples, and :math:`C` is the number of categories\n        (**Notice: excluding background**). The data type of :attr:`predict_scores`\n        is float32 or float64.\n\n        **predict_location** (Variable): A 2-D Tensor with shape :math:`[F, 4]` represents\n        location prediction belonging to positive samples. :math:`F` is the number\n        of positive samples. :math:`F` is the number of positive samples, and each\n        sample has 4 coordinate values. The data type of :attr:`predict_location`\n        is float32 or float64.\n\n        **target_label** (Variable): A 2-D Tensor with shape :math:`[F+B, 1]` represents\n        target labels for classification belonging to positive and negative\n        samples. :math:`F` is the number of positive samples, :math:`B` is the\n        number of negative, and each sample has one target category. The data type\n        of :attr:`target_label` is int32.\n\n        **target_bbox** (Variable): A 2-D Tensor with shape :math:`[F, 4]` represents\n        target locations for box regression belonging to positive samples.\n        :math:`F` is the number of positive samples, and each sample has 4\n        coordinate values. The data type of :attr:`target_bbox` is float32 or\n        float64.\n\n        **bbox_inside_weight** (Variable): A 2-D Tensor with shape :math:`[F, 4]`\n        represents whether a positive sample is fake positive, if a positive\n        sample is false positive, the corresponding entries in\n        :attr:`bbox_inside_weight` are set 0, otherwise 1. :math:`F` is the number\n        of total positive samples in a mini-batch, and each sample has 4\n        coordinate values. The data type of :attr:`bbox_inside_weight` is float32\n        or float64.\n\n        **fg_num** (Variable): A 2-D Tensor with shape :math:`[N, 1]` represents the number\n        of positive samples. :math:`N` is the batch size. **Notice: The number\n        of positive samples is used as the denominator of later loss function,\n        to avoid the condition that the denominator is zero, this OP has added 1\n        to the actual number of positive samples of each image.** The data type of\n        :attr:`fg_num` is int32.\n\n    Examples:\n        .. code-block:: python\n\n          import paddle.fluid as fluid\n          bbox_pred = fluid.data(name='bbox_pred', shape=[1, 100, 4],\n                            dtype='float32')\n          cls_logits = fluid.data(name='cls_logits', shape=[1, 100, 10],\n                            dtype='float32')\n          anchor_box = fluid.data(name='anchor_box', shape=[100, 4],\n                            dtype='float32')\n          anchor_var = fluid.data(name='anchor_var', shape=[100, 4],\n                            dtype='float32')\n          gt_boxes = fluid.data(name='gt_boxes', shape=[10, 4],\n                            dtype='float32')\n          gt_labels = fluid.data(name='gt_labels', shape=[10, 1],\n                            dtype='int32')\n          is_crowd = fluid.data(name='is_crowd', shape=[1],\n                            dtype='int32')\n          im_info = fluid.data(name='im_info', shape=[1, 3],\n                            dtype='float32')\n          score_pred, loc_pred, score_target, loc_target, bbox_inside_weight, fg_num = \\\n                fluid.layers.retinanet_target_assign(bbox_pred, cls_logits, anchor_box,\n                anchor_var, gt_boxes, gt_labels, is_crowd, im_info, 10)\n\n    "
    check_variable_and_dtype(bbox_pred, 'bbox_pred', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(cls_logits, 'cls_logits', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(anchor_box, 'anchor_box', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(anchor_var, 'anchor_var', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(gt_boxes, 'gt_boxes', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(gt_labels, 'gt_labels', ['int32'], 'retinanet_target_assign')
    check_variable_and_dtype(is_crowd, 'is_crowd', ['int32'], 'retinanet_target_assign')
    check_variable_and_dtype(im_info, 'im_info', ['float32', 'float64'], 'retinanet_target_assign')
    helper = LayerHelper('retinanet_target_assign', **locals())
    loc_index = helper.create_variable_for_type_inference(dtype='int32')
    score_index = helper.create_variable_for_type_inference(dtype='int32')
    target_label = helper.create_variable_for_type_inference(dtype='int32')
    target_bbox = helper.create_variable_for_type_inference(dtype=anchor_box.dtype)
    bbox_inside_weight = helper.create_variable_for_type_inference(dtype=anchor_box.dtype)
    fg_num = helper.create_variable_for_type_inference(dtype='int32')
    helper.append_op(type='retinanet_target_assign', inputs={'Anchor': anchor_box, 'GtBoxes': gt_boxes, 'GtLabels': gt_labels, 'IsCrowd': is_crowd, 'ImInfo': im_info}, outputs={'LocationIndex': loc_index, 'ScoreIndex': score_index, 'TargetLabel': target_label, 'TargetBBox': target_bbox, 'BBoxInsideWeight': bbox_inside_weight, 'ForegroundNumber': fg_num}, attrs={'positive_overlap': positive_overlap, 'negative_overlap': negative_overlap})
    loc_index.stop_gradient = True
    score_index.stop_gradient = True
    target_label.stop_gradient = True
    target_bbox.stop_gradient = True
    bbox_inside_weight.stop_gradient = True
    fg_num.stop_gradient = True
    cls_logits = nn.reshape(x=cls_logits, shape=((- 1), num_classes))
    bbox_pred = nn.reshape(x=bbox_pred, shape=((- 1), 4))
    predicted_cls_logits = nn.gather(cls_logits, score_index)
    predicted_bbox_pred = nn.gather(bbox_pred, loc_index)
    return (predicted_cls_logits, predicted_bbox_pred, target_label, target_bbox, bbox_inside_weight, fg_num)
**Target Assign Layer for the detector RetinaNet.**

This OP finds out positive and negative samples from all anchors
for training the detector `RetinaNet <https://arxiv.org/abs/1708.02002>`_ ,
and assigns target labels for classification along with target locations for
regression to each sample, then takes out the part belonging to positive and
negative samples from category prediction( :attr:`cls_logits`) and location
prediction( :attr:`bbox_pred`) which belong to all anchors.

The searching principles for positive and negative samples are as followed:

1. Anchors are assigned to ground-truth boxes when it has the highest IoU
overlap with a ground-truth box.

2. Anchors are assigned to ground-truth boxes when it has an IoU overlap
higher than :attr:`positive_overlap` with any ground-truth box.

3. Anchors are assigned to background when its IoU overlap is lower than
:attr:`negative_overlap` for all ground-truth boxes.

4. Anchors which do not meet the above conditions do not participate in
the training process.

Retinanet predicts a :math:`C`-vector for classification and a 4-vector for box
regression for each anchor, hence the target label for each positive(or negative)
sample is a :math:`C`-vector and the target locations for each positive sample
is a 4-vector. As for a positive sample, if the category of its assigned
ground-truth box is class :math:`i`, the corresponding entry in its length
:math:`C` label vector is set to 1 and all other entries is set to 0, its box
regression targets are computed as the offset between itself and its assigned
ground-truth box. As for a negative sample, all entries in its length :math:`C`
label vector are set to 0 and box regression targets are omitted because
negative samples do not participate in the training process of location
regression.

After the assignment, the part belonging to positive and negative samples is
taken out from category prediction( :attr:`cls_logits` ), and the part
belonging to positive samples is taken out from location
prediction( :attr:`bbox_pred` ).

Args:
    bbox_pred(Variable): A 3-D Tensor with shape :math:`[N, M, 4]` represents
        the predicted locations of all anchors. :math:`N` is the batch size( the
        number of images in a mini-batch), :math:`M` is the number of all anchors
        of one image, and each anchor has 4 coordinate values. The data type of
        :attr:`bbox_pred` is float32 or float64.
    cls_logits(Variable): A 3-D Tensor with shape :math:`[N, M, C]` represents
        the predicted categories of all anchors. :math:`N` is the batch size,
        :math:`M` is the number of all anchors of one image, and :math:`C` is
        the number of categories (**Notice: excluding background**). The data type
        of :attr:`cls_logits` is float32 or float64.
    anchor_box(Variable): A 2-D Tensor with shape :math:`[M, 4]` represents
        the locations of all anchors. :math:`M` is the number of all anchors of
        one image, each anchor is represented as :math:`[xmin, ymin, xmax, ymax]`,
        :math:`[xmin, ymin]` is the left top coordinate of the anchor box,
        :math:`[xmax, ymax]` is the right bottom coordinate of the anchor box.
        The data type of :attr:`anchor_box` is float32 or float64. Please refer
        to the OP :ref:`api_fluid_layers_anchor_generator` 
        for the generation of :attr:`anchor_box`.
    anchor_var(Variable): A 2-D Tensor with shape :math:`[M,4]` represents the expanded 
        factors of anchor locations used in loss function. :math:`M` is number of
        all anchors of one image, each anchor possesses a 4-vector expanded factor.
        The data type of :attr:`anchor_var` is float32 or float64. Please refer
        to the OP :ref:`api_fluid_layers_anchor_generator`
        for the generation of :attr:`anchor_var`.
    gt_boxes(Variable): A 1-level 2-D LoDTensor with shape :math:`[G, 4]` represents
        locations of all ground-truth boxes. :math:`G` is the total number of
        all ground-truth boxes in a mini-batch, and each ground-truth box has 4
        coordinate values. The data type of :attr:`gt_boxes` is float32 or
        float64.
    gt_labels(variable): A 1-level 2-D LoDTensor with shape :math:`[G, 1]` represents
        categories of all ground-truth boxes, and the values are in the range of
        :math:`[1, C]`. :math:`G` is the total number of all ground-truth boxes
        in a mini-batch, and each ground-truth box has one category. The data type
        of :attr:`gt_labels` is int32.
    is_crowd(Variable): A 1-level 1-D LoDTensor with shape :math:`[G]` which
        indicates whether a ground-truth box is a crowd. If the value is 1, the
        corresponding box is a crowd, it is ignored during training. :math:`G` is
        the total number of all ground-truth boxes in a mini-batch. The data type
        of :attr:`is_crowd` is int32.
    im_info(Variable): A 2-D Tensor with shape [N, 3] represents the size
        information of input images. :math:`N` is the batch size, the size
        information of each image is a 3-vector which are the height and width
        of the network input along with the factor scaling the origin image to
        the network input. The data type of :attr:`im_info` is float32.
    num_classes(int32): The number of categories for classification, the default
        value is 1.
    positive_overlap(float32): Minimum overlap required between an anchor
        and ground-truth box for the anchor to be a positive sample, the default
        value is 0.5.
    negative_overlap(float32): Maximum overlap allowed between an anchor
        and ground-truth box for the anchor to be a negative sample, the default
        value is 0.4. :attr:`negative_overlap` should be less than or equal to
        :attr:`positive_overlap`, if not, the actual value of
        :attr:`positive_overlap` is :attr:`negative_overlap`.

Returns:
    A tuple with 6 Variables:
    
    **predict_scores** (Variable): A 2-D Tensor with shape :math:`[F+B, C]` represents
    category prediction belonging to positive and negative samples. :math:`F`
    is the number of positive samples in a mini-batch, :math:`B` is the number
    of negative samples, and :math:`C` is the number of categories
    (**Notice: excluding background**). The data type of :attr:`predict_scores`
    is float32 or float64.

    **predict_location** (Variable): A 2-D Tensor with shape :math:`[F, 4]` represents
    location prediction belonging to positive samples. :math:`F` is the number
    of positive samples. :math:`F` is the number of positive samples, and each
    sample has 4 coordinate values. The data type of :attr:`predict_location`
    is float32 or float64.

    **target_label** (Variable): A 2-D Tensor with shape :math:`[F+B, 1]` represents
    target labels for classification belonging to positive and negative
    samples. :math:`F` is the number of positive samples, :math:`B` is the
    number of negative, and each sample has one target category. The data type
    of :attr:`target_label` is int32.

    **target_bbox** (Variable): A 2-D Tensor with shape :math:`[F, 4]` represents
    target locations for box regression belonging to positive samples.
    :math:`F` is the number of positive samples, and each sample has 4
    coordinate values. The data type of :attr:`target_bbox` is float32 or
    float64.

    **bbox_inside_weight** (Variable): A 2-D Tensor with shape :math:`[F, 4]`
    represents whether a positive sample is fake positive, if a positive
    sample is false positive, the corresponding entries in
    :attr:`bbox_inside_weight` are set 0, otherwise 1. :math:`F` is the number
    of total positive samples in a mini-batch, and each sample has 4
    coordinate values. The data type of :attr:`bbox_inside_weight` is float32
    or float64.

    **fg_num** (Variable): A 2-D Tensor with shape :math:`[N, 1]` represents the number
    of positive samples. :math:`N` is the batch size. **Notice: The number
    of positive samples is used as the denominator of later loss function,
    to avoid the condition that the denominator is zero, this OP has added 1
    to the actual number of positive samples of each image.** The data type of
    :attr:`fg_num` is int32.

Examples:
    .. code-block:: python

      import paddle.fluid as fluid
      bbox_pred = fluid.data(name='bbox_pred', shape=[1, 100, 4],
                        dtype='float32')
      cls_logits = fluid.data(name='cls_logits', shape=[1, 100, 10],
                        dtype='float32')
      anchor_box = fluid.data(name='anchor_box', shape=[100, 4],
                        dtype='float32')
      anchor_var = fluid.data(name='anchor_var', shape=[100, 4],
                        dtype='float32')
      gt_boxes = fluid.data(name='gt_boxes', shape=[10, 4],
                        dtype='float32')
      gt_labels = fluid.data(name='gt_labels', shape=[10, 1],
                        dtype='int32')
      is_crowd = fluid.data(name='is_crowd', shape=[1],
                        dtype='int32')
      im_info = fluid.data(name='im_info', shape=[1, 3],
                        dtype='float32')
      score_pred, loc_pred, score_target, loc_target, bbox_inside_weight, fg_num = \
            fluid.layers.retinanet_target_assign(bbox_pred, cls_logits, anchor_box,
            anchor_var, gt_boxes, gt_labels, is_crowd, im_info, 10)
def retinanet_target_assign(bbox_pred, cls_logits, anchor_box, anchor_var, gt_boxes, gt_labels, is_crowd, im_info, num_classes=1, positive_overlap=0.5, negative_overlap=0.4):
    "\n    **Target Assign Layer for the detector RetinaNet.**\n\n    This OP finds out positive and negative samples from all anchors\n    for training the detector `RetinaNet <https://arxiv.org/abs/1708.02002>`_ ,\n    and assigns target labels for classification along with target locations for\n    regression to each sample, then takes out the part belonging to positive and\n    negative samples from category prediction( :attr:`cls_logits`) and location\n    prediction( :attr:`bbox_pred`) which belong to all anchors.\n\n    The searching principles for positive and negative samples are as followed:\n\n    1. Anchors are assigned to ground-truth boxes when it has the highest IoU\n    overlap with a ground-truth box.\n\n    2. Anchors are assigned to ground-truth boxes when it has an IoU overlap\n    higher than :attr:`positive_overlap` with any ground-truth box.\n\n    3. Anchors are assigned to background when its IoU overlap is lower than\n    :attr:`negative_overlap` for all ground-truth boxes.\n\n    4. Anchors which do not meet the above conditions do not participate in\n    the training process.\n\n    Retinanet predicts a :math:`C`-vector for classification and a 4-vector for box\n    regression for each anchor, hence the target label for each positive(or negative)\n    sample is a :math:`C`-vector and the target locations for each positive sample\n    is a 4-vector. As for a positive sample, if the category of its assigned\n    ground-truth box is class :math:`i`, the corresponding entry in its length\n    :math:`C` label vector is set to 1 and all other entries is set to 0, its box\n    regression targets are computed as the offset between itself and its assigned\n    ground-truth box. As for a negative sample, all entries in its length :math:`C`\n    label vector are set to 0 and box regression targets are omitted because\n    negative samples do not participate in the training process of location\n    regression.\n\n    After the assignment, the part belonging to positive and negative samples is\n    taken out from category prediction( :attr:`cls_logits` ), and the part\n    belonging to positive samples is taken out from location\n    prediction( :attr:`bbox_pred` ).\n\n    Args:\n        bbox_pred(Variable): A 3-D Tensor with shape :math:`[N, M, 4]` represents\n            the predicted locations of all anchors. :math:`N` is the batch size( the\n            number of images in a mini-batch), :math:`M` is the number of all anchors\n            of one image, and each anchor has 4 coordinate values. The data type of\n            :attr:`bbox_pred` is float32 or float64.\n        cls_logits(Variable): A 3-D Tensor with shape :math:`[N, M, C]` represents\n            the predicted categories of all anchors. :math:`N` is the batch size,\n            :math:`M` is the number of all anchors of one image, and :math:`C` is\n            the number of categories (**Notice: excluding background**). The data type\n            of :attr:`cls_logits` is float32 or float64.\n        anchor_box(Variable): A 2-D Tensor with shape :math:`[M, 4]` represents\n            the locations of all anchors. :math:`M` is the number of all anchors of\n            one image, each anchor is represented as :math:`[xmin, ymin, xmax, ymax]`,\n            :math:`[xmin, ymin]` is the left top coordinate of the anchor box,\n            :math:`[xmax, ymax]` is the right bottom coordinate of the anchor box.\n            The data type of :attr:`anchor_box` is float32 or float64. Please refer\n            to the OP :ref:`api_fluid_layers_anchor_generator` \n            for the generation of :attr:`anchor_box`.\n        anchor_var(Variable): A 2-D Tensor with shape :math:`[M,4]` represents the expanded \n            factors of anchor locations used in loss function. :math:`M` is number of\n            all anchors of one image, each anchor possesses a 4-vector expanded factor.\n            The data type of :attr:`anchor_var` is float32 or float64. Please refer\n            to the OP :ref:`api_fluid_layers_anchor_generator`\n            for the generation of :attr:`anchor_var`.\n        gt_boxes(Variable): A 1-level 2-D LoDTensor with shape :math:`[G, 4]` represents\n            locations of all ground-truth boxes. :math:`G` is the total number of\n            all ground-truth boxes in a mini-batch, and each ground-truth box has 4\n            coordinate values. The data type of :attr:`gt_boxes` is float32 or\n            float64.\n        gt_labels(variable): A 1-level 2-D LoDTensor with shape :math:`[G, 1]` represents\n            categories of all ground-truth boxes, and the values are in the range of\n            :math:`[1, C]`. :math:`G` is the total number of all ground-truth boxes\n            in a mini-batch, and each ground-truth box has one category. The data type\n            of :attr:`gt_labels` is int32.\n        is_crowd(Variable): A 1-level 1-D LoDTensor with shape :math:`[G]` which\n            indicates whether a ground-truth box is a crowd. If the value is 1, the\n            corresponding box is a crowd, it is ignored during training. :math:`G` is\n            the total number of all ground-truth boxes in a mini-batch. The data type\n            of :attr:`is_crowd` is int32.\n        im_info(Variable): A 2-D Tensor with shape [N, 3] represents the size\n            information of input images. :math:`N` is the batch size, the size\n            information of each image is a 3-vector which are the height and width\n            of the network input along with the factor scaling the origin image to\n            the network input. The data type of :attr:`im_info` is float32.\n        num_classes(int32): The number of categories for classification, the default\n            value is 1.\n        positive_overlap(float32): Minimum overlap required between an anchor\n            and ground-truth box for the anchor to be a positive sample, the default\n            value is 0.5.\n        negative_overlap(float32): Maximum overlap allowed between an anchor\n            and ground-truth box for the anchor to be a negative sample, the default\n            value is 0.4. :attr:`negative_overlap` should be less than or equal to\n            :attr:`positive_overlap`, if not, the actual value of\n            :attr:`positive_overlap` is :attr:`negative_overlap`.\n\n    Returns:\n        A tuple with 6 Variables:\n        \n        **predict_scores** (Variable): A 2-D Tensor with shape :math:`[F+B, C]` represents\n        category prediction belonging to positive and negative samples. :math:`F`\n        is the number of positive samples in a mini-batch, :math:`B` is the number\n        of negative samples, and :math:`C` is the number of categories\n        (**Notice: excluding background**). The data type of :attr:`predict_scores`\n        is float32 or float64.\n\n        **predict_location** (Variable): A 2-D Tensor with shape :math:`[F, 4]` represents\n        location prediction belonging to positive samples. :math:`F` is the number\n        of positive samples. :math:`F` is the number of positive samples, and each\n        sample has 4 coordinate values. The data type of :attr:`predict_location`\n        is float32 or float64.\n\n        **target_label** (Variable): A 2-D Tensor with shape :math:`[F+B, 1]` represents\n        target labels for classification belonging to positive and negative\n        samples. :math:`F` is the number of positive samples, :math:`B` is the\n        number of negative, and each sample has one target category. The data type\n        of :attr:`target_label` is int32.\n\n        **target_bbox** (Variable): A 2-D Tensor with shape :math:`[F, 4]` represents\n        target locations for box regression belonging to positive samples.\n        :math:`F` is the number of positive samples, and each sample has 4\n        coordinate values. The data type of :attr:`target_bbox` is float32 or\n        float64.\n\n        **bbox_inside_weight** (Variable): A 2-D Tensor with shape :math:`[F, 4]`\n        represents whether a positive sample is fake positive, if a positive\n        sample is false positive, the corresponding entries in\n        :attr:`bbox_inside_weight` are set 0, otherwise 1. :math:`F` is the number\n        of total positive samples in a mini-batch, and each sample has 4\n        coordinate values. The data type of :attr:`bbox_inside_weight` is float32\n        or float64.\n\n        **fg_num** (Variable): A 2-D Tensor with shape :math:`[N, 1]` represents the number\n        of positive samples. :math:`N` is the batch size. **Notice: The number\n        of positive samples is used as the denominator of later loss function,\n        to avoid the condition that the denominator is zero, this OP has added 1\n        to the actual number of positive samples of each image.** The data type of\n        :attr:`fg_num` is int32.\n\n    Examples:\n        .. code-block:: python\n\n          import paddle.fluid as fluid\n          bbox_pred = fluid.data(name='bbox_pred', shape=[1, 100, 4],\n                            dtype='float32')\n          cls_logits = fluid.data(name='cls_logits', shape=[1, 100, 10],\n                            dtype='float32')\n          anchor_box = fluid.data(name='anchor_box', shape=[100, 4],\n                            dtype='float32')\n          anchor_var = fluid.data(name='anchor_var', shape=[100, 4],\n                            dtype='float32')\n          gt_boxes = fluid.data(name='gt_boxes', shape=[10, 4],\n                            dtype='float32')\n          gt_labels = fluid.data(name='gt_labels', shape=[10, 1],\n                            dtype='int32')\n          is_crowd = fluid.data(name='is_crowd', shape=[1],\n                            dtype='int32')\n          im_info = fluid.data(name='im_info', shape=[1, 3],\n                            dtype='float32')\n          score_pred, loc_pred, score_target, loc_target, bbox_inside_weight, fg_num = \\\n                fluid.layers.retinanet_target_assign(bbox_pred, cls_logits, anchor_box,\n                anchor_var, gt_boxes, gt_labels, is_crowd, im_info, 10)\n\n    "
    check_variable_and_dtype(bbox_pred, 'bbox_pred', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(cls_logits, 'cls_logits', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(anchor_box, 'anchor_box', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(anchor_var, 'anchor_var', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(gt_boxes, 'gt_boxes', ['float32', 'float64'], 'retinanet_target_assign')
    check_variable_and_dtype(gt_labels, 'gt_labels', ['int32'], 'retinanet_target_assign')
    check_variable_and_dtype(is_crowd, 'is_crowd', ['int32'], 'retinanet_target_assign')
    check_variable_and_dtype(im_info, 'im_info', ['float32', 'float64'], 'retinanet_target_assign')
    helper = LayerHelper('retinanet_target_assign', **locals())
    loc_index = helper.create_variable_for_type_inference(dtype='int32')
    score_index = helper.create_variable_for_type_inference(dtype='int32')
    target_label = helper.create_variable_for_type_inference(dtype='int32')
    target_bbox = helper.create_variable_for_type_inference(dtype=anchor_box.dtype)
    bbox_inside_weight = helper.create_variable_for_type_inference(dtype=anchor_box.dtype)
    fg_num = helper.create_variable_for_type_inference(dtype='int32')
    helper.append_op(type='retinanet_target_assign', inputs={'Anchor': anchor_box, 'GtBoxes': gt_boxes, 'GtLabels': gt_labels, 'IsCrowd': is_crowd, 'ImInfo': im_info}, outputs={'LocationIndex': loc_index, 'ScoreIndex': score_index, 'TargetLabel': target_label, 'TargetBBox': target_bbox, 'BBoxInsideWeight': bbox_inside_weight, 'ForegroundNumber': fg_num}, attrs={'positive_overlap': positive_overlap, 'negative_overlap': negative_overlap})
    loc_index.stop_gradient = True
    score_index.stop_gradient = True
    target_label.stop_gradient = True
    target_bbox.stop_gradient = True
    bbox_inside_weight.stop_gradient = True
    fg_num.stop_gradient = True
    cls_logits = nn.reshape(x=cls_logits, shape=((- 1), num_classes))
    bbox_pred = nn.reshape(x=bbox_pred, shape=((- 1), 4))
    predicted_cls_logits = nn.gather(cls_logits, score_index)
    predicted_bbox_pred = nn.gather(bbox_pred, loc_index)
    return (predicted_cls_logits, predicted_bbox_pred, target_label, target_bbox, bbox_inside_weight, fg_num)