code: def test_broadcast_object(self):
      world_size = 3
      for use_disk, obj in product(
          [True, False], self._get_test_objects()
      ):
          filename = tempfile.NamedTemporaryFile(delete=True).name
          inputs = [None] * world_size
          inputs[0] = obj  # only the primary worker has the object
  
          calls = [
              {
                  "world_size": world_size,
                  "function": broadcast_object,
                  "inputs": [i, _PRIMARY_RANK, use_disk],
              }
              for i in inputs
          ]
          results = run_in_process_group(filename, calls)
  
          # check that all replicas got identical objects
          self.assertEqual(len(results), world_size)
  
          for result in results:
              if isinstance(obj, dict):
                  for key in obj:
                      if key == "tensor":
                          self.assertTrue(
                              torch.allclose(result[key], obj[key])
                          )
                      else:
                          self.assertEqual(result[key], obj[key])
              else:
                  self.assertEqual(result, obj)
  
file_path: ClassyVision/test/generic_distributed_util_test.py
imports: import tempfile
  import unittest
  from itertools import product
  from typing import Any, Dict, List
  import torch
  from classy_vision.generic.distributed_util import _PRIMARY_RANK, broadcast_object
  from torch.multiprocessing import Event, Process, Queue
label_desc: Use image node_id 2 for calling the TestDistributedUtil obj's underlying member method code with example usage: obj.test_broadcast_object() without return types