code: def broadcast_parameters(params, root_rank):
      """
      Broadcasts the parameters from root rank to all other processes.
      Typical usage is to broadcast the ``model.state_dict()``,
      ``model.named_parameters()``, or ``model.parameters()``.
  
      Arguments:
          params: One of the following:
              - list of parameters to broadcast
              - dict of parameters to broadcast
          root_rank: The rank of the process from which parameters will be
                     broadcasted to all other processes.
      """
      if isinstance(params, dict):
          params = sorted(params.items())
      elif isinstance(params, list):
          # support both named_parameters() and regular parameters()
          params = [
              p if isinstance(p, tuple) else (None, p) for p in params
          ]
      else:
          raise ValueError("invalid params of type: %s" % type(params))
  
      # Run asynchronous broadcasts.
      handles = []
      for name, p in params:
          handle = bf.broadcast_nonblocking_(p, root_rank, name)
          handles.append(handle)
  
      # Wait for completion.
      for handle in handles:
          bf.synchronize(handle)
  
file_path: bluefog/bluefog/torch/utility.py
imports: from typing import Any, List, Optional
  from functools import wraps
  import collections
  import numpy
  import torch
  import bluefog.torch
label_desc: Use image node_id 1 for calling a global function with example usage: broadcast_parameters(params, root_rank) without return types