class_docstr: Apply non maxima suppression to filter.
class_docstr_tok: ["Apply","non","maxima","suppression","to","filter","."]
code: def forward(self, x: Tensor, mask_only: bool = False) -> Tensor:
      if len(x.shape) != 5:
          raise AssertionError(x.shape)
      # find local maximum values
      B, CH, D, H, W = x.size()
      if self.kernel_size == (3, 3, 3):
          mask = zeros(
              B, CH, D, H, W, device=x.device, dtype=torch.bool
          )
          center = slice(1, -1)
          left = slice(0, -2)
          right = slice(2, None)
          center_tensor = x[..., center, center, center]
          mask[..., 1:-1, 1:-1, 1:-1] = (
              (center_tensor > x[..., center, center, left])
              & (center_tensor > x[..., center, center, right])
              & (center_tensor > x[..., center, left, center])
              & (center_tensor > x[..., center, left, left])
              & (center_tensor > x[..., center, left, right])
              & (center_tensor > x[..., center, right, center])
              & (center_tensor > x[..., center, right, left])
              & (center_tensor > x[..., center, right, right])
              & (center_tensor > x[..., left, center, center])
              & (center_tensor > x[..., left, center, left])
              & (center_tensor > x[..., left, center, right])
              & (center_tensor > x[..., left, left, center])
              & (center_tensor > x[..., left, left, left])
              & (center_tensor > x[..., left, left, right])
              & (center_tensor > x[..., left, right, center])
              & (center_tensor > x[..., left, right, left])
              & (center_tensor > x[..., left, right, right])
              & (center_tensor > x[..., right, center, center])
              & (center_tensor > x[..., right, center, left])
              & (center_tensor > x[..., right, center, right])
              & (center_tensor > x[..., right, left, center])
              & (center_tensor > x[..., right, left, left])
              & (center_tensor > x[..., right, left, right])
              & (center_tensor > x[..., right, right, center])
              & (center_tensor > x[..., right, right, left])
              & (center_tensor > x[..., right, right, right])
          )
      else:
          max_non_center = (
              F.conv3d(
                  pad(x, list(self.padding)[::-1], mode="replicate"),
                  self.kernel.repeat(CH, 1, 1, 1, 1).to(
                      x.device, x.dtype
                  ),
                  stride=1,
                  groups=CH,
              )
              .view(B, CH, -1, D, H, W)
              .max(dim=2, keepdim=False)[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 NonMaximaSuppression3d obj's underlying member method code with example usage: obj.forward(x, mask_only) and returns: unknown, mask