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.Layer, optional): Normalization layer. Default: nn.LayerNorm
      downsample (nn.Layer | 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): Whether use overlapped convolution for patch embedding
      use_layerscale (bool): Whether use layerscale proposed in CaiT. Default: False 
      layerscale_value (float): Value of layerscale
      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_checkpoint (bool): Whether to use checkpointing to save memory. Default: False.
class_docstr_tok: ["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.Layer",",","optional",")",":","Normalization","layer",".","Default",":","nn.LayerNorm","downsample","(","nn.Layer","|","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",")",":","Whether","use","overlapped","convolution","for","patch","embedding","use_layerscale","(","bool",")",":","Whether","use","layerscale","proposed","in","CaiT",".","Default",":","False","layerscale_value","(","float",")",":","Value","of","layerscale","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_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_level=2,
      focal_window=9,
      use_conv_embed=False,
      use_layerscale=False,
      layerscale_value=1e-4,
      use_postln=False,
      use_postln_in_modulation=False,
      normalize_modulator=False,
      use_checkpoint=False,
  ):
      super().__init__()
      self.depth = depth
      self.use_checkpoint = use_checkpoint
  
      # build blocks
      self.blocks = nn.LayerList(
          [
              FocalModulationBlock(
                  dim=dim,
                  mlp_ratio=mlp_ratio,
                  drop=drop,
                  drop_path=drop_path[i]
                  if isinstance(drop_path, np.ndarray)
                  else drop_path,
                  act_layer=nn.GELU,
                  norm_layer=norm_layer,
                  focal_level=focal_level,
                  focal_window=focal_window,
                  use_postln=use_postln,
                  use_postln_in_modulation=use_postln_in_modulation,
                  normalize_modulator=normalize_modulator,
                  use_layerscale=use_layerscale,
                  layerscale_value=layerscale_value,
              )
              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,
          )
      else:
          self.downsample = None
  
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 BasicLayer object from inherited base classes: nn with example: obj = BasicLayer(dim, depth, mlp_ratio, drop, drop_path, norm_layer, downsample, focal_level, focal_window, use_conv_embed, use_layerscale, layerscale_value, use_postln, use_postln_in_modulation, normalize_modulator, use_checkpoint)