code: def __init__(self, features: str = "superpoint", **conf_) -> None:  # type: ignore
      super().__init__()
      self.conf = conf = SimpleNamespace(
          **{**self.default_conf, **conf_}
      )
      if features is not None:
          KORNIA_CHECK(
              features in list(self.features.keys()),
              "Features keys are wrong",
          )
          for k, v in self.features[features].items():
              setattr(conf, k, v)
      KORNIA_CHECK(
          not (self.conf.add_scale_ori and self.conf.add_laf)
      )  # we use either scale ori, or LAF
  
      if conf.input_dim != conf.descriptor_dim:
          self.input_proj = nn.Linear(
              conf.input_dim, conf.descriptor_dim, bias=True
          )
      else:
          self.input_proj = nn.Identity()  # type: ignore
  
      head_dim = conf.descriptor_dim // conf.num_heads
      self.posenc = LearnableFourierPositionalEncoding(
          2 + 2 * conf.add_scale_ori + 4 * conf.add_laf,
          head_dim,
          head_dim,
      )
  
      h, n, d = conf.num_heads, conf.n_layers, conf.descriptor_dim
      self.transformers = ModuleList(
          [TransformerLayer(d, h, conf.flash) for _ in range(n)]
      )
      self.log_assignment = ModuleList(
          [MatchAssignment(d) for _ in range(n)]
      )
      self.token_confidence = ModuleList(
          [TokenConfidence(d) for _ in range(n - 1)]
      )
      self.register_buffer(
          "confidence_thresholds",
          Tensor(
              [
                  self.confidence_threshold(i)
                  for i in range(self.conf.n_layers)
              ]
          ),
      )
      state_dict = None
      if features is not None:
          fname = f"{conf.weights}_{self.version}.pth".replace(".", "-")
          if features in [
              "keynet_affnet_hardnet",
              "dog_affnet_hardnet",
          ]:
              fname = "keynet_affnet_hardnet_lightlue.pth"
              url = "http://cmp.felk.cvut.cz/~mishkdmy/models/keynet_affnet_hardnet_lightlue.pth"
          else:
              url = self.url.format(self.version, features)
          state_dict = torch.hub.load_state_dict_from_url(
              url, file_name=fname
          )
      elif conf.weights is not None:
          path = Path(__file__).parent
          path = path / f"weights/{self.conf.weights}.pth"
          state_dict = torch.load(str(path), map_location="cpu")
      if state_dict:
          # rename old state dict entries
          for i in range(self.conf.n_layers):
              pattern = f"self_attn.{i}", f"transformers.{i}.self_attn"
              state_dict = {
                  k.replace(*pattern): v for k, v in state_dict.items()
              }
              pattern = (
                  f"cross_attn.{i}",
                  f"transformers.{i}.cross_attn",
              )
              state_dict = {
                  k.replace(*pattern): v for k, v in state_dict.items()
              }
          self.load_state_dict(state_dict, strict=False)
      print("Loaded LightGlue model")
      # static lengths LightGlue is compiled for (only used with torch.compile)
      self.static_lengths = None
  
imports: import math
  import warnings
  from pathlib import Path
  from types import SimpleNamespace
  from typing import Any, Callable, ClassVar, Dict, List, Optional, Tuple
  import torch
  import torch.nn.functional
  from torch import nn
  from kornia.core import Module, ModuleList, Tensor, arange, concatenate, cos, einsum, ones, ones_like, sin, stack, where, zeros
  from kornia.core.check import KORNIA_CHECK
  from kornia.feature.laf import laf_to_three_points, scale_laf
label_desc: Use image node_id 1 to create a new LightGlue object from inherited base classes: Module with example: obj = LightGlue(features)