class_docstr: Basic Swin Transformer layer in one stage 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
code: def forward(self, x):
      x_shape = x.size()
      if len(x_shape) == 5:
          b, c, d, h, w = x_shape
          window_size, shift_size = get_window_size(
              (d, h, w), self.window_size, self.shift_size
          )
          x = rearrange(x, "b c d h w -> b d h w c")
          dp = int(np.ceil(d / window_size[0])) * window_size[0]
          hp = int(np.ceil(h / window_size[1])) * window_size[1]
          wp = int(np.ceil(w / window_size[2])) * window_size[2]
          attn_mask = compute_mask(
              [dp, hp, wp], window_size, shift_size, x.device
          )
          for blk in self.blocks:
              x = blk(x, attn_mask)
          x = x.view(b, d, h, w, -1)
          if self.downsample is not None:
              x = self.downsample(x)
          x = rearrange(x, "b d h w c -> b c d h w")
  
      elif len(x_shape) == 4:
          b, c, h, w = x_shape
          window_size, shift_size = get_window_size(
              (h, w), self.window_size, self.shift_size
          )
          x = rearrange(x, "b c h w -> b h w c")
          hp = int(np.ceil(h / window_size[0])) * window_size[0]
          wp = int(np.ceil(w / window_size[1])) * window_size[1]
          attn_mask = compute_mask(
              [hp, wp], window_size, shift_size, x.device
          )
          for blk in self.blocks:
              x = blk(x, attn_mask)
          x = x.view(b, h, w, -1)
          if self.downsample is not None:
              x = self.downsample(x)
          x = rearrange(x, "b h w c -> b c h w")
      return x
  
imports: from __future__ import annotations
  import itertools
  from collections.abc import Sequence
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from torch.nn import LayerNorm
  from typing_extensions import Final
  from monai.networks.blocks import MLPBlock
  from monai.networks.blocks import PatchEmbed, UnetOutBlock, UnetrBasicBlock, UnetrUpBlock
  from monai.networks.layers import DropPath, trunc_normal_
  from monai.utils import ensure_tuple_rep, look_up_option, optional_import
  from monai.utils.deprecate_utils import deprecated_arg
label_desc: Use image node_id 2 for calling the BasicLayer obj's underlying member method code with example usage: obj.forward(x) and returns: x