code: def extract_tensor_patches(
      input: Tensor,
      window_size: Union[int, Tuple[int, int]],
      stride: Union[int, Tuple[int, int]] = 1,
      padding: Union[int, Tuple[int, int]] = 0,
  ) -> Tensor:
      r"""Function that extract patches from tensors and stack them.
  
      See :class:`~kornia.contrib.ExtractTensorPatches` for details.
  
      Args:
          input: tensor image where to extract the patches with shape :math:`(B, C, H, W)`.
          window_size: the size of the sliding window and the output patch size.
          stride: stride of the sliding window.
          padding: Zero-padding added to both side of the input.
  
      Returns:
          the tensor with the extracted patches with shape :math:`(B, N, C, H_{out}, W_{out})`.
  
      Examples:
          >>> input = torch.arange(9.).view(1, 1, 3, 3)
          >>> patches = extract_tensor_patches(input, (2, 3))
          >>> input
          tensor([[[[0., 1., 2.],
                    [3., 4., 5.],
                    [6., 7., 8.]]]])
          >>> patches[:, -1]
          tensor([[[[3., 4., 5.],
                    [6., 7., 8.]]]])
      """
      if not torch.is_tensor(input):
          raise TypeError(
              f"Input input type is not a Tensor. Got {type(input)}"
          )
  
      if len(input.shape) != 4:
          raise ValueError(
              f"Invalid input shape, we expect BxCxHxW. Got: {input.shape}"
          )
  
      window_size = cast(Tuple[int, int], _pair(window_size))
      stride = cast(Tuple[int, int], _pair(stride))
  
      if (stride[0] > window_size[0]) | (stride[1] > window_size[1]):
          raise AssertionError(
              f"Stride={stride} should be less than or equal to Window size={window_size}"
          )
  
      if padding:
          padding = cast(Tuple[int, int], _pair(padding))
  
          if len(padding) != 2:
              raise AssertionError(
                  "Padding must be either an int or a tuple of two ints"
              )
  
          pad_vert = _pair(padding[0])
          pad_horz = _pair(padding[1])
          padding4 = cast(
              Tuple[int, int, int, int], pad_horz + pad_vert
          )
          input = pad(input, padding4)
  
      return _extract_tensor_patchesnd(input, window_size, stride)
  
file_path: kornia/kornia/contrib/extract_patches.py
imports: import math
  from typing import Optional, Tuple, Union, cast
  import torch
  import torch.nn.functional
  from torch.nn.modules.utils import _pair
  from kornia.core import Module, Tensor, pad
label_desc: Use image node_id 4 for calling a global function with example usage: extract_tensor_patches(input, window_size, stride, padding) and returns: _extract_tensor_patchesnd