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","."]
docstr: Assign ground truth supervision to sampled subset of anchors.
  
  Types of input arrays and output arrays are same.
  
  Here are notations.
  
  * :math:`S` is the number of anchors.
  * :math:`R` is the number of bounding boxes.
  
  Args:
      bbox (array): Coordinates of bounding boxes. Its shape is
          :math:`(R, 4)`.
      anchor (array): Coordinates of anchors. Its shape is
          :math:`(S, 4)`.
      img_size (tuple of ints): A tuple :obj:`H, W`, which
          is a tuple of height and width of an image.
  
  Returns:
      (array, array):
  
      * **loc**: Offsets and scales to match the anchors to                 the ground truth bounding boxes. Its shape is :math:`(S, 4)`.
      * **label**: Labels of anchors with values                 :obj:`(1=positive, 0=negative, -1=ignore)`. Its shape                 is :math:`(S,)`.
docstr_tok: ["Assign","ground","truth","supervision","to","sampled","subset","of","anchors",".","Types","of","input","arrays","and","output","arrays","are","same",".","Here","are","notations",".","*",":","math",":","`","S","`","is","the","number","of","anchors",".","*",":","math",":","`","R","`","is","the","number","of","bounding","boxes",".","Args",":","bbox","(","array",")",":","Coordinates","of","bounding","boxes",".","Its","shape","is",":","math",":","`","(","R",",","4",")","`",".","anchor","(","array",")",":","Coordinates","of","anchors",".","Its","shape","is",":","math",":","`","(","S",",","4",")","`",".","img_size","(","tuple","of","ints",")",":","A","tuple",":","obj",":","`","H",",","W","`",",","which","is","a","tuple","of","height","and","width","of","an","image",".","Returns",":","(","array",",","array",")",":","*","*","*","loc","*","*",":","Offsets","and","scales","to","match","the","anchors","to","the","ground","truth","bounding","boxes",".","Its","shape","is",":","math",":","`","(","S",",","4",")","`",".","*","*","*","label","*","*",":","Labels","of","anchors","with","values",":","obj",":","`","(","1=positive",",","0=negative",",","-1=ignore",")","`",".","Its","shape","is",":","math",":","`","(","S",",",")","`","."]
code: def __call__(self, bbox, anchor, img_size):
      """Assign ground truth supervision to sampled subset of anchors.
  
          Types of input arrays and output arrays are same.
  
          Here are notations.
  
          * :math:`S` is the number of anchors.
          * :math:`R` is the number of bounding boxes.
  
          Args:
              bbox (array): Coordinates of bounding boxes. Its shape is
                  :math:`(R, 4)`.
              anchor (array): Coordinates of anchors. Its shape is
                  :math:`(S, 4)`.
              img_size (tuple of ints): A tuple :obj:`H, W`, which
                  is a tuple of height and width of an image.
  
          Returns:
              (array, array):
  
              * **loc**: Offsets and scales to match the anchors to \
                  the ground truth bounding boxes. Its shape is :math:`(S, 4)`.
              * **label**: Labels of anchors with values \
                  :obj:`(1=positive, 0=negative, -1=ignore)`. Its shape \
                  is :math:`(S,)`.
  
          """
      xp = cuda.get_array_module(bbox)
      bbox = cuda.to_cpu(bbox)
      anchor = cuda.to_cpu(anchor)
  
      img_H, img_W = img_size
  
      n_anchor = len(anchor)
      inside_index = _get_inside_index(anchor, img_H, img_W)
      anchor = anchor[inside_index]
      argmax_ious, label = self._create_label(
          inside_index, anchor, bbox
      )
  
      # compute bounding box regression targets
      loc = bbox2loc(anchor, bbox[argmax_ious])
  
      # map up to original set of anchors
      label = _unmap(label, n_anchor, inside_index, fill=-1)
      loc = _unmap(loc, n_anchor, inside_index, fill=0)
  
      if xp != np:
          loc = chainer.backends.cuda.to_gpu(loc)
          label = chainer.backends.cuda.to_gpu(label)
      return loc, 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 2 for calling the AnchorTargetCreator obj's underlying member method code with example usage: obj.__call__(bbox, anchor, img_size) and returns: loc,  label