code: def build_MLP(input_dim, hidden_dim, output_dim, num_layers):
      assert (
          num_layers > 1
      ), f"num_layers should be greater than 1 but got {num_layers}"
      h = [hidden_dim] * (num_layers - 1)
      layers = list()
      for n, k in zip([input_dim] + h[:-1], h):
          layers.extend((nn.Linear(n, k), nn.ReLU()))
      # Note that the relu func of MLP in original DETR repo is set
      # 'inplace=False', however the ReLU cfg of FFN in mmdet is set
      # 'inplace=True' by default.
      layers.append(nn.Linear(hidden_dim, output_dim))
      return nn.Sequential(*layers)
  
imports: import math
  import warnings
  import torch
  import torch.nn
  from mmcv.cnn import build_norm_layer
  from mmcv.cnn.bricks.transformer import BaseTransformerLayer, TransformerLayerSequence, build_transformer_layer_sequence
  from mmcv.ops import MultiScaleDeformableAttention
  from mmengine.model import BaseModule
  from mmengine.model.weight_init import xavier_init
  from torch.nn.init import normal_
  from mmdet.models.layers.transformer import inverse_sigmoid
  from mmdet.registry import MODELS
label_desc: Use image node_id 1 for calling a global function with example usage: build_MLP(input_dim, hidden_dim, output_dim, num_layers) and returns: nn