class_docstr: Apply non maxima suppression to filter.
  
  Flag `minima_are_also_good` is useful, when you want to detect both maxima and minima, e.g. for DoG
class_docstr_tok: ["Apply","non","maxima","suppression","to","filter",".","Flag","`","minima_are_also_good","`","is","useful",",","when","you","want","to","detect","both","maxima","and","minima",",","e.g",".","for","DoG"]
code: def forward(self, x: Tensor, mask_only: bool = False) -> Tensor:
      if len(x.shape) != 4:
          raise AssertionError(x.shape)
      B, CH, H, W = x.size()
      # find local maximum values
      x_padded = pad(x, list(self.padding)[::-1], mode="replicate")
      B, CH, HP, WP = x_padded.size()
  
      neighborhood = F.conv2d(
          x_padded.view(B * CH, 1, HP, WP),
          self.kernel.to(x.device, x.dtype),
          stride=1,
      ).view(B, CH, -1, H, W)
      max_non_center = neighborhood.max(dim=2)[0]
      mask = x > max_non_center
      if mask_only:
          return mask
      return x * (mask.to(x.dtype))
  
file_path: kornia/kornia/geometry/subpix/nms.py
imports: from __future__ import annotations
  import torch
  import torch.nn.functional
  from kornia.core import Module, Tensor, eye, pad, zeros
label_desc: Use image node_id 3 for calling the NonMaximaSuppression2d obj's underlying member method code with example usage: obj.forward(x, mask_only) and returns: unknown, mask