class_docstr: The linear scaled attention mechanism from the
  `"Rethinking Attention with Performers"
  <https://arxiv.org/abs/2009.14794>`_ paper.
  
  Args:
      channels (int): Size of each input sample.
      heads (int, optional): Number of parallel attention heads.
      head_channels (int, optional): Size of each attention head.
          (default: :obj:`64.`)
      kernel (Callable, optional): Kernels for generalized attention.
          If not specified, `ReLU` kernel will be used.
          (default: :obj:`torch.nn.ReLU()`)
      qkv_bias (bool, optional): If specified, add bias to query, key
          and value in the self attention. (default: :obj:`False`)
      attn_out_bias (bool, optional): If specified, add bias to the
          attention output. (default: :obj:`True`)
      dropout (float, optional): Dropout probability of the final
          attention output. (default: :obj:`0.0`)
class_docstr_tok: ["The","linear","scaled","attention","mechanism","from","the","`","``","Rethinking","Attention","with","Performers","''","<","https",":","\/\/arxiv.org\/abs\/2009.14794",">","`","_","paper",".","Args",":","channels","(","int",")",":","Size","of","each","input","sample",".","heads","(","int",",","optional",")",":","Number","of","parallel","attention","heads",".","head_channels","(","int",",","optional",")",":","Size","of","each","attention","head",".","(","default",":",":","obj",":","`","64.","`",")","kernel","(","Callable",",","optional",")",":","Kernels","for","generalized","attention",".","If","not","specified",",","`","ReLU","`","kernel","will","be","used",".","(","default",":",":","obj",":","`","torch.nn.ReLU","(",")","`",")","qkv_bias","(","bool",",","optional",")",":","If","specified",",","add","bias","to","query",",","key","and","value","in","the","self","attention",".","(","default",":",":","obj",":","`","False","`",")","attn_out_bias","(","bool",",","optional",")",":","If","specified",",","add","bias","to","the","attention","output",".","(","default",":",":","obj",":","`","True","`",")","dropout","(","float",",","optional",")",":","Dropout","probability","of","the","final","attention","output",".","(","default",":",":","obj",":","`","0.0","`",")"]
docstr: Forward pass.
  
  Args:
      x (torch.Tensor): Node feature tensor
          :math:`\mathbf{X} \in \mathbb{R}^{B \times N \times F}`, with
          batch-size :math:`B`, (maximum) number of nodes :math:`N` for
          each graph, and feature dimension :math:`F`.
      mask (torch.Tensor, optional): Mask matrix
          :math:`\mathbf{M} \in {\{ 0, 1 \}}^{B \times N}` indicating
          the valid nodes for each graph. (default: :obj:`None`)
docstr_tok: ["Forward","pass",".","Args",":","x","(","torch.Tensor",")",":","Node","feature","tensor",":","math",":","`","\\mathbf","{","X","}","\\in","\\mathbb","{","R","}","^","{","B","\\times","N","\\times","F","}","`",",","with","batch-size",":","math",":","`","B","`",",","(","maximum",")","number","of","nodes",":","math",":","`","N","`","for","each","graph",",","and","feature","dimension",":","math",":","`","F","`",".","mask","(","torch.Tensor",",","optional",")",":","Mask","matrix",":","math",":","`","\\mathbf","{","M","}","\\in","{","\\","{","0",",","1","\\","}","}","^","{","B","\\times","N","}","`","indicating","the","valid","nodes","for","each","graph",".","(","default",":",":","obj",":","`","None","`",")"]
code: def forward(self, x: Tensor, mask: Optional[Tensor] = None) -> Tensor:
      r"""Forward pass.
  
      Args:
          x (torch.Tensor): Node feature tensor
              :math:`\mathbf{X} \in \mathbb{R}^{B \times N \times F}`, with
              batch-size :math:`B`, (maximum) number of nodes :math:`N` for
              each graph, and feature dimension :math:`F`.
          mask (torch.Tensor, optional): Mask matrix
              :math:`\mathbf{M} \in {\{ 0, 1 \}}^{B \times N}` indicating
              the valid nodes for each graph. (default: :obj:`None`)
      """
      B, N, *_ = x.shape
      q, k, v = self.q(x), self.k(x), self.v(x)
      # Reshape and permute q, k and v to proper shape
      # (B, N, num_heads * head_channels) to (b, num_heads, n, head_channels)
      q, k, v = map(
          lambda t: t.reshape(
              B, N, self.heads, self.head_channels
          ).permute(0, 2, 1, 3),
          (q, k, v),
      )
      if mask is not None:
          mask = mask[:, None, :, None]
          v.masked_fill_(~mask, 0.0)
      out = self.fast_attn(q, k, v)
      out = out.permute(0, 2, 1, 3).reshape(B, N, -1)
      out = self.attn_out(out)
      out = self.dropout(out)
      return out
  
file_path: pytorch_geometric/torch_geometric/nn/attention/performer.py
imports: import math
  from typing import Callable, Optional
  import torch
  from torch import Tensor
label_desc: Use image node_id 2 for calling the PerformerAttention obj's underlying member method code with example usage: obj.forward(x, mask) and returns: out