code: def linear_op_reductions(self, op_str):
      device_mesh = self.build_device_mesh()
      shard_spec = [Shard(0)]
  
      tensor = torch.randn(12, 8, 8)
      dtensor = distribute_tensor(tensor, device_mesh, shard_spec)
  
      op = getattr(tensor, op_str)
      op_dt = getattr(dtensor, op_str)
  
      keep_dim_or_not = [True, False, None]
      for dim in range(tensor.ndim):
          for keep_dim in keep_dim_or_not:
              args = (dim, keep_dim) if keep_dim is not None else (dim,)
              if op_str in ("max", "min"):
                  # min and max return a tuple when dim specified
                  dim_reduced_tensor, _ = op(*args)
                  dt_reduced, _ = op_dt(*args)
              else:
                  dim_reduced_tensor = op(*args)
                  dt_reduced = op_dt(*args)
              dt_dim_reduced_tensor = dt_reduced.full_tensor()
              self.assertEqual(
                  dt_dim_reduced_tensor, dim_reduced_tensor
              )
  
      full_reduced_tensor = op()
      dt_full_reduced = op_dt().full_tensor()
      self.assertEqual(dt_full_reduced, full_reduced_tensor)
  
file_path: pytorch/test/distributed/_tensor/test_math_ops.py
imports: import copy
  import itertools
  import torch
  from torch.distributed._tensor import DeviceMesh, distribute_module, distribute_tensor
  from torch.distributed._tensor.debug import CommDebugMode
  from torch.distributed._tensor.ops.utils import is_tensor_partial
  from torch.distributed._tensor.placement_types import Replicate, Shard
  from torch.testing._internal.common_utils import run_tests
  from torch.testing._internal.distributed._tensor.common_dtensor import DTensorTestBase, skip_unless_torch_gpu, with_comms
label_desc: Use image node_id 1 for calling the DistMathOpsTest obj's underlying member method code with example usage: obj.linear_op_reductions(op_str) without return types