class_docstr: Implementation of Metaformer block with RepMixer as token mixer.
  
  For more details on Metaformer structure, please refer to:
  `MetaFormer Is Actually What You Need for Vision <https://arxiv.org/pdf/2111.11418.pdf>`_
class_docstr_tok: ["Implementation","of","Metaformer","block","with","RepMixer","as","token","mixer",".","For","more","details","on","Metaformer","structure",",","please","refer","to",":","`","MetaFormer","Is","Actually","What","You","Need","for","Vision","<","https",":","\/\/arxiv.org\/pdf\/2111.11418.pdf",">","`","_"]
docstr: Build RepMixer Block.
  
  Args:
      dim: Number of embedding dimensions.
      kernel_size: Kernel size for repmixer. Default: 3
      mlp_ratio: MLP expansion ratio. Default: 4.0
      act_layer: Activation layer. Default: ``nn.GELU``
      drop: Dropout rate. Default: 0.0
      drop_path: Drop path rate. Default: 0.0
      use_layer_scale: Flag to turn on layer scale. Default: ``True``
      layer_scale_init_value: Layer scale value at initialization. Default: 1e-5
      inference_mode: Flag to instantiate block in inference mode. Default: ``False``
code: def __init__(
      self,
      dim: int,
      kernel_size: int = 3,
      mlp_ratio: float = 4.0,
      act_layer: nn.Module = nn.GELU,
      drop: float = 0.0,
      drop_path: float = 0.0,
      use_layer_scale: bool = True,
      layer_scale_init_value: float = 1e-5,
      inference_mode: bool = False,
  ):
      """Build RepMixer Block.
  
      Args:
          dim: Number of embedding dimensions.
          kernel_size: Kernel size for repmixer. Default: 3
          mlp_ratio: MLP expansion ratio. Default: 4.0
          act_layer: Activation layer. Default: ``nn.GELU``
          drop: Dropout rate. Default: 0.0
          drop_path: Drop path rate. Default: 0.0
          use_layer_scale: Flag to turn on layer scale. Default: ``True``
          layer_scale_init_value: Layer scale value at initialization. Default: 1e-5
          inference_mode: Flag to instantiate block in inference mode. Default: ``False``
      """
  
      super().__init__()
  
      self.token_mixer = RepMixer(
          dim,
          kernel_size=kernel_size,
          use_layer_scale=use_layer_scale,
          layer_scale_init_value=layer_scale_init_value,
          inference_mode=inference_mode,
      )
  
      assert (
          mlp_ratio > 0
      ), "MLP ratio should be greater than 0, found: {}".format(
          mlp_ratio
      )
      mlp_hidden_dim = int(dim * mlp_ratio)
      self.convffn = ConvFFN(
          in_channels=dim,
          hidden_channels=mlp_hidden_dim,
          act_layer=act_layer,
          drop=drop,
      )
  
      # Drop Path
      self.drop_path = (
          DropPath(drop_path) if drop_path > 0.0 else nn.Identity()
      )
  
      # Layer Scale
      self.use_layer_scale = use_layer_scale
      if use_layer_scale:
          self.layer_scale = nn.Parameter(
              layer_scale_init_value * torch.ones((dim, 1, 1)),
              requires_grad=True,
          )
  
imports: import os
  import copy
  from functools import partial
  from typing import List, Tuple, Optional, Union
  import torch
  import torch.nn
  from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
  from timm.models.layers import DropPath, trunc_normal_
  from timm.models.registry import register_model
  from models.modules.mobileone import MobileOneBlock
  from models.modules.replknet import ReparamLargeKernelConv
label_desc: Use image node_id 1 to create a new RepMixerBlock object from inherited base classes: nn with example: obj = RepMixerBlock(dim, kernel_size, mlp_ratio, act_layer, drop, drop_path, use_layer_scale, layer_scale_init_value, inference_mode)