class_docstr: Module, which computes HardNet descriptors of given grayscale patches of 32x32.
  
  This is based on the original code from paper "Working hard to know your neighbor's
  margins: Local descriptor learning loss". See :cite:`HardNet2017` for more details.
  
  Args:
      pretrained: Download and set pretrained weights to the model.
  
  Returns:
      torch.Tensor: HardNet descriptor of the patches.
  
  Shape:
      - Input: :math:`(B, 1, 32, 32)`
      - Output: :math:`(B, 128)`
  
  Examples:
      >>> input = torch.rand(16, 1, 32, 32)
      >>> hardnet = HardNet()
      >>> descs = hardnet(input) # 16x128
class_docstr_tok: ["Module",",","which","computes","HardNet","descriptors","of","given","grayscale","patches","of","32x32",".","This","is","based","on","the","original","code","from","paper","``","Working","hard","to","know","your","neighbor's","margins",":","Local","descriptor","learning","loss","''",".","See",":","cite",":","`","HardNet2017","`","for","more","details",".","Args",":","pretrained",":","Download","and","set","pretrained","weights","to","the","model",".","Returns",":","torch.Tensor",":","HardNet","descriptor","of","the","patches",".","Shape",":","-","Input",":",":","math",":","`","(","B",",","1",",","32",",","32",")","`","-","Output",":",":","math",":","`","(","B",",","128",")","`","Examples",":",">",">",">","input","=","torch.rand","(","16",",","1",",","32",",","32",")",">",">",">","hardnet","=","HardNet","(",")",">",">",">","descs","=","hardnet","(","input",")","#","16x128"]
docstr: Utility function that normalizes the input by batch.
docstr_tok: ["Utility","function","that","normalizes","the","input","by","batch","."]
code: def _normalize_input(
      x: torch.Tensor, eps: float = 1e-6
  ) -> torch.Tensor:
      """Utility function that normalizes the input by batch."""
      if not is_mps_tensor_safe(x):
          sp, mp = torch.std_mean(x, dim=(-3, -2, -1), keepdim=True)
      else:
          mp = torch.mean(x, dim=(-3, -2, -1), keepdim=True)
          sp = torch.std(x, dim=(-3, -2, -1), keepdim=True)
      # WARNING: we need to .detach() input, otherwise the gradients produced by
      # the patches extractor with F.grid_sample are very noisy, making the detector
      # training totally unstable.
      return (x - mp.detach()) / (sp.detach() + eps)
  
file_path: kornia/kornia/feature/hardnet.py
imports: from typing import Dict
  import torch
  import torch.nn.functional
  from torch import nn
  from kornia.core.check import KORNIA_CHECK_SHAPE
  from kornia.testing import is_mps_tensor_safe
  from kornia.utils.helpers import map_location_to_cpu
label_desc: Use image node_id 2 for calling the HardNet obj's underlying member method code with example usage: obj._normalize_input(x, eps) and returns: unknown