class_docstr: Head block for SOLOv2 network
  
  Args:
      num_classes (int): Number of output classes.
      in_channels (int): Number of input channels.
      seg_feat_channels (int): Num_filters of kernel & categroy branch convolution operation.
      stacked_convs (int): Times of convolution operation.
      num_grids (list[int]): List of feature map grids size.
      kernel_out_channels (int): Number of output channels in kernel branch.
      dcn_v2_stages (list): Which stage use dcn v2 in tower. It is between [0, stacked_convs).
      segm_strides (list[int]): List of segmentation area stride.
      solov2_loss (object): SOLOv2Loss instance.
      score_threshold (float): Threshold of categroy score.
      mask_nms (object): MaskMatrixNMS instance.
class_docstr_tok: ["Head","block","for","SOLOv2","network","Args",":","num_classes","(","int",")",":","Number","of","output","classes",".","in_channels","(","int",")",":","Number","of","input","channels",".","seg_feat_channels","(","int",")",":","Num_filters","of","kernel","&","categroy","branch","convolution","operation",".","stacked_convs","(","int",")",":","Times","of","convolution","operation",".","num_grids","(","list","[","int","]",")",":","List","of","feature","map","grids","size",".","kernel_out_channels","(","int",")",":","Number","of","output","channels","in","kernel","branch",".","dcn_v2_stages","(","list",")",":","Which","stage","use","dcn","v2","in","tower",".","It","is","between","[","0",",","stacked_convs",")",".","segm_strides","(","list","[","int","]",")",":","List","of","segmentation","area","stride",".","solov2_loss","(","object",")",":","SOLOv2Loss","instance",".","score_threshold","(","float",")",":","Threshold","of","categroy","score",".","mask_nms","(","object",")",":","MaskMatrixNMS","instance","."]
code: def __init__(
      self,
      num_classes=80,
      in_channels=256,
      seg_feat_channels=256,
      stacked_convs=4,
      num_grids=[40, 36, 24, 16, 12],
      kernel_out_channels=256,
      dcn_v2_stages=[],
      segm_strides=[8, 8, 16, 32, 32],
      solov2_loss=None,
      score_threshold=0.1,
      mask_threshold=0.5,
      mask_nms=None,
      norm_type="gn",
      drop_block=False,
  ):
      super(SOLOv2Head, self).__init__()
      self.num_classes = num_classes
      self.in_channels = in_channels
      self.seg_num_grids = num_grids
      self.cate_out_channels = self.num_classes
      self.seg_feat_channels = seg_feat_channels
      self.stacked_convs = stacked_convs
      self.kernel_out_channels = kernel_out_channels
      self.dcn_v2_stages = dcn_v2_stages
      self.segm_strides = segm_strides
      self.solov2_loss = solov2_loss
      self.mask_nms = mask_nms
      self.score_threshold = score_threshold
      self.mask_threshold = mask_threshold
      self.norm_type = norm_type
      self.drop_block = drop_block
  
      self.kernel_pred_convs = []
      self.cate_pred_convs = []
      for i in range(self.stacked_convs):
          use_dcn = True if i in self.dcn_v2_stages else False
          ch_in = (
              self.in_channels + 2 if i == 0 else self.seg_feat_channels
          )
          kernel_conv = self.add_sublayer(
              "bbox_head.kernel_convs." + str(i),
              ConvNormLayer(
                  ch_in=ch_in,
                  ch_out=self.seg_feat_channels,
                  filter_size=3,
                  stride=1,
                  use_dcn=use_dcn,
                  norm_type=self.norm_type,
              ),
          )
          self.kernel_pred_convs.append(kernel_conv)
          ch_in = self.in_channels if i == 0 else self.seg_feat_channels
          cate_conv = self.add_sublayer(
              "bbox_head.cate_convs." + str(i),
              ConvNormLayer(
                  ch_in=ch_in,
                  ch_out=self.seg_feat_channels,
                  filter_size=3,
                  stride=1,
                  use_dcn=use_dcn,
                  norm_type=self.norm_type,
              ),
          )
          self.cate_pred_convs.append(cate_conv)
  
      self.solo_kernel = self.add_sublayer(
          "bbox_head.solo_kernel",
          nn.Conv2D(
              self.seg_feat_channels,
              self.kernel_out_channels,
              kernel_size=3,
              stride=1,
              padding=1,
              weight_attr=ParamAttr(
                  initializer=Normal(mean=0.0, std=0.01)
              ),
              bias_attr=True,
          ),
      )
      self.solo_cate = self.add_sublayer(
          "bbox_head.solo_cate",
          nn.Conv2D(
              self.seg_feat_channels,
              self.cate_out_channels,
              kernel_size=3,
              stride=1,
              padding=1,
              weight_attr=ParamAttr(
                  initializer=Normal(mean=0.0, std=0.01)
              ),
              bias_attr=ParamAttr(
                  initializer=Constant(
                      value=float(-np.log((1 - 0.01) / 0.01))
                  )
              ),
          ),
      )
  
      if self.drop_block and self.training:
          self.drop_block_fun = DropBlock(
              block_size=3, keep_prob=0.9, name="solo_cate.dropblock"
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import paddle
  from paddle import ParamAttr
  import paddle.nn
  import paddle.nn.functional
  from paddle.nn.initializer import Normal, Constant
  from ppdet.modeling.layers import ConvNormLayer, MaskMatrixNMS, DropBlock
  from ppdet.core.workspace import register
  from six.moves import zip
  import numpy
label_desc: Use image node_id 1 to create a new SOLOv2Head object from inherited base classes: nn with example: obj = SOLOv2Head(num_classes, in_channels, seg_feat_channels, stacked_convs, num_grids, kernel_out_channels, dcn_v2_stages, segm_strides, solov2_loss, score_threshold, mask_threshold, mask_nms, norm_type, drop_block)