code: def __init__(
      self,
      dim,
      num_heads,
      mlp_ratio=4.0,
      qkv_bias=True,
      drop_path=0.0,
      norm_cfg=dict(type="LN", eps=1e-6),
      act_cfg=dict(type="GELU"),
      use_rel_pos=False,
      rel_pos_zero_init=True,
      window_size=0,
      input_size=None,
  ):
      super().__init__()
      self.norm1 = build_norm_layer(norm_cfg, dim)[1]
      self.attn = Attention(
          dim,
          num_heads=num_heads,
          qkv_bias=qkv_bias,
          use_rel_pos=use_rel_pos,
          rel_pos_zero_init=rel_pos_zero_init,
          input_size=input_size
          if window_size == 0
          else (window_size, window_size),
      )
  
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
      self.norm2 = build_norm_layer(norm_cfg, dim)[1]
      self.mlp = Mlp(
          in_features=dim,
          hidden_features=int(dim * mlp_ratio),
          act_cfg=act_cfg,
      )
  
      self.window_size = window_size
  
imports: import math
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import build_activation_layer, build_norm_layer
  from mmcv.cnn.bricks import DropPath
  from mmengine.logging import MMLogger
  from mmengine.model import BaseModule
  from mmengine.runner.checkpoint import CheckpointLoader
  from mmdet.registry import MODELS
label_desc: Use image node_id 1 to create a new Block object from inherited base classes: nn with example: obj = Block(dim, num_heads, mlp_ratio, qkv_bias, drop_path, norm_cfg, act_cfg, use_rel_pos, rel_pos_zero_init, window_size, input_size)