code: def test_broadcast_nd(self):
      mesh_tensor = torch.arange(8).reshape(2, 2, 2)
      mesh = DeviceMesh(self.device_type, mesh_tensor)
      local_tensor = (
          torch.ones(3, 3, device=self.device_type) * self.rank
      )
  
      # check all dim groups
      dim_to_subgroups = mesh.get_group()
      for dim, dim_group in enumerate(dim_to_subgroups):
          dim_group_size = get_world_size(dim_group)
          global_ranks = [
              get_global_rank(dim_group, i)
              for i in range(dim_group_size)
          ]
          cloned_local_tensor = local_tensor.clone()
          mesh_broadcast(cloned_local_tensor, mesh, mesh_dim=dim)
          res_num = global_ranks[0]
          self.assertEqual(
              cloned_local_tensor, torch.ones(3, 3) * res_num
          )
  
imports: import os
  import torch
  import torch.distributed._functional_collectives
  from torch.distributed._tensor import DTensor
  from torch.distributed._tensor._collective_utils import mesh_all_to_all, mesh_broadcast, mesh_scatter
  from torch.distributed._tensor.placement_types import _Partial, Shard
  from torch.distributed.device_mesh import _mesh_resources, DeviceMesh, init_device_mesh
  from torch.distributed.distributed_c10d import get_global_rank, get_world_size, init_process_group, is_initialized, is_nccl_available, ProcessGroup
  from torch.testing._internal.common_utils import run_tests
  from torch.testing._internal.distributed._tensor.common_dtensor import DTensorTestBase, with_comms
  from torch.testing._internal.distributed.fake_pg import FakeStore
label_desc: Use image node_id 8 for calling the DeviceMeshCollectiveTest obj's underlying member method code with example usage: obj.test_broadcast_nd() without return types