code: def test_op_checker(state):
      # Must be in a distributed state
      if state.distributed_type == DistributedType.NO:
          return
      state.debug = True
      # `pad_across_processes`
      if state.process_index == 0:
          data = {
              "tensor": torch.tensor([[0.0, 1, 2, 3, 4]]).to(
                  state.device
              )
          }
      else:
          data = {
              "tensor": torch.tensor([[[0.0, 1, 2, 3, 4, 5]]]).to(
                  state.device
              )
          }
  
      with assert_exception(DistributedOperationException):
          pad_across_processes(data, dim=0)
  
      # `reduce`
      if state.process_index == 0:
          data = {
              "tensor": torch.tensor([[0.0, 1, 2, 3, 4]]).to(
                  state.device
              )
          }
      else:
          data = {
              "tensor": torch.tensor(
                  [[[0.0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]]
              ).to(state.device)
          }
  
      with assert_exception(DistributedOperationException):
          reduce(data)
  
      # `broadcast`
      if state.process_index == 0:
          data = {
              "tensor": torch.tensor([[0.0, 1, 2, 3, 4]]).to(
                  state.device
              )
          }
      else:
          data = {
              "tensor": torch.tensor(
                  [[[0.0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]]
              ).to(state.device)
          }
  
      with assert_exception(DistributedOperationException):
          broadcast(data)
  
      state.debug = False
  
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 9 for calling a global function with example usage: test_op_checker(state) without return types