code: def __init__(
      self,
      dim,
      key_dim,
      num_heads,
      mlp_ratios=4.0,
      attn_ratio=2.0,
      drop=0.0,
      drop_path=0.0,
      act_layer=nn.ReLU,
      lr_mult=1.0,
  ):
      super().__init__()
      self.dim = dim
      self.num_heads = num_heads
      self.mlp_ratios = mlp_ratios
  
      self.attn = Attention(
          dim,
          key_dim=key_dim,
          num_heads=num_heads,
          attn_ratio=attn_ratio,
          activation=act_layer,
          lr_mult=lr_mult,
      )
  
      # NOTE: drop path for stochastic depth, we shall see if this is better than dropout here
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else Identity()
      )
      mlp_hidden_dim = int(dim * mlp_ratios)
      self.mlp = MLP(
          in_features=dim,
          hidden_features=mlp_hidden_dim,
          act_layer=act_layer,
          drop=drop,
          lr_mult=lr_mult,
      )
  
imports: from functools import partial
  from collections import defaultdict
  import paddle
  import paddle.nn
  import paddle.nn.functional
  import paddleseg
  from paddleseg import utils
  from paddleseg.models import layers
  from paddleseg.cvlibs import manager
  from paddleseg.models.backbones.transformer_utils import Identity, DropPath
  from ppmatting.models.layers import MLFF
  from ppmatting.models.losses import MRSD, GradientLoss
label_desc: Use image node_id 1 to create a new Block object from inherited base classes: nn with example: obj = Block(dim, key_dim, num_heads, mlp_ratios, attn_ratio, drop, drop_path, act_layer, lr_mult)