code: def test_set_exception(self) -> None:
      # This test is to ensure errors can propagate across futures.
      error_msg = "Intentional Value Error"
      value_error = ValueError(error_msg)
  
      f = Future[T]()  # type: ignore[valid-type]
      # Set exception
      f.set_exception(value_error)
      # Exception should throw on wait
      with self.assertRaisesRegex(ValueError, "Intentional"):
          f.wait()
  
      # Exception should also throw on value
      f = Future[T]()  # type: ignore[valid-type]
      f.set_exception(value_error)
      with self.assertRaisesRegex(ValueError, "Intentional"):
          f.value()
  
      def cb(fut):
          fut.value()
  
      f = Future[T]()  # type: ignore[valid-type]
      f.set_exception(value_error)
  
      with self.assertRaisesRegex(
          RuntimeError, "Got the following error"
      ):
          cb_fut = f.then(cb)
          cb_fut.wait()
  
imports: import threading
  import time
  import torch
  import unittest
  from torch.futures import Future
  from torch.testing._internal.common_utils import IS_WINDOWS, TestCase, TemporaryFileName, run_tests
  from typing import TypeVar
label_desc: Use image node_id 1 for calling the TestFuture obj's underlying member method code with example usage: obj.test_set_exception() without return types