code: def __init__(
      self,
      dim,
      num_heads=8,
      mixer="Global",
      HW=None,
      local_k=[7, 11],
      qkv_bias=False,
      qk_scale=None,
      attn_drop=0.0,
      proj_drop=0.0,
  ):
      super().__init__()
      self.num_heads = num_heads
      self.dim = dim
      self.head_dim = dim // num_heads
      self.scale = qk_scale or self.head_dim**-0.5
  
      self.qkv = nn.Linear(dim, dim * 3, bias_attr=qkv_bias)
      self.attn_drop = nn.Dropout(attn_drop)
      self.proj = nn.Linear(dim, dim)
      self.proj_drop = nn.Dropout(proj_drop)
      self.HW = HW
      if HW is not None:
          H = HW[0]
          W = HW[1]
          self.N = H * W
          self.C = dim
      if mixer == "Local" and HW is not None:
          hk = local_k[0]
          wk = local_k[1]
          mask = paddle.ones(
              [H * W, H + hk - 1, W + wk - 1], dtype="float32"
          )
          for h in range(0, H):
              for w in range(0, W):
                  mask[h * W + w, h : h + hk, w : w + wk] = 0.0
          mask_paddle = mask[
              :, hk // 2 : H + hk // 2, wk // 2 : W + wk // 2
          ].flatten(1)
          mask_inf = paddle.full(
              [H * W, H * W], "-inf", dtype="float32"
          )
          mask = paddle.where(mask_paddle < 1, mask_paddle, mask_inf)
          self.mask = mask.unsqueeze([0, 1])
      self.mixer = mixer
  
imports: from paddle import ParamAttr
  from paddle.nn.initializer import KaimingNormal
  import numpy
  import paddle
  import paddle.nn
  from paddle.nn.initializer import TruncatedNormal, Constant, Normal
label_desc: Use image node_id 1 to create a new Attention object from inherited base classes: nn with example: obj = Attention(dim, num_heads, mixer, HW, local_k, qkv_bias, qk_scale, attn_drop, proj_drop)