class_docstr: Multi-scale feature detector, based on code from KeyNet. Can be used with any response function.
  
  This is based on the original code from paper
  "Key.Net: Keypoint Detection by Handcrafted and Learned CNN Filters".
  See :cite:`KeyNet2019` for more details.
  
  Args:
      model: response function, such as KeyNet or BlobHessian
      num_features: Number of features to detect.
      conf: Dict with initialization parameters. Do not pass it, unless you know what you are doing`.
      ori_module: for local feature orientation estimation. Default: :class:`~kornia.feature.PassLAF`,
         which does nothing. See :class:`~kornia.feature.LAFOrienter` for details.
      aff_module: for local feature affine shape estimation. Default: :class:`~kornia.feature.PassLAF`,
          which does nothing. See :class:`~kornia.feature.LAFAffineShapeEstimator` for details.
class_docstr_tok: ["Multi-scale","feature","detector",",","based","on","code","from","KeyNet",".","Can","be","used","with","any","response","function",".","This","is","based","on","the","original","code","from","paper","''","Key.Net",":","Keypoint","Detection","by","Handcrafted","and","Learned","CNN","Filters","''",".","See",":","cite",":","`","KeyNet2019","`","for","more","details",".","Args",":","model",":","response","function",",","such","as","KeyNet","or","BlobHessian","num_features",":","Number","of","features","to","detect",".","conf",":","Dict","with","initialization","parameters",".","Do","not","pass","it",",","unless","you","know","what","you","are","doing","`",".","ori_module",":","for","local","feature","orientation","estimation",".","Default",":",":","class",":","`","~kornia.feature.PassLAF","`",",","which","does","nothing",".","See",":","class",":","`","~kornia.feature.LAFOrienter","`","for","details",".","aff_module",":","for","local","feature","affine","shape","estimation",".","Default",":",":","class",":","`","~kornia.feature.PassLAF","`",",","which","does","nothing",".","See",":","class",":","`","~kornia.feature.LAFAffineShapeEstimator","`","for","details","."]
code: def detect(
      self, img: Tensor, mask: Optional[Tensor] = None
  ) -> Tuple[Tensor, Tensor]:
      # Compute points per level
      num_features_per_level: List[float] = []
      tmp = 0.0
      factor_points = self.scale_factor_levels**2
      levels = self.num_pyramid_levels + self.num_upscale_levels + 1
      for idx_level in range(levels):
          tmp += factor_points ** (
              -1 * (idx_level - self.num_upscale_levels)
          )
          nf = self.num_features * factor_points ** (
              -1 * (idx_level - self.num_upscale_levels)
          )
          num_features_per_level.append(nf)
      num_features_per_level = [
          int(x / tmp) for x in num_features_per_level
      ]
  
      _, _, h, w = img.shape
      img_up = img
      cur_img = img
      all_responses: List[Tensor] = []
      all_lafs: List[Tensor] = []
      # Extract features from the upper levels
      for idx_level in range(self.num_upscale_levels):
          nf = num_features_per_level[
              len(num_features_per_level)
              - self.num_pyramid_levels
              - 1
              - (idx_level + 1)
          ]
          num_points_level = int(nf)
  
          # Resize input image
          up_factor = self.scale_factor_levels ** (1 + idx_level)
          nh, nw = int(h * up_factor), int(w * up_factor)
          up_factor_kpts = (float(w) / float(nw), float(h) / float(nh))
          img_up = resize(
              img_up,
              (nh, nw),
              interpolation="bilinear",
              align_corners=False,
          )
  
          cur_scores, cur_lafs = self.detect_features_on_single_level(
              img_up, num_points_level, up_factor_kpts
          )
  
          all_responses.append(cur_scores.view(1, -1))
          all_lafs.append(cur_lafs)
  
      # Extract features from the downsampling pyramid
      for idx_level in range(self.num_pyramid_levels + 1):
          if idx_level > 0:
              cur_img = pyrdown(
                  cur_img, factor=self.scale_factor_levels
              )
              _, _, nh, nw = cur_img.shape
              factor = (float(w) / float(nw), float(h) / float(nh))
          else:
              factor = (1.0, 1.0)
  
          num_points_level = int(num_features_per_level[idx_level])
          if idx_level > 0 or (self.num_upscale_levels > 0):
              nf2 = [
                  num_features_per_level[a]
                  for a in range(
                      0, idx_level + 1 + self.num_upscale_levels
                  )
              ]
              res_points = tensor(nf2).sum().item()
              num_points_level = int(res_points)
  
          cur_scores, cur_lafs = self.detect_features_on_single_level(
              cur_img, num_points_level, factor
          )
          all_responses.append(cur_scores.view(1, -1))
          all_lafs.append(cur_lafs)
      responses = concatenate(all_responses, 1)
      lafs = concatenate(all_lafs, 1)
      if lafs.shape[1] > self.num_features:
          responses, idxs = torch.topk(
              responses, k=self.num_features, dim=1
          )
          lafs = torch.gather(
              lafs, 1, idxs[..., None, None].expand(-1, -1, 2, 3)
          )
      return responses, lafs
  
imports: import math
  from typing import List, Optional, Tuple
  import torch
  import torch.nn.functional
  from typing_extensions import TypedDict
  from kornia.core import Device, Module, Tensor, concatenate, eye, tensor, where, zeros
  from kornia.core.check import KORNIA_CHECK_SHAPE
  from kornia.geometry.subpix import ConvSoftArgmax3d, NonMaximaSuppression2d
  from kornia.geometry.transform import ScalePyramid, pyrdown, resize
  from .laf import laf_from_center_scale_ori, laf_is_inside_image
  from .orientation import PassLAF
  from .responses import BlobHessian
label_desc: Use image node_id 4 for calling the MultiResolutionDetector obj's underlying member method code with example usage: obj.detect(img, mask) and returns: responses,  lafs