code: def broadcast(dtype, use_mpi=False):
      if dtype in "hH":
          return  # nccl does not support int16
  
      def run_broadcast(rank, root, dtype, use_mpi=False):
          dev = cuda.Device(rank)
          dev.use()
          comm = NCCLBackend(N_WORKERS, rank, use_mpi=use_mpi)
          expected = cupy.arange(2 * 3 * 4, dtype=dtype).reshape(
              (2, 3, 4)
          )
          if rank == root:
              in_array = expected
          else:
              in_array = cupy.zeros((2, 3, 4), dtype=dtype)
          comm.broadcast(in_array, root)
          testing.assert_allclose(in_array, expected)
  
      if use_mpi:
          from mpi4py import MPI
  
          # This process was run with mpiexec
          run_broadcast(MPI.COMM_WORLD.Get_rank(), 0, dtype, True)
          run_broadcast(MPI.COMM_WORLD.Get_rank(), 1, dtype, True)
      else:
          _launch_workers(run_broadcast, (0, dtype))
          _launch_workers(run_broadcast, (1, dtype))
  
imports: import sys
  import time
  import warnings
  import cupy
  from cupy import cuda
  from cupy.cuda import nccl
  from cupy import testing
  from cupyx.distributed import init_process_group
  from cupyx.distributed._nccl_comm import NCCLBackend
  from cupyx.distributed._store import ExceptionAwareProcess
  from cupyx.scipy import sparse
label_desc: Use image node_id 2 for calling a global function with example usage: broadcast(dtype, use_mpi) without return types