class_docstr: Patch Merging Layer.
  Args:
      dim (int): Number of input channels.
      norm_layer (str): Normalization layer name.
      strided (Optional[bool]): Down-sample the input by a factor of 2. Default is True.
class_docstr_tok: ["Patch","Merging","Layer",".","Args",":","dim","(","int",")",":","Number","of","input","channels",".","norm_layer","(","str",")",":","Normalization","layer","name",".","strided","(","Optional","[","bool","]",")",":","Down-sample","the","input","by","a","factor","of","2",".","Default","is","True","."]
docstr: Args:
      x (Tensor): input tensor with expected layout of [..., H, W, C]
  Returns:
      Tensor with layout of [..., H/2, W/2, 2*C]
docstr_tok: ["Args",":","x","(","Tensor",")",":","input","tensor","with","expected","layout","of","[","...",",","H",",","W",",","C","]","Returns",":","Tensor","with","layout","of","[","...",",","H\/2",",","W\/2",",","2","*","C","]"]
code: def forward(self, x: Tensor, *args, **kwargs) -> Tensor:
      """
      Args:
          x (Tensor): input tensor with expected layout of [..., H, W, C]
      Returns:
          Tensor with layout of [..., H/2, W/2, 2*C]
      """
      x = _patch_merging_pad(x)
  
      if self.strided:
          x0 = x[..., 0::2, 0::2, :]  # ... H/s W/s C
          x1 = x[..., 1::2, 0::2, :]  # ... H/s W/s C
          x2 = x[..., 0::2, 1::2, :]  # ... H/s W/s C
          x3 = x[..., 1::2, 1::2, :]  # ... H/s W/s C
          x = torch.cat([x0, x1, x2, x3], -1)  # ... H/s W/s 4*C
      else:
          x = torch.cat([x, x, x, x], -1)  # H W 4*C
  
      x = self.norm(x)
      x = self.reduction(x)  # ... H/2 W/2 2*C
      return x
  
imports: from typing import List, Optional
  import torch
  from torch import Tensor, nn
  from torch.nn import functional
  from cvnets.layers import Dropout, LinearLayer, StochasticDepth, get_normalization_layer
  from cvnets.layers.activation import build_activation_layer
  from cvnets.modules import BaseModule
label_desc: Use image node_id 2 for calling the PatchMerging obj's underlying member method code with example usage: obj.forward(x) and returns: x