class_docstr: This class tests all member functions of crypten package
code: def test_broadcast_obj(self) -> None:
      TEST_OBJECTS = [
          {"a": 1, "b": 2, "c": 3},
          torch.tensor(1),
          torch.nn.Linear(10, 5),
          CNN(),
      ]
      for param in TEST_OBJECTS[2].parameters():
          param.data.fill_(1.0)
      for param in TEST_OBJECTS[3].parameters():
          param.data.fill_(1.0)
      serial.register_safe_class(CNN)
  
      for reference in TEST_OBJECTS:
          for src in range(self.world_size):
              test_obj = reference if self.rank == src else None
              test_obj = comm.get().broadcast_obj(test_obj, src)
              if isinstance(reference, torch.nn.Module):
                  test_obj_params = list(test_obj.parameters())
                  reference_params = list(reference.parameters())
                  for i, param in enumerate(reference_params):
                      self.assertTrue(
                          test_obj_params[i].eq(param).all(),
                          "broadcast_obj failed",
                      )
              else:
                  self.assertEqual(
                      test_obj, reference, "broadcast_obj failed"
                  )
  
      # Test that the restricted loader will raise an error for code injection
      for invalid_obj in INVALID_SERIALIZED_OBJECTS:
          for src in range(self.world_size):
              if self.rank == src:
                  # Mimic broadcast_obj without pickling invalid bytestream
                  size = torch.tensor(
                      len(invalid_obj), dtype=torch.int32
                  )
                  arr = torch.from_numpy(
                      numpy.frombuffer(invalid_obj, dtype=numpy.int8)
                  )
  
                  dist.broadcast(size, src, group=comm.get().main_group)
                  dist.broadcast(arr, src, group=comm.get().main_group)
              else:
                  with self.assertRaises(ValueError):
                      test_obj = None
                      comm.get().broadcast_obj(test_obj, src)
  
imports: import unittest
  import crypten
  import crypten.communicator
  import numpy
  import torch
  import torch.distributed
  import torch.nn
  import torch.nn.functional
  from crypten.common import serial
  from crypten.config import cfg
  from test.multiprocess_test_case import get_random_test_tensor, MultiProcessTestCase
label_desc: Use image node_id 17 for calling the TestCommunicator obj's underlying member method code with example usage: obj.test_broadcast_obj() without return types