class_docstr: Patch Merging Layer.
      
class_docstr_tok: ["Patch","Merging","Layer","."]
docstr: Args:
      dim: Number of input channels.
      out_dim: Number of output channels (or 2 * dim if None)
      norm_layer: Normalization layer.
docstr_tok: ["Args",":","dim",":","Number","of","input","channels",".","out_dim",":","Number","of","output","channels","(","or","2","*","dim","if","None",")","norm_layer",":","Normalization","layer","."]
code: def __init__(
      self,
      dim: int,
      out_dim: Optional[int] = None,
      norm_layer: Callable = nn.LayerNorm,
  ):
      """
      Args:
          dim: Number of input channels.
          out_dim: Number of output channels (or 2 * dim if None)
          norm_layer: Normalization layer.
      """
      super().__init__()
      self.dim = dim
      self.out_dim = out_dim or 2 * dim
      self.norm = norm_layer(4 * dim)
      self.reduction = nn.Linear(4 * dim, self.out_dim, bias=False)
  
imports: import logging
  import math
  from typing import Callable, List, Optional, Tuple, Union
  import torch
  import torch.nn
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.layers import PatchEmbed, Mlp, DropPath, ClassifierHead, to_2tuple, to_ntuple, trunc_normal_, _assert, use_fused_attn, resize_rel_pos_bias_table, resample_patch_embed
  from ._builder import build_model_with_cfg
  from ._features_fx import register_notrace_function
  from ._manipulate import checkpoint_seq, named_apply
  from ._registry import generate_default_cfgs, register_model, register_model_deprecations
  from .vision_transformer import get_init_weights_vit
label_desc: Use image node_id 1 to create a new PatchMerging object from inherited base classes: nn with example: obj = PatchMerging(dim, out_dim, norm_layer)