class_docstr: Patch merging layer based on: "Liu et al.,
  Swin Transformer: Hierarchical Vision Transformer using Shifted Windows
  <https://arxiv.org/abs/2103.14030>"
  https://github.com/microsoft/Swin-Transformer
docstr: Args:
      dim: number of feature channels.
      norm_layer: normalization layer.
      spatial_dims: number of spatial dims.
docstr_tok: ["Args",":","dim",":","number","of","feature","channels",".","norm_layer",":","normalization","layer",".","spatial_dims",":","number","of","spatial","dims","."]
code: def __init__(
      self,
      dim: int,
      norm_layer: type[LayerNorm] = nn.LayerNorm,
      spatial_dims: int = 3,
  ) -> None:
      """
      Args:
          dim: number of feature channels.
          norm_layer: normalization layer.
          spatial_dims: number of spatial dims.
      """
  
      super().__init__()
      self.dim = dim
      if spatial_dims == 3:
          self.reduction = nn.Linear(8 * dim, 2 * dim, bias=False)
          self.norm = norm_layer(8 * dim)
      elif spatial_dims == 2:
          self.reduction = nn.Linear(4 * dim, 2 * dim, bias=False)
          self.norm = norm_layer(4 * dim)
  
imports: from __future__ import annotations
  import itertools
  from collections.abc import Sequence
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  import torch.utils.checkpoint
  from torch.nn import LayerNorm
  from typing_extensions import Final
  from monai.networks.blocks import MLPBlock
  from monai.networks.blocks import PatchEmbed, UnetOutBlock, UnetrBasicBlock, UnetrUpBlock
  from monai.networks.layers import DropPath, trunc_normal_
  from monai.utils import ensure_tuple_rep, look_up_option, optional_import
  from monai.utils.deprecate_utils import deprecated_arg
label_desc: Use image node_id 1 to create a new PatchMergingV2 object from inherited base classes: nn with example: obj = PatchMergingV2(dim, norm_layer, spatial_dims)