docstr: Standard matching and filtering with AdaLAM. This function:
  
      - performs some elementary sanity check on the inputs;
      - wraps input arrays into torch tensors and loads to GPU if necessary;
      - extracts nearest neighbors;
      - finds mutual nearest neighbors if required;
      - finally calls AdaLAM filtering.
  
  Inputs:
      k1: keypoint locations in the source image, in pixel coordinates.
          Expected an array with shape (num_keypoints_in_source_image, 2).
      k2: keypoint locations in the destination image, in pixel coordinates.
          Expected an array with shape (num_keypoints_in_destination_image, 2).
      d1: descriptors in the source image.
          Expected an array with shape (num_keypoints_in_source_image, descriptor_size).
      d2: descriptors in the destination image.
          Expected an array with shape (num_keypoints_in_destination_image, descriptor_size).
      im1shape: Shape of the source image. If None, it is inferred from keypoints max and min, at the cost of
                wasted runtime. So please provide it. Expected a tuple with (width, height) or (height, width)
                of source image
      im2shape: Shape of the destination image. If None, it is inferred from keypoints max and min, at the cost
                of wasted runtime. So please provide it. Expected a tuple with (width, height) or (height, width)
                of destination image
      o1/o2: keypoint orientations in degrees. They can be None if 'orientation_difference_threshold' in config
             is set to None. See documentation on 'orientation_difference_threshold' in the DEFAULT_CONFIG.
             Expected an array with shape (num_keypoints_in_source/destination_image,)
      s1/s2: keypoint scales. They can be None if 'scale_rate_threshold' in config is set to None.
             See documentation on 'scale_rate_threshold' in the DEFAULT_CONFIG.
             Expected an array with shape (num_keypoints_in_source/destination_image,)
      return_dist: if True, inverse confidence value is also outputted.
  
  Returns:
      Filtered putative matches.
      A long tensor with shape (num_filtered_matches, 2) with indices of corresponding keypoints in k1 and k2.
