class_docstr: Mask IoU Head.
  
  This head predicts the IoU of predicted masks and corresponding gt masks.
  
  Args:
      num_convs (int): The number of convolution layers. Defaults to 4.
      num_fcs (int): The number of fully connected layers. Defaults to 2.
      roi_feat_size (int): RoI feature size. Default to 14.
      in_channels (int): The channel number of inputs features.
          Defaults to 256.
      conv_out_channels (int): The feature channels of convolution layers.
          Defaults to 256.
      fc_out_channels (int): The feature channels of fully connected layers.
          Defaults to 1024.
      num_classes (int): Number of categories excluding the background
          category. Defaults to 80.
      loss_iou (:obj:`ConfigDict` or dict): IoU loss.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict], optional): Initialization config dict.
class_docstr_tok: ["Mask","IoU","Head",".","This","head","predicts","the","IoU","of","predicted","masks","and","corresponding","gt","masks",".","Args",":","num_convs","(","int",")",":","The","number","of","convolution","layers",".","Defaults","to","4.","num_fcs","(","int",")",":","The","number","of","fully","connected","layers",".","Defaults","to","2.","roi_feat_size","(","int",")",":","RoI","feature","size",".","Default","to","14.","in_channels","(","int",")",":","The","channel","number","of","inputs","features",".","Defaults","to","256.","conv_out_channels","(","int",")",":","The","feature","channels","of","convolution","layers",".","Defaults","to","256.","fc_out_channels","(","int",")",":","The","feature","channels","of","fully","connected","layers",".","Defaults","to","1024.","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","Defaults","to","80.","loss_iou","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","IoU","loss",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",",","optional",")",":","Initialization","config","dict","."]
docstr: Compute area ratio of the gt mask inside the proposal and the gt
  mask of the corresponding instance.
  
  Args:
      pos_proposals (Tensor): Positive proposals, has shape (num_pos, 4).
      pos_assigned_gt_inds (Tensor): positive proposals assigned ground
          truth index.
      gt_masks (BitmapMask or PolygonMask): Gt masks (the whole instance)
          of each image, with the same shape of the input image.
  
  Returns:
      Tensor: The area ratio of the gt mask inside the proposal and the
      gt mask of the corresponding instance.
docstr_tok: ["Compute","area","ratio","of","the","gt","mask","inside","the","proposal","and","the","gt","mask","of","the","corresponding","instance",".","Args",":","pos_proposals","(","Tensor",")",":","Positive","proposals",",","has","shape","(","num_pos",",","4",")",".","pos_assigned_gt_inds","(","Tensor",")",":","positive","proposals","assigned","ground","truth","index",".","gt_masks","(","BitmapMask","or","PolygonMask",")",":","Gt","masks","(","the","whole","instance",")","of","each","image",",","with","the","same","shape","of","the","input","image",".","Returns",":","Tensor",":","The","area","ratio","of","the","gt","mask","inside","the","proposal","and","the","gt","mask","of","the","corresponding","instance","."]
code: def _get_area_ratio(
      self,
      pos_proposals: Tensor,
      pos_assigned_gt_inds: Tensor,
      gt_masks: InstanceData,
  ) -> Tensor:
      """Compute area ratio of the gt mask inside the proposal and the gt
      mask of the corresponding instance.
  
      Args:
          pos_proposals (Tensor): Positive proposals, has shape (num_pos, 4).
          pos_assigned_gt_inds (Tensor): positive proposals assigned ground
              truth index.
          gt_masks (BitmapMask or PolygonMask): Gt masks (the whole instance)
              of each image, with the same shape of the input image.
  
      Returns:
          Tensor: The area ratio of the gt mask inside the proposal and the
          gt mask of the corresponding instance.
      """
      num_pos = pos_proposals.size(0)
      if num_pos > 0:
          area_ratios = []
          proposals_np = pos_proposals.cpu().numpy()
          pos_assigned_gt_inds = pos_assigned_gt_inds.cpu().numpy()
          # compute mask areas of gt instances (batch processing for speedup)
          gt_instance_mask_area = gt_masks.areas
          for i in range(num_pos):
              gt_mask = gt_masks[pos_assigned_gt_inds[i]]
  
              # crop the gt mask inside the proposal
              bbox = proposals_np[i, :].astype(np.int32)
              gt_mask_in_proposal = gt_mask.crop(bbox)
  
              ratio = gt_mask_in_proposal.areas[0] / (
                  gt_instance_mask_area[pos_assigned_gt_inds[i]] + 1e-7
              )
              area_ratios.append(ratio)
          area_ratios = (
              torch.from_numpy(np.stack(area_ratios))
              .float()
              .to(pos_proposals.device)
          )
      else:
          area_ratios = pos_proposals.new_zeros((0,))
      return area_ratios
  
imports: from typing import List, Tuple
  import numpy
  import torch
  import torch.nn
  from mmcv.cnn import Conv2d, Linear, MaxPool2d
  from mmengine.config import ConfigDict
  from mmengine.model import BaseModule
  from mmengine.structures import InstanceData
  from torch import Tensor
  from torch.nn.modules.utils import _pair
  from mmdet.models.task_modules.samplers import SamplingResult
  from mmdet.registry import MODELS
  from mmdet.utils import ConfigType, InstanceList, OptMultiConfig
label_desc: Use image node_id 5 for calling the MaskIoUHead obj's underlying member method code with example usage: obj._get_area_ratio(pos_proposals, pos_assigned_gt_inds, gt_masks) and returns: area_ratios