class_docstr: Module, which computes HardNet8 descriptors of given grayscale patches of 32x32.
  
  This is based on the original code from paper "Improving the HardNet Descriptor".
  See :cite:`HardNet2020` for more details.
  
  Args:
      pretrained: Download and set pretrained weights to the model.
  
  Returns:
      torch.Tensor: HardNet8 descriptor of the patches.
  
  Shape:
      - Input: :math:`(B, 1, 32, 32)`
      - Output: :math:`(B, 128)`
  
  Examples:
      >>> input = torch.rand(16, 1, 32, 32)
      >>> hardnet = HardNet8()
      >>> descs = hardnet(input) # 16x128
class_docstr_tok: ["Module",",","which","computes","HardNet8","descriptors","of","given","grayscale","patches","of","32x32",".","This","is","based","on","the","original","code","from","paper","``","Improving","the","HardNet","Descriptor","''",".","See",":","cite",":","`","HardNet2020","`","for","more","details",".","Args",":","pretrained",":","Download","and","set","pretrained","weights","to","the","model",".","Returns",":","torch.Tensor",":","HardNet8","descriptor","of","the","patches",".","Shape",":","-","Input",":",":","math",":","`","(","B",",","1",",","32",",","32",")","`","-","Output",":",":","math",":","`","(","B",",","128",")","`","Examples",":",">",">",">","input","=","torch.rand","(","16",",","1",",","32",",","32",")",">",">",">","hardnet","=","HardNet8","(",")",">",">",">","descs","=","hardnet","(","input",")","#","16x128"]
code: def __init__(self, pretrained: bool = False) -> None:
      super().__init__()
      self.features = nn.Sequential(
          nn.Conv2d(1, 32, kernel_size=3, padding=1, bias=False),
          nn.BatchNorm2d(32, affine=False),
          nn.ReLU(),
          nn.Conv2d(32, 32, kernel_size=3, padding=1, bias=False),
          nn.BatchNorm2d(32, affine=False),
          nn.ReLU(),
          nn.Conv2d(
              32, 64, kernel_size=3, stride=2, padding=1, bias=False
          ),
          nn.BatchNorm2d(64, affine=False),
          nn.ReLU(),
          nn.Conv2d(64, 64, kernel_size=3, padding=1, bias=False),
          nn.BatchNorm2d(64, affine=False),
          nn.ReLU(),
          nn.Conv2d(
              64, 128, kernel_size=3, stride=2, padding=1, bias=False
          ),
          nn.BatchNorm2d(128, affine=False),
          nn.ReLU(),
          nn.Conv2d(128, 128, kernel_size=3, padding=1, bias=False),
          nn.BatchNorm2d(128, affine=False),
          nn.ReLU(),
          nn.Conv2d(128, 256, kernel_size=3, padding=1, bias=False),
          nn.BatchNorm2d(256, affine=False),
          nn.ReLU(),
          nn.Dropout(0.3),
          nn.Conv2d(256, 512, kernel_size=8, bias=False),
          nn.BatchNorm2d(512, affine=False),
      )
      self.features.apply(self.weights_init)
      self.register_buffer(
          "components", torch.ones(512, 128, dtype=torch.float)
      )
      self.register_buffer("mean", torch.zeros(512, dtype=torch.float))
  
      # use torch.hub to load pretrained model
      if pretrained:
          pretrained_dict = torch.hub.load_state_dict_from_url(
              urls["hardnet8v2"], map_location=map_location_to_cpu
          )
          self.load_state_dict(pretrained_dict, strict=True)
      self.eval()
  
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 1 to create a new HardNet8 object from inherited base classes: nn with example: obj = HardNet8(pretrained)