code: def test_reduce_sum(state):
      # For now runs on only two processes
      if state.num_processes != 2:
          return
      tensor = create_tensor(state)
      reduced_tensor = reduce(tensor, "sum")
      truth_tensor = torch.tensor([4.0, 6]).to(state.device)
      assert torch.allclose(
          reduced_tensor, truth_tensor
      ), f"{reduced_tensor} != {truth_tensor}"
  
file_path: accelerate/src/accelerate/test_utils/scripts/test_ops.py
imports: import torch
  from accelerate import PartialState
  from accelerate.test_utils.testing import assert_exception
  from accelerate.utils.dataclasses import DistributedType
  from accelerate.utils.operations import DistributedOperationException, broadcast, gather, gather_object, pad_across_processes, reduce
label_desc: Use image node_id 7 for calling a global function with example usage: test_reduce_sum(state) without return types