code: def patch_model_provider(
      model_provider, gate=None, Megatron_Version="v2.2"
  ):
      from megatron import get_args
  
      def fmoefied_model_provider_v2_2():
          from .layers import fmoefy
  
          args = get_args()
          hhs = args.hidden_size * 4
          assert hhs % args.top_k == 0
          hhs = hhs // args.top_k
          assert hhs % args.tensor_model_parallel_size == 0
          hhs = hhs // args.tensor_model_parallel_size
          return fmoefy(
              model_provider(),
              fmoe_num_experts=args.fmoe_num_experts,
              hidden_hidden_size=hhs,
              top_k=args.top_k,
              gate=gate,
              megatron_version="v2.2",
          )
  
      def fmoefied_model_provider_v2_5(pre_process, post_process):
          from .layers import fmoefy
  
          args = get_args()
          hhs = args.hidden_size * 4
          assert hhs % args.top_k == 0
          hhs = hhs // args.top_k
          assert hhs % args.tensor_model_parallel_size == 0
          hhs = hhs // args.tensor_model_parallel_size
          return fmoefy(
              model_provider(
                  pre_process=pre_process, post_process=post_process
              ),
              fmoe_num_experts=args.fmoe_num_experts,
              hidden_hidden_size=hhs,
              top_k=args.top_k,
              gate=gate,
              megatron_version="v2.5",
          )
  
      def fmoefied_model_provider_v3_0_2(pre_process, post_process):
          from .layers import fmoefy
  
          args = get_args()
          hhs = args.hidden_size * 4
          assert hhs % args.top_k == 0
          hhs = hhs // args.top_k
          assert hhs % args.tensor_model_parallel_size == 0
          hhs = hhs // args.tensor_model_parallel_size
          return fmoefy(
              model_provider(
                  pre_process=pre_process, post_process=post_process
              ),
              fmoe_num_experts=args.fmoe_num_experts,
              hidden_hidden_size=hhs,
              top_k=args.top_k,
              gate=gate,
              megatron_version="v3.0.2",
          )
  
      if Megatron_Version == "v2.2":
          return fmoefied_model_provider_v2_2
      elif Megatron_Version == "v2.5":
          return fmoefied_model_provider_v2_5
      elif Megatron_Version == "v3.0.2":
          return fmoefied_model_provider_v3_0_2
      else:
          assert False, f"Megatron Version {Megatron_Version} unknown."
  
label_desc: Use image node_id 3 for calling a global function with example usage: patch_model_provider(model_provider, gate, Megatron_Version) and returns: fmoefy, fmoefy, fmoefy, fmoefied_model_provider_v2_2, fmoefied_model_provider_v2_5, fmoefied_model_provider_v3_0_2