class_docstr: Self attention for Perceiver https://arxiv.org/pdf/2103.03206.pdf.
  Args:
      num_channels (`int`):
          Number of channels.
      num_heads (`int`):
          Number of parallel attention heads.
      dropout (`nn.Module`):
          Dropout probability.
class_docstr_tok: ["Self","attention","for","Perceiver","https",":","\/\/arxiv.org\/pdf\/2103.03206.pdf",".","Args",":","num_channels","(","`","int","`",")",":","Number","of","channels",".","num_heads","(","`","int","`",")",":","Number","of","parallel","attention","heads",".","dropout","(","`","nn.Module","`",")",":","Dropout","probability","."]
docstr: Forward function.
  Args:
      x (`Tensor`):
          Input tensor
      pad_mask (`Tensor`):
          Padding mask.
      attn_mask (`Tensor`):
          Attention mask.
docstr_tok: ["Forward","function",".","Args",":","x","(","`","Tensor","`",")",":","Input","tensor","pad_mask","(","`","Tensor","`",")",":","Padding","mask",".","attn_mask","(","`","Tensor","`",")",":","Attention","mask","."]
code: def forward(self, x, pad_mask=None, attn_mask=None):
      """
      Forward function.
      Args:
          x (`Tensor`):
              Input tensor
          pad_mask (`Tensor`):
              Padding mask.
          attn_mask (`Tensor`):
              Attention mask.
      """
      x = self.norm(x)
      return self.attention(
          x, x, pad_mask=pad_mask, attn_mask=attn_mask
      )
  
imports: from torch import nn
  from towhee.models.perceiver.multi_head_attention import MultiHeadAttention
label_desc: Use image node_id 2 for calling the SelfAttention obj's underlying member method code with example usage: obj.forward(x, pad_mask, attn_mask) and returns: self