class_docstr: Patch Merging Layer.
  Args:
      dim (int): Number of input channels.
      norm_layer (nn.Layer, optional): Normalization layer.  Default: nn.LayerNorm
docstr: Forward function.
  Args:
      x: Input feature, tensor size (B, H*W, C).
      H, W: Spatial resolution of the input feature.
docstr_tok: ["Forward","function",".","Args",":","x",":","Input","feature",",","tensor","size","(","B",",","H","*","W",",","C",")",".","H",",","W",":","Spatial","resolution","of","the","input","feature","."]
code: def forward(self, x, H, W):
      """Forward function.
      Args:
          x: Input feature, tensor size (B, H*W, C).
          H, W: Spatial resolution of the input feature.
      """
      B, L, C = x.shape
      assert L == H * W, "input feature has wrong size"
  
      x = x.reshape([-1, H, W, C])
  
      # padding
      pad_input = (H % 2 == 1) or (W % 2 == 1)
      if pad_input:
          # paddle F.pad default data_format is 'NCHW'
          x = F.pad(
              x, [0, 0, 0, H % 2, 0, W % 2, 0, 0], data_format="NHWC"
          )
          H += H % 2
          W += W % 2
  
      x0 = x[:, 0::2, 0::2, :]  # B H/2 W/2 C
      x1 = x[:, 1::2, 0::2, :]  # B H/2 W/2 C
      x2 = x[:, 0::2, 1::2, :]  # B H/2 W/2 C
      x3 = x[:, 1::2, 1::2, :]  # B H/2 W/2 C
      x = paddle.concat([x0, x1, x2, x3], -1)  # B H/2 W/2 4*C
      x = x.reshape([-1, H * W // 4, 4 * C])  # B H/2*W/2 4*C
  
      x = self.norm(x)
      x = self.reduction(x)
  
      return x
  
imports: import numpy
  import paddle
  import paddle.nn
  import paddle.nn.functional
  from ppdet.modeling.shape_spec import ShapeSpec
  from ppdet.core.workspace import register, serializable
  from .transformer_utils import DropPath, Identity
  from .transformer_utils import add_parameter, to_2tuple
  from .transformer_utils import ones_, zeros_, trunc_normal_
label_desc: Use image node_id 2 for calling the PatchMerging obj's underlying member method code with example usage: obj.forward(x, H, W) and returns: x