class_docstr: Patch embedding block based on: "Liu et al.,
  Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
  <https://arxiv.org/abs/2103.14030>"
  https://github.com/microsoft/Swin-Transformer
  
  Unlike ViT patch embedding block: (1) input is padded to satisfy window size requirements (2) normalized if
  specified (3) position embedding is not used.
  
  Example::
  
      >>> from monai.networks.blocks import PatchEmbed
      >>> PatchEmbed(patch_size=2, in_chans=1, embed_dim=48, norm_layer=nn.LayerNorm, spatial_dims=3)
class_docstr_tok: ["Patch","embedding","block","based","on",":","``","Liu","et","al.",",","Swin","Transformer",":","Hierarchical","Vision","Transformer","using","Shifted","Windows","<","https",":","\/\/arxiv.org\/abs\/2103.14030",">","''","https",":","\/\/github.com\/microsoft\/Swin-Transformer","Unlike","ViT","patch","embedding","block",":","(","1",")","input","is","padded","to","satisfy","window","size","requirements","(","2",")","normalized","if","specified","(","3",")","position","embedding","is","not","used",".","Example",":",":",">",">",">","from","monai.networks.blocks","import","PatchEmbed",">",">",">","PatchEmbed","(","patch_size=2",",","in_chans=1",",","embed_dim=48",",","norm_layer=nn.LayerNorm",",","spatial_dims=3",")"]
code: def forward(self, x):
      x_shape = x.size()
      if len(x_shape) == 5:
          _, _, d, h, w = x_shape
          if w % self.patch_size[2] != 0:
              x = F.pad(
                  x, (0, self.patch_size[2] - w % self.patch_size[2])
              )
          if h % self.patch_size[1] != 0:
              x = F.pad(
                  x,
                  (
                      0,
                      0,
                      0,
                      self.patch_size[1] - h % self.patch_size[1],
                  ),
              )
          if d % self.patch_size[0] != 0:
              x = F.pad(
                  x,
                  (
                      0,
                      0,
                      0,
                      0,
                      0,
                      self.patch_size[0] - d % self.patch_size[0],
                  ),
              )
  
      elif len(x_shape) == 4:
          _, _, h, w = x_shape
          if w % self.patch_size[1] != 0:
              x = F.pad(
                  x, (0, self.patch_size[1] - w % self.patch_size[1])
              )
          if h % self.patch_size[0] != 0:
              x = F.pad(
                  x,
                  (
                      0,
                      0,
                      0,
                      self.patch_size[0] - h % self.patch_size[0],
                  ),
              )
  
      x = self.proj(x)
      if self.norm is not None:
          x_shape = x.size()
          x = x.flatten(2).transpose(1, 2)
          x = self.norm(x)
          if len(x_shape) == 5:
              d, wh, ww = x_shape[2], x_shape[3], x_shape[4]
              x = x.transpose(1, 2).view(-1, self.embed_dim, d, wh, ww)
          elif len(x_shape) == 4:
              wh, ww = x_shape[2], x_shape[3]
              x = x.transpose(1, 2).view(-1, self.embed_dim, wh, ww)
      return x
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.nn import LayerNorm
  from monai.networks.blocks.pos_embed_utils import build_sincos_position_embedding
  from monai.networks.layers import Conv, trunc_normal_
  from monai.utils import deprecated_arg, ensure_tuple_rep, optional_import
  from monai.utils.module import look_up_option
label_desc: Use image node_id 2 for calling the PatchEmbed obj's underlying member method code with example usage: obj.forward(x) and returns: x