class_docstr: Args:
      dim (int): Number of input channels.
      proj_drop (float, optional): Dropout ratio of output. Default: 0.0
      focal_level (int): Number of focal levels
      focal_window (int): Focal window size at focal level 1
      focal_factor (int): Step to increase the focal window. Default: 2
      use_postln_in_modulation (bool): Whether use post-modulation layernorm
      normalize_modulator (bool): Whether use normalize in modulator
class_docstr_tok: ["Args",":","dim","(","int",")",":","Number","of","input","channels",".","proj_drop","(","float",",","optional",")",":","Dropout","ratio","of","output",".","Default",":","0.0","focal_level","(","int",")",":","Number","of","focal","levels","focal_window","(","int",")",":","Focal","window","size","at","focal","level","1","focal_factor","(","int",")",":","Step","to","increase","the","focal","window",".","Default",":","2","use_postln_in_modulation","(","bool",")",":","Whether","use","post-modulation","layernorm","normalize_modulator","(","bool",")",":","Whether","use","normalize","in","modulator"]
code: def __init__(
      self,
      dim,
      proj_drop=0.0,
      focal_level=2,
      focal_window=7,
      focal_factor=2,
      use_postln_in_modulation=False,
      normalize_modulator=False,
  ):
      super().__init__()
      self.dim = dim
  
      # specific args for focalv3
      self.focal_level = focal_level
      self.focal_window = focal_window
      self.focal_factor = focal_factor
      self.use_postln_in_modulation = use_postln_in_modulation
      self.normalize_modulator = normalize_modulator
  
      self.f = nn.Linear(
          dim, 2 * dim + (self.focal_level + 1), bias_attr=True
      )
      self.h = nn.Conv2D(
          dim,
          dim,
          kernel_size=1,
          stride=1,
          padding=0,
          groups=1,
          bias_attr=True,
      )
  
      self.act = nn.GELU()
      self.proj = nn.Linear(dim, dim)
      self.proj_drop = nn.Dropout(proj_drop)
      self.focal_layers = nn.LayerList()
  
      if self.use_postln_in_modulation:
          self.ln = nn.LayerNorm(dim)
  
      for k in range(self.focal_level):
          kernel_size = self.focal_factor * k + self.focal_window
          self.focal_layers.append(
              nn.Sequential(
                  nn.Conv2D(
                      dim,
                      dim,
                      kernel_size=kernel_size,
                      stride=1,
                      groups=dim,
                      padding=kernel_size // 2,
                      bias_attr=False,
                  ),
                  nn.GELU(),
              )
          )
  
imports: import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.modeling.shape_spec import ShapeSpec
  from ppdet.core.workspace import register, serializable
  from .transformer_utils import DropPath, Identity
  from .transformer_utils import add_parameter, to_2tuple
  from .transformer_utils import ones_, zeros_, trunc_normal_
  from .swin_transformer import Mlp
label_desc: Use image node_id 1 to create a new FocalModulation object from inherited base classes: nn with example: obj = FocalModulation(dim, proj_drop, focal_level, focal_window, focal_factor, use_postln_in_modulation, normalize_modulator)