class_docstr: Mask Head network of Mask R-CNN.
  
  Args:
      n_class (int): The number of classes including background.
      scales (tuple of floats): The scales of feature maps.
class_docstr_tok: ["Mask","Head","network","of","Mask","R-CNN",".","Args",":","n_class","(","int",")",":","The","number","of","classes","including","background",".","scales","(","tuple","of","floats",")",":","The","scales","of","feature","maps","."]
docstr: Assigns feature levels to Rois based on their size.
  
  Args:
      rois (array): An array of shape :math:`(R, 4)`,                 where :math:`R` is the total number of RoIs in the given batch.
      roi_indices (array): An array of shape :math:`(R,)`.
  
  Returns:
      two lists and one array:
      :obj:`out_rois`, :obj:`out_roi_indices` and :obj:`order`.
  
      * **out_rois**: A list of arrays of shape :math:`(R_l, 4)`,                 where :math:`R_l` is the number of RoIs in the :math:`l`-th                 feature map.
      * **out_roi_indices** : A list of arrays of shape :math:`(R_l,)`.
      * **order**: A correspondence between the output and the input.                 The relationship below is satisfied.
  
      .. code:: python
  
          xp.concatenate(out_rois, axis=0)[order[i]] == rois[i]
docstr_tok: ["Assigns","feature","levels","to","Rois","based","on","their","size",".","Args",":","rois","(","array",")",":","An","array","of","shape",":","math",":","`","(","R",",","4",")","`",",","where",":","math",":","`","R","`","is","the","total","number","of","RoIs","in","the","given","batch",".","roi_indices","(","array",")",":","An","array","of","shape",":","math",":","`","(","R",",",")","`",".","Returns",":","two","lists","and","one","array",":",":","obj",":","`","out_rois","`",",",":","obj",":","`","out_roi_indices","`","and",":","obj",":","`","order","`",".","*","*","*","out_rois","*","*",":","A","list","of","arrays","of","shape",":","math",":","`","(","R_l",",","4",")","`",",","where",":","math",":","`","R_l","`","is","the","number","of","RoIs","in","the",":","math",":","`","l","`","-th","feature","map",".","*","*","*","out_roi_indices","*","*",":","A","list","of","arrays","of","shape",":","math",":","`","(","R_l",",",")","`",".","*","*","*","order","*","*",":","A","correspondence","between","the","output","and","the","input",".","The","relationship","below","is","satisfied",".","..","code",":",":","python","xp.concatenate","(","out_rois",",","axis=0",")","[","order","[","i","]","]","==","rois","[","i","]"]
code: def distribute(self, rois, roi_indices):
      """Assigns feature levels to Rois based on their size.
  
          Args:
              rois (array): An array of shape :math:`(R, 4)`, \
                  where :math:`R` is the total number of RoIs in the given batch.
              roi_indices (array): An array of shape :math:`(R,)`.
  
          Returns:
              two lists and one array:
              :obj:`out_rois`, :obj:`out_roi_indices` and :obj:`order`.
  
              * **out_rois**: A list of arrays of shape :math:`(R_l, 4)`, \
                  where :math:`R_l` is the number of RoIs in the :math:`l`-th \
                  feature map.
              * **out_roi_indices** : A list of arrays of shape :math:`(R_l,)`.
              * **order**: A correspondence between the output and the input. \
                  The relationship below is satisfied.
  
              .. code:: python
  
                  xp.concatenate(out_rois, axis=0)[order[i]] == rois[i]
  
          """
  
      size = self.xp.sqrt(
          self.xp.prod(rois[:, 2:] - rois[:, :2], axis=1)
      )
      level = self.xp.floor(
          self.xp.log2(size / self._canonical_scale + 1e-6)
      ).astype(np.int32)
      # skip last level
      level = self.xp.clip(
          level + self._canonical_level, 0, len(self._scales) - 2
      )
  
      masks = [level == l for l in range(len(self._scales))]
      out_rois = [rois[mask] for mask in masks]
      out_roi_indices = [roi_indices[mask] for mask in masks]
      order = self.xp.argsort(
          self.xp.concatenate(
              [self.xp.where(mask)[0] for mask in masks]
          )
      )
      return out_rois, out_roi_indices, order
  
file_path: chainercv/chainercv/links/model/fpn/mask_head.py
imports: from __future__ import division
  import numpy
  import chainer
  from chainer.backends import cuda
  import chainer.functions
  from chainer.initializers import HeNormal
  import chainer.links
  from chainercv.links import Conv2DActiv
  from chainercv.utils.bbox.bbox_iou import bbox_iou
  from chainercv.links.model.fpn.mask_utils import mask_to_segm
  from chainercv.links.model.fpn.mask_utils import segm_to_mask
label_desc: Use image node_id 3 for calling the MaskHead obj's underlying member method code with example usage: obj.distribute(rois, roi_indices) and returns: out_rois,  out_roi_indices,  order