class_docstr: Module which detects and described local features in an image using the DISK method. See
  :cite:`tyszkiewicz2020disk` for details.
  
  .. image:: _static/img/disk_outdoor_depth.jpg
  
  Args:
      desc_dim: The dimension of the descriptor.
      unet: The U-Net to use. If None, a default U-Net is used. Kornia doesn't provide the training code for DISK
            so this is only useful when using a custom checkpoint trained using the code released with the paper.
            The unet should take as input a tensor of shape :math:`(B, C, H, W)` and output a tensor of shape
            :math:`(B, \mathrm{desc\_dim} + 1, H, W)`.
  
  Example:
      >>> disk = DISK.from_pretrained('depth')
      >>> images = torch.rand(1, 3, 256, 256)
      >>> features = disk(images)
class_docstr_tok: ["Module","which","detects","and","described","local","features","in","an","image","using","the","DISK","method",".","See",":","cite",":","`","tyszkiewicz2020disk","`","for","details",".","..","image",":",":","_static\/img\/disk_outdoor_depth.jpg","Args",":","desc_dim",":","The","dimension","of","the","descriptor",".","unet",":","The","U-Net","to","use",".","If","None",",","a","default","U-Net","is","used",".","Kornia","does","n't","provide","the","training","code","for","DISK","so","this","is","only","useful","when","using","a","custom","checkpoint","trained","using","the","code","released","with","the","paper",".","The","unet","should","take","as","input","a","tensor","of","shape",":","math",":","`","(","B",",","C",",","H",",","W",")","`","and","output","a","tensor","of","shape",":","math",":","`","(","B",",","\\mathrm","{","desc\\_dim","}","+","1",",","H",",","W",")","`",".","Example",":",">",">",">","disk","=","DISK.from_pretrained","(","'depth","'",")",">",">",">","images","=","torch.rand","(","1",",","3",",","256",",","256",")",">",">",">","features","=","disk","(","images",")"]
docstr: Returns the heatmap and the dense descriptors.
  
  .. image:: _static/img/DISK.png
  
  Args:
      images: The image to detect features in. Shape :math:`(B, 3, H, W)`.
  
  Returns:
      A tuple of dense detection scores and descriptors.
      Shapes are :math:`(B, 1, H, W)` and :math:`(B, D, H, W)`, where
      :math:`D` is the descriptor dimension.
docstr_tok: ["Returns","the","heatmap","and","the","dense","descriptors",".","..","image",":",":","_static\/img\/DISK.png","Args",":","images",":","The","image","to","detect","features","in",".","Shape",":","math",":","`","(","B",",","3",",","H",",","W",")","`",".","Returns",":","A","tuple","of","dense","detection","scores","and","descriptors",".","Shapes","are",":","math",":","`","(","B",",","1",",","H",",","W",")","`","and",":","math",":","`","(","B",",","D",",","H",",","W",")","`",",","where",":","math",":","`","D","`","is","the","descriptor","dimension","."]
code: def heatmap_and_dense_descriptors(
      self, images: Tensor
  ) -> tuple[Tensor, Tensor]:
      """Returns the heatmap and the dense descriptors.
  
      .. image:: _static/img/DISK.png
  
      Args:
          images: The image to detect features in. Shape :math:`(B, 3, H, W)`.
  
      Returns:
          A tuple of dense detection scores and descriptors.
          Shapes are :math:`(B, 1, H, W)` and :math:`(B, D, H, W)`, where
          :math:`D` is the descriptor dimension.
      """
      unet_output = self.unet(images)
  
      if unet_output.shape[1] != self.desc_dim + 1:
          raise ValueError(
              f"U-Net output has {unet_output.shape[1]} channels, but expected self.desc_dim={self.desc_dim} + 1."
          )
  
      descriptors = unet_output[:, : self.desc_dim]
      heatmaps = unet_output[:, self.desc_dim :]
  
      return heatmaps, descriptors
  
file_path: kornia/kornia/feature/disk/disk.py
imports: from __future__ import annotations
  from typing import Optional
  import torch
  from kornia.core import Module, Tensor
  from ._unets import Unet
  from .detector import heatmap_to_keypoints
  from .structs import DISKFeatures
label_desc: Use image node_id 2 for calling the DISK obj's underlying member method code with example usage: obj.heatmap_and_dense_descriptors(images) and returns: heatmaps,  descriptors