class_docstr: LoFTR transformer module from: https://arxiv.org/pdf/2104.00680.pdf
  Canonical implementations at: https://github.com/zju3dv/LoFTR/blob/master/src/loftr/loftr_module/transformer.py
class_docstr_tok: ["LoFTR","transformer","module","from",":","https",":","\/\/arxiv.org\/pdf\/2104.00680.pdf","Canonical","implementations","at",":","https",":","\/\/github.com\/zju3dv\/LoFTR\/blob\/master\/src\/loftr\/loftr_module\/transformer.py"]
docstr: Args:
      x (torch.Tensor): [B, S1, D]
      source (torch.Tensor): [B, S2, D]
      x_mask (torch.Tensor): [B, S1] (optional)
      source_mask (torch.Tensor): [B, S2] (optional)
docstr_tok: ["Args",":","x","(","torch.Tensor",")",":","[","B",",","S1",",","D","]","source","(","torch.Tensor",")",":","[","B",",","S2",",","D","]","x_mask","(","torch.Tensor",")",":","[","B",",","S1","]","(","optional",")","source_mask","(","torch.Tensor",")",":","[","B",",","S2","]","(","optional",")"]
code: def forward(
      self,
      x: Tensor,
      source: Tensor,
      x_mask: Optional[Tensor] = None,
      source_mask: Optional[Tensor] = None,
  ) -> Tensor:
      """
      Args:
          x (torch.Tensor): [B, S1, D]
          source (torch.Tensor): [B, S2, D]
          x_mask (torch.Tensor): [B, S1] (optional)
          source_mask (torch.Tensor): [B, S2] (optional)
      """
      B, S, D = x.shape
      queries, keys, values = x, source, source
  
      queries = self.query_proj(queries).reshape(
          B, S, self.num_heads, self.dim_head
      )
      keys = self.key_proj(keys).reshape(
          B, S, self.num_heads, self.dim_head
      )
      values = self.value_proj(values).reshape(
          B, S, self.num_heads, self.dim_head
      )
  
      # attention operation
      message = self.attention_op(
          queries, keys, values, x_mask, source_mask
      )
      # concatenating attention heads together before passing through projection layer
      message = self.merge(message.reshape(B, S, D))
      message = self.attention_norm(message)
  
      # ffn operation
      message = self.ffn(torch.cat([x, message], dim=2))
      message = self.ffn_norm(message)
  
      return x + message
  
imports: import math
  from functools import partial
  from typing import Callable, Dict, Iterable, List, Optional, Tuple
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torchvision.models.optical_flow.raft
  from torch import Tensor
  from torchvision.models._api import register_model, Weights, WeightsEnum
  from torchvision.models._utils import handle_legacy_interface
  from torchvision.models.optical_flow._utils import grid_sample, make_coords_grid, upsample_flow
  from torchvision.ops import Conv2dNormActivation
  from torchvision.prototype.transforms._presets import StereoMatching
label_desc: Use image node_id 2 for calling the LocalFeatureEncoderLayer obj's underlying member method code with example usage: obj.forward(x, source, x_mask, source_mask) and returns: unknown