class_docstr: Transformer blocks with support of window attention and residual propagation blocks
class_docstr_tok: ["Transformer","blocks","with","support","of","window","attention","and","residual","propagation","blocks"]
code: def forward(self, x: paddle.Tensor) -> paddle.Tensor:
      shortcut = x
      x = self.norm1(x)
      # Window partition
      if self.window_size > 0:
          H, W = x.shape[1], x.shape[2]
          x, pad_hw = window_partition(x, self.window_size)
  
      x = self.attn(x)
      # Reverse window partition
      if self.window_size > 0:
          x = window_unpartition(x, self.window_size, pad_hw, (H, W))
  
      x = shortcut + x
      x = x + self.mlp(self.norm2(x))
  
      return x
  
imports: import sys
  import os
  from functools import partial
  from typing import Optional, Tuple, Type
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from .common import LayerNorm2d, MLPBlock
label_desc: Use image node_id 2 for calling the Block obj's underlying member method code with example usage: obj.forward(x) and returns: x