code: def model_provider(
      pre_process=True,
      post_process=True,
      add_encoder=True,
      add_decoder=True,
  ) -> T5Model:
      """Builds the model.
  
      Args:
          pre_process (bool, optional): Set to true if you need to compute embedings. Defaults to True.
          post_process (bool, optional): Set to true if you need to want to compute output logits/loss. Defaults to True.
          add_encoder (bool, optional): Defaults to True
          add_decoder (bool, optional): Defaults to True
      Returns:
          T5Model: The returned T5 model
      """
  
      args = get_args()
      config = core_transformer_config_from_args(args)
      if args.use_mcore_models:
          if args.transformer_impl == "local":
              en_block_spec = get_t5_encoder_with_local_block_spec(
                  args.encoder_num_layers
              )
              de_block_spec = get_t5_decoder_with_local_block_spec(
                  args.decoder_num_layers
              )
          elif args.transformer_impl == "transformer_engine":
              en_block_spec = (
                  get_t5_encoder_with_transformer_engine_block_spec(
                      args.encoder_num_layers
                  )
              )
              de_block_spec = (
                  get_t5_decoder_with_transformer_engine_block_spec(
                      args.decoder_num_layers
                  )
              )
          print_rank_0("building T5 model ...")
          model = T5Model(
              config=config,
              transformer_encoder_layer_spec=en_block_spec,
              transformer_decoder_layer_spec=de_block_spec,
              vocab_size=args.padded_vocab_size,
              max_sequence_length=args.max_position_embeddings,
              pre_process=pre_process,
              post_process=post_process,
              fp16_lm_cross_entropy=args.fp16_lm_cross_entropy,
              parallel_output=True,
              share_embeddings_and_output_weights=not args.untie_embeddings_and_output_weights,
              position_embedding_type=args.position_embedding_type,
              rotary_percent=args.rotary_percent,
          )
      else:
          model = megatron.model.T5Model(
              config=config,
              num_tokentypes=0,
              parallel_output=True,
              pre_process=pre_process,
              post_process=post_process,
              add_encoder=add_encoder,
              add_decoder=add_decoder,
          )
      return model
  
file_path: megatron-lm/pretrain_t5.py
imports: from functools import partial
  import torch
  from torch import Tensor
  from megatron import get_args, get_timers, print_rank_0
  from megatron.core import tensor_parallel
  from megatron.core.enums import ModelType
  from megatron.data.dataset_utils import build_train_valid_test_datasets
  from megatron.core.models.T5 import T5Model
  from megatron.training import pretrain
  from megatron.utils import average_losses_across_data_parallel_group
  from megatron.arguments import core_transformer_config_from_args
  from megatron.core.transformer.spec_utils import import_module
  from megatron.core.models.T5.t5_spec import get_t5_encoder_with_transformer_engine_block_spec, get_t5_decoder_with_transformer_engine_block_spec, get_t5_encoder_with_local_block_spec, get_t5_decoder_with_local_block_spec
label_desc: Use image node_id 1 for calling a global function with example usage: model_provider(pre_process, post_process, add_encoder, add_decoder) and returns: model