class_docstr: This is a sinusoidal position encoding that generalized to 2-dimensional images.
docstr: Args:
      max_shape (tuple): for 1/8 featmap, the max length of 256 corresponds to 2048 pixels
      temp_bug_fix (bool): As noted in this [issue](https://github.com/zju3dv/LoFTR/issues/41),
          the original implementation of LoFTR includes a bug in the pos-enc impl, which has little impact
          on the final performance. For now, we keep both impls for backward compatibility.
          We will remove the buggy impl after re-training all variants of our released models.
docstr_tok: ["Args",":","max_shape","(","tuple",")",":","for","1\/8","featmap",",","the","max","length","of","256","corresponds","to","2048","pixels","temp_bug_fix","(","bool",")",":","As","noted","in","this","[","issue","]","(","https",":","\/\/github.com\/zju3dv\/LoFTR\/issues\/41",")",",","the","original","implementation","of","LoFTR","includes","a","bug","in","the","pos-enc","impl",",","which","has","little","impact","on","the","final","performance",".","For","now",",","we","keep","both","impls","for","backward","compatibility",".","We","will","remove","the","buggy","impl","after","re-training","all","variants","of","our","released","models","."]
code: def __init__(
      self,
      d_model: int,
      max_shape: Tuple[int, int] = (256, 256),
      temp_bug_fix: bool = True,
  ) -> None:
      """
      Args:
          max_shape (tuple): for 1/8 featmap, the max length of 256 corresponds to 2048 pixels
          temp_bug_fix (bool): As noted in this [issue](https://github.com/zju3dv/LoFTR/issues/41),
              the original implementation of LoFTR includes a bug in the pos-enc impl, which has little impact
              on the final performance. For now, we keep both impls for backward compatibility.
              We will remove the buggy impl after re-training all variants of our released models.
      """
      super().__init__()
      self.d_model = d_model
      self.temp_bug_fix = temp_bug_fix
  
      pe = self._create_position_encoding(max_shape)
      self.register_buffer("pe", pe, persistent=False)
  
file_path: kornia/kornia/feature/loftr/utils/position_encoding.py
imports: import math
  from typing import Tuple
  import torch
  from kornia.core import Module, Tensor, cos, sin, zeros
label_desc: Use image node_id 1 to create a new PositionEncodingSine object from inherited base classes: Module with example: obj = PositionEncodingSine(d_model, max_shape, temp_bug_fix)