    def forward(self, x):
        """
        Forward function.

        Args:
            x (`torch.Tensor`):
                Input feature, tensor size (b, c, d, h, w).
        """
        # calculate attention mask for SW-MSA
        b, _, d, h, w = x.shape
        window_size, shift_size = \
            get_window_size((d, h, w), self.window_size, self.shift_size)  # pylint: disable=unbalanced-tuple-unpacking
        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')
        return x
Forward function.

Args:
x (`torch.Tensor`):
Input feature, tensor size (b, c, d, h, w).
towhee/models/video_swin_transformer/video_swin_transformer_block.py