class_docstr: DyHead Block with three types of attention.
  
  HSigmoid arguments in default act_cfg follow official code, not paper.
  https://github.com/microsoft/DynamicHead/blob/master/dyhead/dyrelu.py
  
  Args:
      in_channels (int): Number of input channels.
      out_channels (int): Number of output channels.
      zero_init_offset (bool, optional): Whether to use zero init for
          `spatial_conv_offset`. Default: True.
      act_cfg (dict, optional): Config dict for the last activation layer of
          scale-aware attention. Default: dict(type='HSigmoid', bias=3.0,
          divisor=6.0).
class_docstr_tok: ["DyHead","Block","with","three","types","of","attention",".","HSigmoid","arguments","in","default","act_cfg","follow","official","code",",","not","paper",".","https",":","\/\/github.com\/microsoft\/DynamicHead\/blob\/master\/dyhead\/dyrelu.py","Args",":","in_channels","(","int",")",":","Number","of","input","channels",".","out_channels","(","int",")",":","Number","of","output","channels",".","zero_init_offset","(","bool",",","optional",")",":","Whether","to","use","zero","init","for","`","spatial_conv_offset","`",".","Default",":","True",".","act_cfg","(","dict",",","optional",")",":","Config","dict","for","the","last","activation","layer","of","scale-aware","attention",".","Default",":","dict","(","type='HSigmoid","'",",","bias=3.0",",","divisor=6.0",")","."]
docstr: Forward function.
docstr_tok: ["Forward","function","."]
code: def forward(self, x):
      """Forward function."""
      outs = []
      for level in range(len(x)):
          # calculate offset and mask of DCNv2 from middle-level feature
          offset_and_mask = self.spatial_conv_offset(x[level])
          offset = offset_and_mask[:, : self.offset_dim, :, :]
          mask = offset_and_mask[:, self.offset_dim :, :, :].sigmoid()
  
          mid_feat = self.spatial_conv_mid(x[level], offset, mask)
          sum_feat = mid_feat * self.scale_attn_module(mid_feat)
          summed_levels = 1
          if level > 0:
              low_feat = self.spatial_conv_low(
                  x[level - 1], offset, mask
              )
              sum_feat += low_feat * self.scale_attn_module(low_feat)
              summed_levels += 1
          if level < len(x) - 1:
              # this upsample order is weird, but faster than natural order
              # https://github.com/microsoft/DynamicHead/issues/25
              high_feat = F.interpolate(
                  self.spatial_conv_high(x[level + 1], offset, mask),
                  size=x[level].shape[-2:],
                  mode="bilinear",
                  align_corners=True,
              )
              sum_feat += high_feat * self.scale_attn_module(high_feat)
              summed_levels += 1
          outs.append(self.task_attn_module(sum_feat / summed_levels))
  
      return outs
  
file_path: mmdetection/mmdet/models/necks/dyhead.py
imports: import torch.nn
  import torch.nn.functional
  from mmcv.cnn import build_activation_layer, build_norm_layer
  from mmcv.ops.modulated_deform_conv import ModulatedDeformConv2d
  from mmengine.model import BaseModule, constant_init, normal_init
  from mmdet.registry import MODELS
  from ..layers import DyReLU
label_desc: Use image node_id 3 for calling the DyHeadBlock obj's underlying member method code with example usage: obj.forward(x) and returns: outs