parameters: (block,
                                 insert_idx,
                                 ring_id,
                                 params,
                                 shard,
                                 op_role=OpRole.Optimize,
                                 use_calc_stream=False,
                                 rank=None,
                                 strategy=None)
return_statement: return param_in_this_device
docstring: add broadcast param ops
docstring_summary: add broadcast param ops
docstring_tokens: add broadcast param ops
function: def insert_broadcast_param_ops(block,
                                 insert_idx,
                                 ring_id,
                                 params,
                                 shard,
                                 op_role=OpRole.Optimize,
                                 use_calc_stream=False,
                                 rank=None,
                                 strategy=None):
      """
      add broadcast param ops
      """
      if strategy and strategy.fuse_all_reduce_ops:
          # TODO(wangxi): put fused var in startup_program, only need exec once
          return insert_fused_broadcast_param_ops(
              block, insert_idx, ring_id, params, shard, op_role, use_calc_stream,
              rank, strategy.fuse_grad_size_in_MB)
  
      param_in_this_device = []
      for param in params:
          root_id = shard.device(param)
          assert root_id >= 0, "root id should be a positive int, but now root id is {}".format(
              root_id)
          if rank is not None and rank == root_id:
              param_in_this_device.append(param)
          block._insert_op_without_sync(
              insert_idx,
              type='c_broadcast',
              inputs={'X': param},
              outputs={'Out': param},
              attrs={
                  'ring_id': ring_id,
                  'root': root_id,
                  'use_calc_stream': use_calc_stream,
                  OP_ROLE_KEY: op_role
              })
  
      return param_in_this_device
function_tokens: def insert_broadcast_param_ops ( block , insert_idx , ring_id , params , shard , op_role = OpRole . Optimize , use_calc_stream = False , rank = None , strategy = None ) : if strategy and strategy . fuse_all_reduce_ops : # TODO(wangxi): put fused var in startup_program, only need exec once return insert_fused_broadcast_param_ops ( block , insert_idx , ring_id , params , shard , op_role , use_calc_stream , rank , strategy . fuse_grad_size_in_MB ) param_in_this_device = [ ] for param in params : root_id = shard . device ( param ) assert root_id >= 0 , "root id should be a positive int, but now root id is {}" . format ( root_id ) if rank is not None and rank == root_id : param_in_this_device . append ( param ) block . _insert_op_without_sync ( insert_idx , type = 'c_broadcast' , inputs = { 'X' : param } , outputs = { 'Out' : param } , attrs = { 'ring_id' : ring_id , 'root' : root_id , 'use_calc_stream' : use_calc_stream , OP_ROLE_KEY : op_role } ) return param_in_this_device