class_docstr: 3D Swin Transformer Block.
  
  Args:
      dim (`int`):
          Number of input channels.
      num_heads (`int`):
          Number of attention heads.
      window_size (`tuple[int]`):
          Window size.
      shift_size (`tuple[int]`):
          Shift size for SW-MSA.
      mlp_ratio (`float`):
          Ratio of mlp hidden dim to embedding dim.
      qkv_bias (`bool`):
          If True, add a learnable bias to query, key, value. Default: True
      qk_scale (`float`):
          Override default qk scale of head_dim ** -0.5 if set.
      drop (`float`):
          Dropout rate. Default: 0.0
      attn_drop (`float`):
          Attention dropout rate. Default: 0.0
      drop_path(`float`):
          Stochastic depth rate. Default: 0.0
      act_layer (`nn.Module`):
          Activation layer. Default: nn.GELU
      norm_layer (`nn.Module`):
          Normalization layer.  Default: nn.LayerNorm
code: def forward_part1(self, x, mask_matrix):
      b, d, h, w, c = x.shape
      window_size, shift_size = get_window_size(
          (d, h, w), self.window_size, self.shift_size
      )  # pylint: disable=unbalanced-tuple-unpacking
  
      x = self.norm1(x)
      # pad feature maps to multiples of window size
      pad_l = pad_t = pad_d0 = 0
      pad_d1 = (window_size[0] - d % window_size[0]) % window_size[0]
      pad_b = (window_size[1] - h % window_size[1]) % window_size[1]
      pad_r = (window_size[2] - w % window_size[2]) % window_size[2]
      x = F.pad(x, (0, 0, pad_l, pad_r, pad_t, pad_b, pad_d0, pad_d1))
      _, dp, hp, wp, _ = x.shape
      # cyclic shift
      if any(i > 0 for i in shift_size):
          shifted_x = torch.roll(
              x,
              shifts=(-shift_size[0], -shift_size[1], -shift_size[2]),
              dims=(1, 2, 3),
          )
          attn_mask = mask_matrix
      else:
          shifted_x = x
          attn_mask = None
      # partition windows
      x_windows = window_partition(
          shifted_x, window_size
      )  # b*nW, Wd*Wh*Ww, c
      # W-MSA/SW-MSA
      attn_windows = self.attn(
          x_windows, mask=attn_mask
      )  # b*nW, Wd*Wh*Ww, c
      # merge windows
      attn_windows = attn_windows.view(-1, *(window_size + (c,)))
      shifted_x = window_reverse(
          attn_windows, window_size, b, dp, hp, wp
      )  # b d' h' w' c
      # reverse cyclic shift
      if any(i > 0 for i in shift_size):
          x = torch.roll(
              shifted_x,
              shifts=(shift_size[0], shift_size[1], shift_size[2]),
              dims=(1, 2, 3),
          )
      else:
          x = shifted_x
  
      if pad_d1 > 0 or pad_r > 0 or pad_b > 0:
          x = x[:, :d, :h, :w, :].contiguous()
      return x
  
file_path: towhee/towhee/models/layers/swin_transformer_block3d.py
imports: import torch
  from torch import nn
  from torch.utils import checkpoint
  import torch.nn.functional
  from towhee.models.layers.window_attention3d import WindowAttention3D
  from towhee.models.utils.window_partition3d import window_partition
  from towhee.models.utils.window_reverse3d import window_reverse
  from towhee.models.layers.mlp import Mlp
  from towhee.models.utils.get_window_size import get_window_size
  from towhee.models.layers.droppath import DropPath
label_desc: Use image node_id 2 for calling the SwinTransformerBlock3D obj's underlying member method code with example usage: obj.forward_part1(x, mask_matrix) and returns: x