class_docstr: YOLACT mask head used in https://arxiv.org/abs/1904.02689.
  
  This head outputs the mask prototypes for YOLACT.
  
  Args:
      in_channels (int): Number of channels in the input feature map.
      proto_channels (tuple[int]): Output channels of protonet convs.
      proto_kernel_sizes (tuple[int]): Kernel sizes of protonet convs.
      include_last_relu (bool): If keep the last relu of protonet.
      num_protos (int): Number of prototypes.
      num_classes (int): Number of categories excluding the background
          category.
      loss_mask_weight (float): Reweight the mask loss by this factor.
      max_masks_to_train (int): Maximum number of masks to train for
          each image.
      with_seg_branch (bool): Whether to apply a semantic segmentation
          branch and calculate loss during training to increase
          performance with no speed penalty. Defaults to True.
      loss_segm (:obj:`ConfigDict` or dict, optional): Config of
          semantic segmentation loss.
      train_cfg (:obj:`ConfigDict` or dict, optional): Training config
          of head.
      test_cfg (:obj:`ConfigDict` or dict, optional): Testing config of
          head.
      init_cfg (:obj:`ConfigDict` or list[:obj:`ConfigDict`] or dict or
          list[dict], optional): Initialization config dict.
class_docstr_tok: ["YOLACT","mask","head","used","in","https",":","\/\/arxiv.org\/abs\/1904.02689",".","This","head","outputs","the","mask","prototypes","for","YOLACT",".","Args",":","in_channels","(","int",")",":","Number","of","channels","in","the","input","feature","map",".","proto_channels","(","tuple","[","int","]",")",":","Output","channels","of","protonet","convs",".","proto_kernel_sizes","(","tuple","[","int","]",")",":","Kernel","sizes","of","protonet","convs",".","include_last_relu","(","bool",")",":","If","keep","the","last","relu","of","protonet",".","num_protos","(","int",")",":","Number","of","prototypes",".","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","loss_mask_weight","(","float",")",":","Reweight","the","mask","loss","by","this","factor",".","max_masks_to_train","(","int",")",":","Maximum","number","of","masks","to","train","for","each","image",".","with_seg_branch","(","bool",")",":","Whether","to","apply","a","semantic","segmentation","branch","and","calculate","loss","during","training","to","increase","performance","with","no","speed","penalty",".","Defaults","to","True",".","loss_segm","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Config","of","semantic","segmentation","loss",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Training","config","of","head",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","optional",")",":","Testing","config","of","head",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","list","[",":","obj",":","`","ConfigDict","`","]","or","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict","."]
code: def __init__(
      self,
      num_classes: int,
      in_channels: int = 256,
      proto_channels: tuple = (256, 256, 256, None, 256, 32),
      proto_kernel_sizes: tuple = (3, 3, 3, -2, 3, 1),
      include_last_relu: bool = True,
      num_protos: int = 32,
      loss_mask_weight: float = 1.0,
      max_masks_to_train: int = 100,
      train_cfg: OptConfigType = None,
      test_cfg: OptConfigType = None,
      with_seg_branch: bool = True,
      loss_segm: ConfigType = dict(
          type="CrossEntropyLoss", use_sigmoid=True, loss_weight=1.0
      ),
      init_cfg=dict(
          type="Xavier",
          distribution="uniform",
          override=dict(name="protonet"),
      ),
  ) -> None:
      super().__init__(init_cfg=init_cfg)
      self.in_channels = in_channels
      self.proto_channels = proto_channels
      self.proto_kernel_sizes = proto_kernel_sizes
      self.include_last_relu = include_last_relu
  
      # Segmentation branch
      self.with_seg_branch = with_seg_branch
      self.segm_branch = (
          SegmentationModule(
              num_classes=num_classes, in_channels=in_channels
          )
          if with_seg_branch
          else None
      )
      self.loss_segm = (
          MODELS.build(loss_segm) if with_seg_branch else None
      )
  
      self.loss_mask_weight = loss_mask_weight
      self.num_protos = num_protos
      self.num_classes = num_classes
      self.max_masks_to_train = max_masks_to_train
      self.train_cfg = train_cfg
      self.test_cfg = test_cfg
      self._init_layers()
  
imports: import copy
  from typing import List, Optional
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule
  from mmengine.model import BaseModule, ModuleList
  from mmengine.structures import InstanceData
  from torch import Tensor
  from mmdet.registry import MODELS
  from mmdet.utils import ConfigType, InstanceList, OptConfigType, OptInstanceList, OptMultiConfig
  from ..layers import fast_nms
  from ..utils import images_to_levels, multi_apply, select_single_mlvl
  from ..utils.misc import empty_instances
  from .anchor_head import AnchorHead
  from .base_mask_head import BaseMaskHead
label_desc: Use image node_id 1 to create a new YOLACTProtonet object from inherited base classes: BaseMaskHead with example: obj = YOLACTProtonet(num_classes, in_channels, proto_channels, proto_kernel_sizes, include_last_relu, num_protos, loss_mask_weight, max_masks_to_train, train_cfg, test_cfg, with_seg_branch, loss_segm, init_cfg)