class_docstr: Assign the ground truth bounding boxes to anchors.
  
  Assigns the ground truth bounding boxes to anchors for training Region
  Proposal Networks introduced in Faster R-CNN [#]_.
  
  Offsets and scales to match anchors to the ground truth are
  calculated using the encoding scheme of
  :func:`~chainercv.links.model.faster_rcnn.bbox2loc`.
  
  .. [#] Shaoqing Ren, Kaiming He, Ross Girshick, Jian Sun.     Faster R-CNN: Towards Real-Time Object Detection with     Region Proposal Networks. NIPS 2015.
  
  Args:
      n_sample (int): The number of regions to produce.
      pos_iou_thresh (float): Anchors with IoU above this
          threshold will be assigned as positive.
      neg_iou_thresh (float): Anchors with IoU below this
          threshold will be assigned as negative.
      pos_ratio (float): Ratio of positive regions in the
          sampled regions.
class_docstr_tok: ["Assign","the","ground","truth","bounding","boxes","to","anchors",".","Assigns","the","ground","truth","bounding","boxes","to","anchors","for","training","Region","Proposal","Networks","introduced","in","Faster","R-CNN","[","#","]","_.","Offsets","and","scales","to","match","anchors","to","the","ground","truth","are","calculated","using","the","encoding","scheme","of",":","func",":","`","~chainercv.links.model.faster_rcnn.bbox2loc","`",".","..","[","#","]","Shaoqing","Ren",",","Kaiming","He",",","Ross","Girshick",",","Jian","Sun",".","Faster","R-CNN",":","Towards","Real-Time","Object","Detection","with","Region","Proposal","Networks",".","NIPS","2015",".","Args",":","n_sample","(","int",")",":","The","number","of","regions","to","produce",".","pos_iou_thresh","(","float",")",":","Anchors","with","IoU","above","this","threshold","will","be","assigned","as","positive",".","neg_iou_thresh","(","float",")",":","Anchors","with","IoU","below","this","threshold","will","be","assigned","as","negative",".","pos_ratio","(","float",")",":","Ratio","of","positive","regions","in","the","sampled","regions","."]
code: def _create_label(self, inside_index, anchor, bbox):
      # label: 1 is positive, 0 is negative, -1 is dont care
      label = np.empty((len(inside_index),), dtype=np.int32)
      label.fill(-1)
  
      argmax_ious, max_ious, gt_argmax_ious = self._calc_ious(
          anchor, bbox, inside_index
      )
  
      # assign negative labels first so that positive labels can clobber them
      label[max_ious < self.neg_iou_thresh] = 0
  
      # positive label: for each gt, anchor with highest iou
      label[gt_argmax_ious] = 1
  
      # positive label: above threshold IOU
      label[max_ious >= self.pos_iou_thresh] = 1
  
      # subsample positive labels if we have too many
      n_pos = int(self.pos_ratio * self.n_sample)
      pos_index = np.where(label == 1)[0]
      if len(pos_index) > n_pos:
          disable_index = np.random.choice(
              pos_index, size=(len(pos_index) - n_pos), replace=False
          )
          label[disable_index] = -1
  
      # subsample negative labels if we have too many
      n_neg = self.n_sample - np.sum(label == 1)
      neg_index = np.where(label == 0)[0]
      if len(neg_index) > n_neg:
          disable_index = np.random.choice(
              neg_index, size=(len(neg_index) - n_neg), replace=False
          )
          label[disable_index] = -1
  
      return argmax_ious, label
  
file_path: chainercv/chainercv/links/model/faster_rcnn/utils/anchor_target_creator.py
imports: import numpy
  import chainer
  from chainer.backends import cuda
  from chainercv.links.model.faster_rcnn.utils.bbox2loc import bbox2loc
  from chainercv.utils.bbox.bbox_iou import bbox_iou
label_desc: Use image node_id 3 for calling the AnchorTargetCreator obj's underlying member method code with example usage: obj._create_label(inside_index, anchor, bbox) and returns: argmax_ious,  label