code: def test_equal(self):
      device_mesh = DeviceMesh(
          self.device_type, list(range(self.world_size))
      )
      shard_spec = [Shard(0)]
  
      input_tensor_1 = torch.ones(4, 4)
      dist_tensor_1 = DTensor.from_local(
          input_tensor_1, device_mesh, shard_spec
      )
  
      # tensors are equal
      input_tensor_2 = torch.ones(4, 4)
      dist_tensor_2 = DTensor.from_local(
          input_tensor_2, device_mesh, shard_spec
      )
  
      eq_result = dist_tensor_1.equal(dist_tensor_2)
      self.assertTrue(eq_result)
  
      # tensors are different on some shards
      if self.rank == 0:
          input_tensor_2 = torch.ones(4, 4)
      else:
          input_tensor_2 = torch.randn(4, 4)
      dist_tensor_2 = DTensor.from_local(
          input_tensor_2, device_mesh, shard_spec
      )
  
      eq_result = dist_tensor_1.equal(dist_tensor_2)
      # equal op all reduces each shard's local result
      self.assertFalse(eq_result)
      self.assertTrue(dist_tensor_1.is_same_size(dist_tensor_2))
  
      # test if sharding are different
      replica_spec = [Replicate()]
      global_input = torch.ones(4 * self.world_size, 4)
      dist_tensor_3 = DTensor.from_local(
          global_input, device_mesh, replica_spec, run_check=False
      )
  
      self.assertTrue(dist_tensor_1.equal(dist_tensor_3))
      self.assertTrue(dist_tensor_1.is_same_size(dist_tensor_3))
  
      # test sharding difference with only some shards content difference
      self.assertFalse(dist_tensor_2.equal(dist_tensor_3))
      self.assertTrue(dist_tensor_1.is_same_size(dist_tensor_3))
      self.assertFalse(input_tensor_2.is_same_size(dist_tensor_3))
  
imports: import torch
  from torch.distributed._tensor import DeviceMesh, distribute_tensor, DTensor
  from torch.distributed._tensor.placement_types import _Partial, Replicate, Shard
  from torch.testing._internal.common_utils import run_tests
  from torch.testing._internal.distributed._tensor.common_dtensor import DTensorConverter, DTensorTestBase, with_comms
label_desc: Use image node_id 16 for calling the DistTensorOpsTest obj's underlying member method code with example usage: obj.test_equal() without return types