docstr: Unpatch a patched object.
  
  This method only applies when stride and patch_size are the same.
  
  Args:
      x_patched: patched object or a tuple (tensor, (patches_h, patches_w))
      crop: crop the height and width of the ptches
      channels_last: are the channels in the last dimension? Defaults to False
  
  Returns:
      Tensor of shape [B, C, H, W]
docstr_tok: ["Unpatch","a","patched","object",".","This","method","only","applies","when","stride","and","patch_size","are","the","same",".","Args",":","x_patched",":","patched","object","or","a","tuple","(","tensor",",","(","patches_h",",","patches_w",")",")","crop",":","crop","the","height","and","width","of","the","ptches","channels_last",":","are","the","channels","in","the","last","dimension","?","Defaults","to","False","Returns",":","Tensor","of","shape","[","B",",","C",",","H",",","W","]"]
code: def unpatch(
      self,
      x_patched: Union[Patched, Tuple[Tensor, Tuple[int, int]]],
      crop: Optional[Tuple[int, int]] = None,
      channels_last: bool = False,
  ) -> Tensor:
      """Unpatch a patched object.
  
      This method only applies when stride and patch_size are the same.
  
      Args:
          x_patched: patched object or a tuple (tensor, (patches_h, patches_w))
          crop: crop the height and width of the ptches
          channels_last: are the channels in the last dimension? Defaults to False
  
      Returns:
          Tensor of shape [B, C, H, W]
      """
      x, (n_patches_H, n_patches_W) = x_patched
  
      if not channels_last:
          x = x.permute(0, 2, 1).contiguous()
  
      _, seq_len, C = x.shape
  
      # Can only unpatch objects where stride == patch_size
      assert (
          seq_len == self.stride**2
      ), "Length mismatch. Potential reason: unpatch can only handle patch_size=stride"
      x = (
          x.reshape(
              -1, n_patches_H, n_patches_W, self.stride, self.stride, C
          )
          .permute(0, 5, 1, 3, 2, 4)
          .contiguous()
          .reshape(
              -1,
              C,
              n_patches_H * self.stride,
              n_patches_W * self.stride,
          )
      )
  
      return x[..., : crop[0], : crop[1]] if crop is not None else x
  
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 7 for calling the Patcher obj's underlying member method code with example usage: obj.unpatch(x_patched, crop, channels_last) and returns: unknown