class_docstr: A basic focal modulation layer for one stage.
  
  Args:
      dim (int): Number of feature channels
      depth (int): Depths of this stage.
      mlp_ratio (float): Ratio of mlp hidden dim to embedding dim.
          Default: 4.
      drop (float, optional): Dropout rate. Default: 0.0
      drop_path (float | tuple[float], optional): Stochastic depth rate.
          Default: 0.0
      norm_layer (nn.Module, optional): Normalization layer.
          Default: nn.LayerNorm
      downsample (nn.Module | None, optional): Downsample layer at the
          end of the layer. Default: None
      focal_level (int): Number of focal levels
      focal_window (int): Focal window size at focal level 1
      use_conv_embed (bool): Use overlapped convolution for patch
          embedding or now. Default: False
      use_checkpoint (bool): Whether to use checkpointing to save memory.
          Default: False
code: def __init__(
      self,
      dim,
      depth,
      mlp_ratio=4.0,
      drop=0.0,
      drop_path=0.0,
      norm_layer=nn.LayerNorm,
      downsample=None,
      focal_window=9,
      focal_level=2,
      use_conv_embed=False,
      use_postln=False,
      use_postln_in_modulation=False,
      scaling_modulator=False,
      use_layerscale=False,
      use_checkpoint=False,
      use_pre_norm=False,
  ):
      super().__init__()
      self.depth = depth
      self.use_checkpoint = use_checkpoint
  
      # build blocks
      self.blocks = nn.ModuleList(
          [
              FocalModulationBlock(
                  dim=dim,
                  mlp_ratio=mlp_ratio,
                  drop=drop,
                  drop_path=drop_path[i]
                  if isinstance(drop_path, list)
                  else drop_path,
                  focal_window=focal_window,
                  focal_level=focal_level,
                  use_postln=use_postln,
                  use_postln_in_modulation=use_postln_in_modulation,
                  scaling_modulator=scaling_modulator,
                  use_layerscale=use_layerscale,
                  norm_layer=norm_layer,
              )
              for i in range(depth)
          ]
      )
  
      # patch merging layer
      if downsample is not None:
          self.downsample = downsample(
              patch_size=2,
              in_chans=dim,
              embed_dim=2 * dim,
              use_conv_embed=use_conv_embed,
              norm_layer=norm_layer,
              is_stem=False,
              use_pre_norm=use_pre_norm,
          )
  
      else:
          self.downsample = None
  
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 BasicLayer object from inherited base classes: nn with example: obj = BasicLayer(dim, depth, mlp_ratio, drop, drop_path, norm_layer, downsample, focal_window, focal_level, use_conv_embed, use_postln, use_postln_in_modulation, scaling_modulator, use_layerscale, use_checkpoint, use_pre_norm)