code: def create_master_params_grads(
      params_grads, main_prog, startup_prog, loss_scaling
  ):
      master_params_grads = []
      for p, g in params_grads:
          with main_prog._optimized_guard([p, g]):
              # create master parameters
              master_param = copy_to_master_param(
                  p, main_prog.global_block()
              )
              startup_master_param = (
                  startup_prog.global_block()._clone_variable(
                      master_param
                  )
              )
              startup_p = startup_prog.global_block().var(p.name)
              append_cast_op(
                  startup_p, startup_master_param, startup_prog
              )
              # cast fp16 gradients to fp32 before apply gradients
              if g.name.find("layer_norm") > -1:
                  scaled_g = g / loss_scaling
                  master_params_grads.append([p, scaled_g])
                  continue
              master_grad = fluid.layers.cast(g, "float32")
              master_grad = master_grad / loss_scaling
              master_params_grads.append([master_param, master_grad])
  
      return master_params_grads
  
file_path: PGL/ogb_examples/linkproppred/ogbl-ppa/utils/fp16.py
imports: from __future__ import print_function
  import paddle
  import paddle.fluid
label_desc: Use image node_id 4 for calling a global function with example usage: create_master_params_grads(params_grads, main_prog, startup_prog, loss_scaling) and returns: master_params_grads