code: def broadcast_variables(
      variables,
      root_rank,
      process_set=global_process_set,
      inplace=False,
  ):
      """
      Broadcasts variables from root rank to all other processes
      in a process set (defaults to all Horovod processes).
  
      Optionally, the broadcast may be performed in-place, which avoids
      temporary memory allocations and fragmentation. This is only
      supported with TensorFlow 2.6 or later. Reference variables
      (legacy support in TF 2) must all be of the same data type. There
      is no such restriction for resource variables (default in TF 2).
  
      Arguments:
          variables: variables for broadcast
          root_rank: rank of the process from which global variables will be broadcasted
                     to all other processes.
          process_set: Process set object to limit this operation to a subset of
                       Horovod processes. Default is the global process set.
          inplace: whether to perform in-place broadcasts
      """
      if inplace:
          vars_by_device = {}
          for var in variables:
              vars_by_device.setdefault(var.device, []).append(var)
  
          inplace_broadcast_group = _make_inplace_broadcast_group_fn()
          return inplace_broadcast_group(
              vars_by_device.values(), root_rank, process_set
          )
      else:
          broadcast_group = _make_broadcast_group_fn()
          return broadcast_group(variables, root_rank, process_set)
  
file_path: horovod/horovod/tensorflow/functions.py
imports: import io
  import cloudpickle
  import numpy
  import tensorflow
  from tensorflow.python.framework import ops
  from horovod.tensorflow.mpi_ops import allgather, broadcast, broadcast_
  from horovod.tensorflow.mpi_ops import rank, size
  from horovod.tensorflow.util import _cache, _executing_eagerly, _make_subgraph
  from horovod.common.process_sets import ProcessSet, global_process_set
label_desc: Use image node_id 3 for calling a global function with example usage: broadcast_variables(variables, root_rank, process_set, inplace) and returns: inplace_broadcast_group, broadcast_group