docstr: Pad and extract patches
  
  Args:
      x: tensor of shape [B, C, H, W]
      patch_size: patch size
  
  Returns:
      Patched object with two attributes:
          - `tensor` of shape [B*num_patches_H*num_patches_W, patch_size^2, C]
          - `num_patches` a tuple of ints (num_patches_W, num_patches_W) -- number
              of patches in the height and width dimensions
docstr_tok: ["Pad","and","extract","patches","Args",":","x",":","tensor","of","shape","[","B",",","C",",","H",",","W","]","patch_size",":","patch","size","Returns",":","Patched","object","with","two","attributes",":","-","`","tensor","`","of","shape","[","B","*","num_patches_H","*","num_patches_W",",","patch_size^2",",","C","]","-","`","num_patches","`","a","tuple","of","ints","(","num_patches_W",",","num_patches_W",")","--","number","of","patches","in","the","height","and","width","dimensions"]
code: def forward(self, x: Tensor, patch_size: int) -> Patched:
      """Pad and extract patches
  
      Args:
          x: tensor of shape [B, C, H, W]
          patch_size: patch size
  
      Returns:
          Patched object with two attributes:
              - `tensor` of shape [B*num_patches_H*num_patches_W, patch_size^2, C]
              - `num_patches` a tuple of ints (num_patches_W, num_patches_W) -- number
                  of patches in the height and width dimensions
      """
      x_padded, num_patches_H, num_patches_W = self._pad(x, patch_size)
      patches = (
          self._window_partition(x_padded, patch_size)
          if patch_size == self.stride
          else self._window_partition_conv2d(x_padded, patch_size)
      )  # [B*num_patches_H*num_patches_W, patch_size^2, C]
  
      return Patched(patches, (num_patches_H, num_patches_W))
  
file_path: NeuralCompression/projects/torch_vct/neural/patcher.py
imports: import math
  from typing import NamedTuple, Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import Tensor
label_desc: Use image node_id 6 for calling the Patcher obj's underlying member method code with example usage: obj.forward(x, patch_size) and returns: Patched