docstr: A transformer decoder that attends to an input image using
  queries whose positional embedding is supplied.
  
  Args:
    depth (int): number of layers in the transformer
    embedding_dim (int): the channel dimension for the input embeddings
    num_heads (int): the number of heads for multihead attention. Must
      divide embedding_dim
    mlp_dim (int): the channel dimension internal to the MLP block
    activation (nn.Layer): the activation to use in the MLP block
docstr_tok: ["A","transformer","decoder","that","attends","to","an","input","image","using","queries","whose","positional","embedding","is","supplied",".","Args",":","depth","(","int",")",":","number","of","layers","in","the","transformer","embedding_dim","(","int",")",":","the","channel","dimension","for","the","input","embeddings","num_heads","(","int",")",":","the","number","of","heads","for","multihead","attention",".","Must","divide","embedding_dim","mlp_dim","(","int",")",":","the","channel","dimension","internal","to","the","MLP","block","activation","(","nn.Layer",")",":","the","activation","to","use","in","the","MLP","block"]
code: def __init__(
      self,
      depth: int,
      embedding_dim: int,
      num_heads: int,
      mlp_dim: int,
      activation: Type[nn.Layer] = nn.ReLU,
      attention_downsample_rate: int = 2,
  ) -> None:
      """
      A transformer decoder that attends to an input image using
      queries whose positional embedding is supplied.
  
      Args:
        depth (int): number of layers in the transformer
        embedding_dim (int): the channel dimension for the input embeddings
        num_heads (int): the number of heads for multihead attention. Must
          divide embedding_dim
        mlp_dim (int): the channel dimension internal to the MLP block
        activation (nn.Layer): the activation to use in the MLP block
      """
      super().__init__()
      self.depth = depth
      self.embedding_dim = embedding_dim
      self.num_heads = num_heads
      self.mlp_dim = mlp_dim
      self.layers = nn.LayerList()
      for i in range(depth):
          self.layers.append(
              TwoWayAttentionBlock(
                  embedding_dim=embedding_dim,
                  num_heads=num_heads,
                  mlp_dim=mlp_dim,
                  activation=activation,
                  attention_downsample_rate=attention_downsample_rate,
                  skip_first_layer_pe=i == 0,
              )
          )
      self.final_attn_token_to_image = Attention(
          embedding_dim,
          num_heads,
          downsample_rate=attention_downsample_rate,
      )
      self.norm_final_attn = nn.LayerNorm(embedding_dim)
  
file_path: PaddleSeg/contrib/SegmentAnything/segment_anything/modeling/transformer.py
imports: import paddle
  from paddle import Tensor, nn
  import paddle.nn.functional
  import math
  from typing import Tuple, Type
  from common import MLPBlock
label_desc: Use image node_id 1 to create a new TwoWayTransformer object from inherited base classes: nn with example: obj = TwoWayTransformer(depth, embedding_dim, num_heads, mlp_dim, activation, attention_downsample_rate)