class_docstr: Implementation of `SSD head <https://arxiv.org/abs/1512.02325>`_
  
  Args:
      num_classes (int): Number of categories excluding the background
          category.
      in_channels (Sequence[int]): Number of channels in the input feature
          map.
      stacked_convs (int): Number of conv layers in cls and reg tower.
          Defaults to 0.
      feat_channels (int): Number of hidden channels when stacked_convs
          > 0. Defaults to 256.
      use_depthwise (bool): Whether to use DepthwiseSeparableConv.
          Defaults to False.
      conv_cfg (:obj:`ConfigDict` or dict, Optional): Dictionary to construct
          and config conv layer. Defaults to None.
      norm_cfg (:obj:`ConfigDict` or dict, Optional): Dictionary to construct
          and config norm layer. Defaults to None.
      act_cfg (:obj:`ConfigDict` or dict, Optional): Dictionary to construct
          and config activation layer. Defaults to None.
      anchor_generator (:obj:`ConfigDict` or dict): Config dict for anchor
          generator.
      bbox_coder (:obj:`ConfigDict` or dict): Config of bounding box coder.
      reg_decoded_bbox (bool): If true, the regression loss would be
          applied directly on decoded bounding boxes, converting both
          the predicted boxes and regression targets to absolute
          coordinates format. Defaults to False. It should be `True` when
          using `IoULoss`, `GIoULoss`, or `DIoULoss` in the bbox head.
      train_cfg (:obj:`ConfigDict` or dict, Optional): Training config of
          anchor head.
      test_cfg (:obj:`ConfigDict` or dict, Optional): Testing config of
          anchor head.
      init_cfg (:obj:`ConfigDict` or dict or list[:obj:`ConfigDict` or             dict], Optional): Initialization config dict.
class_docstr_tok: ["Implementation","of","`","SSD","head","<","https",":","\/\/arxiv.org\/abs\/1512.02325",">","`","_","Args",":","num_classes","(","int",")",":","Number","of","categories","excluding","the","background","category",".","in_channels","(","Sequence","[","int","]",")",":","Number","of","channels","in","the","input","feature","map",".","stacked_convs","(","int",")",":","Number","of","conv","layers","in","cls","and","reg","tower",".","Defaults","to","0.","feat_channels","(","int",")",":","Number","of","hidden","channels","when","stacked_convs",">","0",".","Defaults","to","256.","use_depthwise","(","bool",")",":","Whether","to","use","DepthwiseSeparableConv",".","Defaults","to","False",".","conv_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Dictionary","to","construct","and","config","conv","layer",".","Defaults","to","None",".","norm_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Dictionary","to","construct","and","config","norm","layer",".","Defaults","to","None",".","act_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Dictionary","to","construct","and","config","activation","layer",".","Defaults","to","None",".","anchor_generator","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","dict","for","anchor","generator",".","bbox_coder","(",":","obj",":","`","ConfigDict","`","or","dict",")",":","Config","of","bounding","box","coder",".","reg_decoded_bbox","(","bool",")",":","If","true",",","the","regression","loss","would","be","applied","directly","on","decoded","bounding","boxes",",","converting","both","the","predicted","boxes","and","regression","targets","to","absolute","coordinates","format",".","Defaults","to","False",".","It","should","be","`","True","`","when","using","`","IoULoss","`",",","`","GIoULoss","`",",","or","`","DIoULoss","`","in","the","bbox","head",".","train_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Training","config","of","anchor","head",".","test_cfg","(",":","obj",":","`","ConfigDict","`","or","dict",",","Optional",")",":","Testing","config","of","anchor","head",".","init_cfg","(",":","obj",":","`","ConfigDict","`","or","dict","or","list","[",":","obj",":","`","ConfigDict","`","or","dict","]",",","Optional",")",":","Initialization","config","dict","."]
docstr: Initialize layers of the head.
docstr_tok: ["Initialize","layers","of","the","head","."]
code: def _init_layers(self) -> None:
      """Initialize layers of the head."""
      self.cls_convs = nn.ModuleList()
      self.reg_convs = nn.ModuleList()
      # TODO: Use registry to choose ConvModule type
      conv = (
          DepthwiseSeparableConvModule
          if self.use_depthwise
          else ConvModule
      )
  
      for channel, num_base_priors in zip(
          self.in_channels, self.num_base_priors
      ):
          cls_layers = []
          reg_layers = []
          in_channel = channel
          # build stacked conv tower, not used in default ssd
          for i in range(self.stacked_convs):
              cls_layers.append(
                  conv(
                      in_channel,
                      self.feat_channels,
                      3,
                      padding=1,
                      conv_cfg=self.conv_cfg,
                      norm_cfg=self.norm_cfg,
                      act_cfg=self.act_cfg,
                  )
              )
              reg_layers.append(
                  conv(
                      in_channel,
                      self.feat_channels,
                      3,
                      padding=1,
                      conv_cfg=self.conv_cfg,
                      norm_cfg=self.norm_cfg,
                      act_cfg=self.act_cfg,
                  )
              )
              in_channel = self.feat_channels
          # SSD-Lite head
          if self.use_depthwise:
              cls_layers.append(
                  ConvModule(
                      in_channel,
                      in_channel,
                      3,
                      padding=1,
                      groups=in_channel,
                      conv_cfg=self.conv_cfg,
                      norm_cfg=self.norm_cfg,
                      act_cfg=self.act_cfg,
                  )
              )
              reg_layers.append(
                  ConvModule(
                      in_channel,
                      in_channel,
                      3,
                      padding=1,
                      groups=in_channel,
                      conv_cfg=self.conv_cfg,
                      norm_cfg=self.norm_cfg,
                      act_cfg=self.act_cfg,
                  )
              )
          cls_layers.append(
              nn.Conv2d(
                  in_channel,
                  num_base_priors * self.cls_out_channels,
                  kernel_size=1 if self.use_depthwise else 3,
                  padding=0 if self.use_depthwise else 1,
              )
          )
          reg_layers.append(
              nn.Conv2d(
                  in_channel,
                  num_base_priors * 4,
                  kernel_size=1 if self.use_depthwise else 3,
                  padding=0 if self.use_depthwise else 1,
              )
          )
          self.cls_convs.append(nn.Sequential(*cls_layers))
          self.reg_convs.append(nn.Sequential(*reg_layers))
  
file_path: mmdetection/mmdet/models/dense_heads/ssd_head.py
imports: from typing import Dict, List, Optional, Sequence, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
  from torch import Tensor
  from mmdet.registry import MODELS, TASK_UTILS
  from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptInstanceList
  from ..losses import smooth_l1_loss
  from ..task_modules.samplers import PseudoSampler
  from ..utils import multi_apply
  from .anchor_head import AnchorHead
label_desc: Use image node_id 2 for calling the SSDHead obj's underlying member method code with example usage: obj._init_layers() without return types