code: def create_mlp_cls(config, layer_idx=None, return_residual=False):
      inner_dim = config.intermediate_size
      fused_mlp = getattr(config, "fused_mlp", False)
      if fused_mlp:
          assert config.hidden_act in [
              "gelu_new",
              "gelu_fast",
              "gelu_pytorch_tanh",
          ], (
              "fused_mlp only " "supports approximate gelu"
          )
      if not fused_mlp:
          approximate = (
              "tanh"
              if config.hidden_act
              in ["gelu_new", "gelu_fast", "gelu_pytorch_tanh"]
              else "none"
          )
          mlp_cls = partial(
              Mlp,
              hidden_features=inner_dim,
              activation=partial(F.gelu, approximate=approximate),
              return_residual=return_residual,
          )
      else:
          if FusedMLP is None:
              raise ImportError("fused_dense is not installed")
          mlp_checkpoint_lvl = getattr(config, "mlp_checkpoint_lvl", 0)
          # mlp_checkpoint_lvl could be a list, which contains the checkpoint_lvl for each layer
          if isinstance(mlp_checkpoint_lvl, Sequence):
              assert layer_idx is not None
              mlp_checkpoint_lvl = mlp_checkpoint_lvl[layer_idx]
          mlp_cls = partial(
              FusedMLP,
              hidden_features=inner_dim,
              checkpoint_lvl=mlp_checkpoint_lvl,
              return_residual=return_residual,
          )
      return mlp_cls
  
imports: import logging
  import re
  from collections import OrderedDict
  from collections.abc import Sequence
  from functools import partial
  from typing import Any, Mapping
  import torch
  import torch.nn
  import torch.nn.functional
  from einops import rearrange
  from transformers import BertConfig, PretrainedConfig
  from transformers.models.bert.modeling_bert import BaseModelOutputWithPoolingAndCrossAttentions, BertForPreTrainingOutput
  from flash_attn.bert_padding import index_first_axis, index_first_axis_residual, pad_input, unpad_input
  from flash_attn.modules.block import Block
  from flash_attn.modules.embedding import BertEmbeddings
  from flash_attn.modules.mha import MHA
  from flash_attn.modules.mlp import FusedMLP, Mlp
  from flash_attn.utils.pretrained import state_dict_from_pretrained
label_desc: Use image node_id 2 for calling a global function with example usage: create_mlp_cls(config, layer_idx, return_residual) and returns: mlp_cls