class_docstr: Focal Modulation Block.
  Args:
      dim (int): Number of input channels.
      mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
      drop (float, optional): Dropout rate. Default: 0.0
      drop_path (float, optional): Stochastic depth rate. Default: 0.0
      act_layer (nn.Layer, optional): Activation layer. Default: nn.GELU
      norm_layer (nn.Layer, optional): Normalization layer.  Default: nn.LayerNorm
      focal_level (int): number of focal levels
      focal_window (int): focal kernel size at level 1
      use_postln (bool): Whether use layernorm after modulation. Default: False.
      use_postln_in_modulation (bool): Whether use post-modulation layernorm. Default: False.
      normalize_modulator (bool): Whether use normalize in modulator
      use_layerscale (bool): Whether use layerscale proposed in CaiT. Default: False 
      layerscale_value (float): Value for layer scale. Default: 1e-4 
class_docstr_tok: ["Focal","Modulation","Block",".","Args",":","dim","(","int",")",":","Number","of","input","channels",".","mlp_ratio","(","float",")",":","Ratio","of","mlp","hidden","dim","to","embedding","dim",".","drop","(","float",",","optional",")",":","Dropout","rate",".","Default",":","0.0","drop_path","(","float",",","optional",")",":","Stochastic","depth","rate",".","Default",":","0.0","act_layer","(","nn.Layer",",","optional",")",":","Activation","layer",".","Default",":","nn.GELU","norm_layer","(","nn.Layer",",","optional",")",":","Normalization","layer",".","Default",":","nn.LayerNorm","focal_level","(","int",")",":","number","of","focal","levels","focal_window","(","int",")",":","focal","kernel","size","at","level","1","use_postln","(","bool",")",":","Whether","use","layernorm","after","modulation",".","Default",":","False",".","use_postln_in_modulation","(","bool",")",":","Whether","use","post-modulation","layernorm",".","Default",":","False",".","normalize_modulator","(","bool",")",":","Whether","use","normalize","in","modulator","use_layerscale","(","bool",")",":","Whether","use","layerscale","proposed","in","CaiT",".","Default",":","False","layerscale_value","(","float",")",":","Value","for","layer","scale",".","Default",":","1e-4"]
docstr: Args:
      x: Input feature, tensor size (B, H*W, C).
docstr_tok: ["Args",":","x",":","Input","feature",",","tensor","size","(","B",",","H","*","W",",","C",")","."]
code: def forward(self, x):
      """
      Args:
          x: Input feature, tensor size (B, H*W, C).
      """
      B, L, C = x.shape
      H, W = self.H, self.W
      assert L == H * W, "input feature has wrong size"
  
      shortcut = x
      if not self.use_postln:
          x = self.norm1(x)
      x = x.reshape([-1, H, W, C])
  
      # FM
      x = self.modulation(x).reshape([-1, H * W, C])
      if self.use_postln:
          x = self.norm1(x)
  
      # FFN
      x = shortcut + self.drop_path(self.gamma_1 * x)
  
      if self.use_postln:
          x = x + self.drop_path(self.gamma_2 * self.norm2(self.mlp(x)))
      else:
          x = x + self.drop_path(self.gamma_2 * self.mlp(self.norm2(x)))
      return x
  
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 2 for calling the FocalModulationBlock obj's underlying member method code with example usage: obj.forward(x) and returns: x