code: def __init__(
      self,
      patch_size=4,
      in_chans=3,
      embed_dim=96,
      depths=[2, 2, 6, 2],
      mlp_ratio=4.0,
      drop_rate=0.0,
      drop_path_rate=0.3,
      norm_layer=nn.LayerNorm,
      patch_norm=True,
      out_indices=[0, 1, 2, 3],
      frozen_stages=-1,
      focal_levels=[3, 3, 3, 3],
      focal_windows=[3, 3, 3, 3],
      use_pre_norms=[False, False, False, False],
      use_conv_embed=True,
      use_postln=True,
      use_postln_in_modulation=False,
      scaling_modulator=True,
      use_layerscale=True,
      use_checkpoint=False,
  ):
      super().__init__()
  
      self.num_layers = len(depths)
      self.embed_dim = embed_dim
      self.patch_norm = patch_norm
      self.out_indices = out_indices
      self.frozen_stages = frozen_stages
  
      # split image into non-overlapping patches
      self.patch_embed = PatchEmbed(
          patch_size=patch_size,
          in_chans=in_chans,
          embed_dim=embed_dim,
          norm_layer=norm_layer if self.patch_norm else None,
          use_conv_embed=use_conv_embed,
          is_stem=True,
          use_pre_norm=False,
      )
  
      self.pos_drop = nn.Dropout(p=drop_rate)
  
      dpr = [
          x.item()
          for x in torch.linspace(0, drop_path_rate, sum(depths))
      ]
  
      self.layers = nn.ModuleList()
      for i_layer in range(self.num_layers):
          layer = BasicLayer(
              dim=int(embed_dim * 2**i_layer),
              depth=depths[i_layer],
              mlp_ratio=mlp_ratio,
              drop=drop_rate,
              drop_path=dpr[
                  sum(depths[:i_layer]) : sum(depths[: i_layer + 1])
              ],
              norm_layer=norm_layer,
              downsample=PatchEmbed
              if (i_layer < self.num_layers - 1)
              else None,
              focal_window=focal_windows[i_layer],
              focal_level=focal_levels[i_layer],
              use_pre_norm=use_pre_norms[i_layer],
              use_conv_embed=use_conv_embed,
              use_postln=use_postln,
              use_postln_in_modulation=use_postln_in_modulation,
              scaling_modulator=scaling_modulator,
              use_layerscale=use_layerscale,
              use_checkpoint=use_checkpoint,
          )
          self.layers.append(layer)
  
      num_features = [
          int(embed_dim * 2**i) for i in range(self.num_layers)
      ]
      self.num_features = num_features
  
      # add a norm layer for each output
      for i_layer in self.out_indices:
          layer = norm_layer(num_features[i_layer])
          layer_name = f"norm{i_layer}"
          self.add_module(layer_name, layer)
  
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 FocalNet object from inherited base classes: nn with example: obj = FocalNet(patch_size, in_chans, embed_dim, depths, mlp_ratio, drop_rate, drop_path_rate, norm_layer, patch_norm, out_indices, frozen_stages, focal_levels, focal_windows, use_pre_norms, use_conv_embed, use_postln, use_postln_in_modulation, scaling_modulator, use_layerscale, use_checkpoint)