code: def __init__(
      self,
      input_resolution: int | tuple[int, int],
      dim: int,
      out_dim: int,
      stride: int,
      activation: type[Module] = nn.GELU,
  ) -> None:
      KORNIA_CHECK(stride in (1, 2), "stride must be either 1 or 2")
      super().__init__()
      self.input_resolution = _make_pair(input_resolution)
      self.conv1 = ConvBN(dim, out_dim, 1, activation=activation)
      self.conv2 = ConvBN(
          out_dim,
          out_dim,
          3,
          stride,
          1,
          groups=out_dim,
          activation=activation,
      )
      self.conv3 = ConvBN(out_dim, out_dim, 1)
  
imports: from __future__ import annotations
  import itertools
  import warnings
  from typing import Any, Optional
  import torch
  import torch.nn.functional
  from torch import nn
  from torch.utils import checkpoint
  from kornia.contrib.models.common import DropPath, LayerNorm2d, window_partition, window_unpartition
  from kornia.core import Module, Tensor
  from kornia.core.check import KORNIA_CHECK
label_desc: Use image node_id 1 to create a new PatchMerging object from inherited base classes: Module with example: obj = PatchMerging(input_resolution, dim, out_dim, stride, activation)