code: def __init__(
      self,
      d_model: int,
      nhead: int,
      attention: Optional[Literal["linear"]] = "linear",
  ) -> None:
      super().__init__()
  
      self.dim = d_model // nhead
      self.nhead = nhead
  
      # multi-head attention
      self.q_proj = nn.Linear(d_model, d_model, bias=False)
      self.k_proj = nn.Linear(d_model, d_model, bias=False)
      self.v_proj = nn.Linear(d_model, d_model, bias=False)
      self.attention = (
          LinearAttention()
          if attention == "linear"
          else FullAttention()
      )
      self.merge = nn.Linear(d_model, d_model, bias=False)
  
      # feed-forward network
      self.mlp = nn.Sequential(
          nn.Linear(d_model * 2, d_model * 2, bias=False),
          nn.ReLU(True),
          nn.Linear(d_model * 2, d_model, bias=False),
      )
  
      # norm and dropout
      self.norm1 = nn.LayerNorm(d_model)
      self.norm2 = nn.LayerNorm(d_model)
  
file_path: kornia/kornia/feature/loftr/loftr_module/transformer.py
imports: from __future__ import annotations
  import copy
  from typing import Any, Literal, Optional
  import torch
  from torch import nn
  from kornia.core import Module, Tensor
  from .linear_attention import FullAttention, LinearAttention
label_desc: Use image node_id 1 to create a new LoFTREncoderLayer object from inherited base classes: Module with example: obj = LoFTREncoderLayer(d_model, nhead, attention)