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.Module, optional): Activation layer. Default: nn.GELU
      norm_layer (nn.Module, optional): Normalization layer.
          Default: nn.LayerNorm
      focal_level (int): number of focal levels
      focal_window (int): focal kernel size at level 1
code: def __init__(
      self,
      dim,
      mlp_ratio=4.0,
      drop=0.0,
      drop_path=0.0,
      act_layer=nn.GELU,
      norm_layer=nn.LayerNorm,
      focal_level=2,
      focal_window=9,
      use_postln=False,
      use_postln_in_modulation=False,
      scaling_modulator=False,
      use_layerscale=False,
      layerscale_value=1e-4,
  ):
      super().__init__()
      self.dim = dim
      self.mlp_ratio = mlp_ratio
      self.focal_window = focal_window
      self.focal_level = focal_level
      self.use_postln = use_postln
      self.use_layerscale = use_layerscale
  
      self.dw1 = nn.Conv2d(
          dim, dim, kernel_size=3, stride=1, padding=1, groups=dim
      )
      self.norm1 = norm_layer(dim)
      self.modulation = FocalModulation(
          dim,
          focal_window=self.focal_window,
          focal_level=self.focal_level,
          proj_drop=drop,
          use_postln_in_modulation=use_postln_in_modulation,
          scaling_modulator=scaling_modulator,
      )
  
      self.dw2 = nn.Conv2d(
          dim, dim, kernel_size=3, stride=1, padding=1, groups=dim
      )
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
      self.norm2 = norm_layer(dim)
      mlp_hidden_dim = int(dim * mlp_ratio)
      self.mlp = Mlp(
          in_features=dim,
          hidden_features=mlp_hidden_dim,
          act_layer=act_layer,
          drop=drop,
      )
  
      self.H = None
      self.W = None
  
      self.gamma_1 = 1.0
      self.gamma_2 = 1.0
      if self.use_layerscale:
          self.gamma_1 = nn.Parameter(
              layerscale_value * torch.ones(dim), requires_grad=True
          )
          self.gamma_2 = nn.Parameter(
              layerscale_value * torch.ones(dim), requires_grad=True
          )
  
imports: import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from mmcv.cnn.bricks import DropPath
  from mmdet.registry import MODELS
label_desc: Use image node_id 1 to create a new FocalModulationBlock object from inherited base classes: nn with example: obj = FocalModulationBlock(dim, mlp_ratio, drop, drop_path, act_layer, norm_layer, focal_level, focal_window, use_postln, use_postln_in_modulation, scaling_modulator, use_layerscale, layerscale_value)