code: def filter_dilated_rows(
      tensor: torch.Tensor,
      dilation: Tuple[int, int, int],
      dilated_kernel_size: Tuple[int, int, int],
      kernel_size: Tuple[int, int, int],
  ):
      """
      A helper function that removes extra rows created during the process of
      implementing dilation.
  
      Args:
          tensor: A tensor containing the output slices resulting from unfolding
                  the input tensor to `unfold3d()`.
                  Shape is ``(B, C, D_out, H_out, W_out, dilated_kernel_size[0],
                  dilated_kernel_size[1], dilated_kernel_size[2])``.
          dilation: The dilation given to `unfold3d()`.
          dilated_kernel_size: The size of the dilated kernel.
          kernel_size: The size of the kernel given to `unfold3d()`.
  
      Returns:
          A tensor of shape (B, C, D_out, H_out, W_out, kernel_size[0], kernel_size[1], kernel_size[2])
          For D_out, H_out, W_out definitions see :class:`torch.nn.Unfold`.
  
      Example:
          >>> tensor = torch.zeros([1, 1, 3, 3, 3, 5, 5, 5])
          >>> dilation = (2, 2, 2)
          >>> dilated_kernel_size = (5, 5, 5)
          >>> kernel_size = (3, 3, 3)
          >>> filter_dilated_rows(tensor, dilation, dilated_kernel_size, kernel_size).shape
          torch.Size([1, 1, 3, 3, 3, 3, 3, 3])
      """
  
      kernel_rank = len(kernel_size)
  
      indices_to_keep = [
          list(range(0, dilated_kernel_size[i], dilation[i]))
          for i in range(kernel_rank)
      ]
  
      tensor_np = tensor.numpy()
  
      axis_offset = len(tensor.shape) - kernel_rank
  
      for dim in range(kernel_rank):
          tensor_np = np.take(
              tensor_np, indices_to_keep[dim], axis=axis_offset + dim
          )
  
      return torch.Tensor(tensor_np)
  
file_path: opacus/opacus/utils/tensor_utils.py
imports: import math
  from typing import Iterator, List, Tuple, Union
  import numpy
  import torch
  import torch.nn.functional
label_desc: Use image node_id 6 for calling a global function with example usage: filter_dilated_rows(tensor, dilation, dilated_kernel_size, kernel_size) and returns: torch