class_docstr: Focal Modulation.
  
  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, default=2): Step to increase the focal window
docstr: Forward function.
  
  Args:
      x: input features with shape of (B, H, W, C)
docstr_tok: ["Forward","function",".","Args",":","x",":","input","features","with","shape","of","(","B",",","H",",","W",",","C",")"]
code: def forward(self, x):
      """Forward function.
  
      Args:
          x: input features with shape of (B, H, W, C)
      """
      B, nH, nW, C = x.shape
      x = self.f(x)
      x = x.permute(0, 3, 1, 2).contiguous()
      q, ctx, gates = torch.split(x, (C, C, self.focal_level + 1), 1)
  
      ctx_all = 0
      for level in range(self.focal_level):
          ctx = self.focal_layers[level](ctx)
          ctx_all = ctx_all + ctx * gates[:, level : level + 1]
      ctx_global = self.act(
          ctx.mean(2, keepdim=True).mean(3, keepdim=True)
      )
      ctx_all = ctx_all + ctx_global * gates[:, self.focal_level :]
  
      if self.scaling_modulator:
          ctx_all = ctx_all / (self.focal_level + 1)
  
      x_out = q * self.h(ctx_all)
      x_out = x_out.permute(0, 2, 3, 1).contiguous()
      if self.use_postln_in_modulation:
          x_out = self.ln(x_out)
      x_out = self.proj(x_out)
      x_out = self.proj_drop(x_out)
      return x_out
  
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 2 for calling the FocalModulation obj's underlying member method code with example usage: obj.forward(x) and returns: x_out