docstr_tok: ["Standard","matching","and","filtering","with","AdaLAM",".","This","function",":","-","performs","some","elementary","sanity","check","on","the","inputs",";","-","wraps","input","arrays","into","torch","tensors","and","loads","to","GPU","if","necessary",";","-","extracts","nearest","neighbors",";","-","finds","mutual","nearest","neighbors","if","required",";","-","finally","calls","AdaLAM","filtering",".","Inputs",":","k1",":","keypoint","locations","in","the","source","image",",","in","pixel","coordinates",".","Expected","an","array","with","shape","(","num_keypoints_in_source_image",",","2",")",".","k2",":","keypoint","locations","in","the","destination","image",",","in","pixel","coordinates",".","Expected","an","array","with","shape","(","num_keypoints_in_destination_image",",","2",")",".","d1",":","descriptors","in","the","source","image",".","Expected","an","array","with","shape","(","num_keypoints_in_source_image",",","descriptor_size",")",".","d2",":","descriptors","in","the","destination","image",".","Expected","an","array","with","shape","(","num_keypoints_in_destination_image",",","descriptor_size",")",".","im1shape",":","Shape","of","the","source","image",".","If","None",",","it","is","inferred","from","keypoints","max","and","min",",","at","the","cost","of","wasted","runtime",".","So","please","provide","it",".","Expected","a","tuple","with","(","width",",","height",")","or","(","height",",","width",")","of","source","image","im2shape",":","Shape","of","the","destination","image",".","If","None",",","it","is","inferred","from","keypoints","max","and","min",",","at","the","cost","of","wasted","runtime",".","So","please","provide","it",".","Expected","a","tuple","with","(","width",",","height",")","or","(","height",",","width",")","of","destination","image","o1\/o2",":","keypoint","orientations","in","degrees",".","They","can","be","None","if","'orientation_difference_threshold","'","in","config","is","set","to","None",".","See","documentation","on","'orientation_difference_threshold","'","in","the","DEFAULT_CONFIG",".","Expected","an","array","with","shape","(","num_keypoints_in_source\/destination_image",",",")","s1\/s2",":","keypoint","scales",".","They","can","be","None","if","'scale_rate_threshold","'","in","config","is","set","to","None",".","See","documentation","on","'scale_rate_threshold","'","in","the","DEFAULT_CONFIG",".","Expected","an","array","with","shape","(","num_keypoints_in_source\/destination_image",",",")","return_dist",":","if","True",",","inverse","confidence","value","is","also","outputted",".","Returns",":","Filtered","putative","matches",".","A","long","tensor","with","shape","(","num_filtered_matches",",","2",")","with","indices","of","corresponding","keypoints","in","k1","and","k2","."]
code: def match_and_filter(
      self,
      k1: Tensor,
      k2: Tensor,
      d1: Tensor,
      d2: Tensor,
      im1shape: Optional[Tuple[int, int]] = None,
      im2shape: Optional[Tuple[int, int]] = None,
      o1: Optional[Tensor] = None,
      o2: Optional[Tensor] = None,
      s1: Optional[Tensor] = None,
      s2: Optional[Tensor] = None,
      return_dist: bool = False,
  ) -> Union[Tuple[Tensor, Tensor], Tensor]:
      """Standard matching and filtering with AdaLAM. This function:
  
          - performs some elementary sanity check on the inputs;
          - wraps input arrays into torch tensors and loads to GPU if necessary;
          - extracts nearest neighbors;
          - finds mutual nearest neighbors if required;
          - finally calls AdaLAM filtering.
  
      Inputs:
          k1: keypoint locations in the source image, in pixel coordinates.
              Expected an array with shape (num_keypoints_in_source_image, 2).
          k2: keypoint locations in the destination image, in pixel coordinates.
              Expected an array with shape (num_keypoints_in_destination_image, 2).
          d1: descriptors in the source image.
              Expected an array with shape (num_keypoints_in_source_image, descriptor_size).
          d2: descriptors in the destination image.
              Expected an array with shape (num_keypoints_in_destination_image, descriptor_size).
          im1shape: Shape of the source image. If None, it is inferred from keypoints max and min, at the cost of
                    wasted runtime. So please provide it. Expected a tuple with (width, height) or (height, width)
                    of source image
          im2shape: Shape of the destination image. If None, it is inferred from keypoints max and min, at the cost
                    of wasted runtime. So please provide it. Expected a tuple with (width, height) or (height, width)
                    of destination image
          o1/o2: keypoint orientations in degrees. They can be None if 'orientation_difference_threshold' in config
                 is set to None. See documentation on 'orientation_difference_threshold' in the DEFAULT_CONFIG.
                 Expected an array with shape (num_keypoints_in_source/destination_image,)
          s1/s2: keypoint scales. They can be None if 'scale_rate_threshold' in config is set to None.
                 See documentation on 'scale_rate_threshold' in the DEFAULT_CONFIG.
                 Expected an array with shape (num_keypoints_in_source/destination_image,)
          return_dist: if True, inverse confidence value is also outputted.
  
      Returns:
          Filtered putative matches.
          A long tensor with shape (num_filtered_matches, 2) with indices of corresponding keypoints in k1 and k2.
      """
      if s1 is None or s2 is None:
          if self.config["scale_rate_threshold"] is not None:
              raise AttributeError(
                  "Current configuration considers keypoint scales for filtering, but scales have not been provided.\n"  # noqa: E501
                  "Please either provide scales or set 'scale_rate_threshold' to None to disable scale filtering"
              )
      if o1 is None or o2 is None:
          if (
              self.config["orientation_difference_threshold"]
              is not None
          ):
              raise AttributeError(
                  "Current configuration considers keypoint orientations for filtering, but orientations have not been provided.\n"  # noqa: E501
                  "Please either provide orientations or set 'orientation_difference_threshold' to None to disable orientations filtering"  # noqa: E501
              )
      _k1 = as_tensor(
          k1, device=self.config["device"], dtype=torch.float32
      )
      _k2 = as_tensor(
          k2, device=self.config["device"], dtype=torch.float32
      )
      _d1 = as_tensor(
          d1, device=self.config["device"], dtype=torch.float32
      )
      _d2 = as_tensor(
          d2, device=self.config["device"], dtype=torch.float32
      )
      if o1 is not None:
          _o1 = as_tensor(
              o1, device=self.config["device"], dtype=torch.float32
          )
          _o2 = as_tensor(
              o2, device=self.config["device"], dtype=torch.float32
          )
      else:
          _o1, _o2 = o1, o2
      if s1 is not None:
          _s1 = as_tensor(
              s1, device=self.config["device"], dtype=torch.float32
          )
          _s2 = as_tensor(
              s2, device=self.config["device"], dtype=torch.float32
          )
      else:
          _s1, _s2 = s1, s2
  
      if (len(_d2) <= 1) or (len(_d1) <= 1):
          idxs, dists = _no_match(_d1)
          if return_dist:
              return idxs, dists
          return idxs
  
      distmat = dist_matrix(_d1, _d2, is_normalized=False)
      dd12, nn12 = torch.topk(
          distmat, k=2, dim=1, largest=False
      )  # (n1, 2)
  
      putative_matches = nn12[:, 0]
      scores = dd12[:, 0] / dd12[:, 1].clamp_min_(1e-3)
  
      if self.config["force_seed_mnn"]:
          dd21, nn21 = torch.min(distmat, dim=0)  # (n2,)
          mnn = nn21[putative_matches] == torch.arange(
              _k1.shape[0], device=self.config["device"]
          )
      else:
          mnn = None
  
      return self.filter_matches(
          _k1,
          _k2,
          putative_matches,
          scores,
          mnn,
          im1shape,
          im2shape,
          _o1,
          _o2,
          _s1,
          _s2,
          return_dist,
      )
  
file_path: kornia/kornia/feature/adalam/adalam.py
imports: from typing import Optional, Tuple, Union
  import torch
  from kornia.core import Tensor, as_tensor
  from kornia.core.check import KORNIA_CHECK_LAF, KORNIA_CHECK_SHAPE
  from kornia.feature.laf import get_laf_center, get_laf_orientation, get_laf_scale
  from .core import AdalamConfig, _no_match, adalam_core
  from .utils import dist_matrix
label_desc: Use image node_id 3 for calling the AdalamFilter obj's underlying member method code with example usage: obj.match_and_filter(k1, k2, d1, d2, im1shape, im2shape, o1, o2, s1, s2, return_dist) and returns: self, idxs, idxs,  dists