code: def build_pipeline_bert(
      num_layers, num_chunks, device=torch.device("cuda"), **kwargs
  ):
      logger = get_dist_logger()
      pipeline_size = gpc.get_world_size(ParallelMode.PIPELINE)
      pipeline_rank = gpc.get_local_rank(ParallelMode.PIPELINE)
      rank = gpc.get_global_rank()
      wrapper = PipelineSharedModuleWrapper([0, pipeline_size - 1])
      parts = partition_uniform(num_layers, pipeline_size, num_chunks)[
          pipeline_rank
      ]
      models = []
      for start, end in parts:
          kwargs["num_layers"] = num_layers
          kwargs["start_idx"] = start
          kwargs["end_idx"] = end
          kwargs["first_stage"] = start == 0
          kwargs["last_stage"] = end == num_layers
          logger.info(
              f"Rank{rank} build layer {start}-{end}, {end-start}/{num_layers} layers"
          )
          chunk = PipelineBertForPretrain(
              **_filter_kwargs(PipelineBertForPretrain.__init__, kwargs)
          ).to(device)
          if start == 0:
              wrapper.register_module(chunk.embedding.word_embeddings)
          elif end == num_layers:
              wrapper.register_module(chunk.word_embeddings)
          models.append(chunk)
      if len(models) == 1:
          model = models[0]
      else:
          model = nn.ModuleList(models)
      return model
  
imports: import inspect
  import torch
  import torch.nn
  from colossalai.kernel import LayerNorm
  from colossalai.legacy.context import ParallelMode
  from colossalai.legacy.context.parallel_mode import ParallelMode
  from colossalai.legacy.core import global_context
  from colossalai.legacy.nn.layer.wrapper import PipelineSharedModuleWrapper
  from colossalai.legacy.pipeline.utils import partition_uniform
  from colossalai.logging import get_dist_logger
  from .layers import BertDualHead, BertLayer, Embedding, PreProcessor, VocabEmbedding
  from .layers.init_method import init_normal, output_init_normal
label_desc: Use image node_id 2 for calling a global function with example usage: build_pipeline_bert(num_layers, num_chunks, device) and returns: model