code: def broadcast_dict(vals: dict):
      if not is_distributed():
          return vals
  
      if is_main_process():
          data_byte = pickle.dumps(vals)
          data_tensor = torch.ByteTensor(list(data_byte)).to("cuda")
          data_size = torch.IntTensor([len(data_byte)]).to("cuda")
      else:
          data_tensor = torch.empty(
              [1024], dtype=torch.uint8, device="cuda"
          )
          data_size = torch.IntTensor([0]).to("cuda")
  
      dist.broadcast(data_size, 0)
      if not is_main_process():
          # resize
          data_tensor = data_tensor.new_empty([data_size.item()])
  
      dist.broadcast(data_tensor, 0)
  
      if not is_main_process():
          data_list = data_tensor.cpu().tolist()
          data_byte = bytes(data_list[: data_size.item()])
          vals = pickle.loads(data_byte)  # nosec
  
      return vals
  
file_path: axolotl/src/axolotl/utils/distributed.py
imports: import os
  import pickle
  from contextlib import contextmanager
  import torch
  import torch.distributed
  from accelerate import Accelerator
label_desc: Use image node_id 9 for calling a global function with example usage: broadcast_dict(vals) and returns: vals, vals