code: def test_mpfuture_cancel():
      future = hivemind.MPFuture()
      assert not future.cancelled()
      future.cancel()
      evt = mp.Event()
  
      def _proc():
          with pytest.raises(concurrent.futures.CancelledError):
              future.result()
          with pytest.raises(concurrent.futures.CancelledError):
              future.exception()
          with pytest.raises(InvalidStateError):
              future.set_result(123)
          with pytest.raises(InvalidStateError):
              future.set_exception(NotImplementedError())
          assert (
              future.cancelled()
              and future.done()
              and not future.running()
          )
          evt.set()
  
      p = mp.Process(target=_proc)
      p.start()
      p.join()
      assert evt.is_set()
  
imports: import asyncio
  import concurrent.futures
  import multiprocessing
  import random
  import time
  from concurrent.futures import ThreadPoolExecutor
  import numpy
  import pytest
  import torch
  import hivemind
  from hivemind.compression import deserialize_torch_tensor, serialize_torch_tensor
  from hivemind.proto.runtime_pb2 import CompressionType
  from hivemind.utils import BatchTensorDescriptor, DHTExpiration, HeapEntry, MSGPackSerializer, ValueWithExpiration
  from hivemind.utils.asyncio import achain, aenumerate, aiter_with_timeout, amap_in_executor, anext, as_aiter, asingle, attach_event_on_finished, azip, cancel_and_wait, enter_asynchronously
  from hivemind.utils.mpfuture import InvalidStateError
  from hivemind.utils.performance_ema import PerformanceEMA
label_desc: Use image node_id 3 for calling a global function with example usage: test_mpfuture_cancel() without return types