code: def test_interleaving_then_and_add_done_callback_propagates_error(
      self,
  ):
      def raise_value_error(fut):
          raise ValueError("Expected error")
  
      fut = Future[torch.Tensor]()
      then_fut = fut.then(raise_value_error)
      fut.add_done_callback(raise_value_error)
      fut.set_result(torch.ones(2, 2))
  
      # error from add_done_callback's callback is swallowed
      # error from then's callback is not
      self.assertEqual(fut.wait(), torch.ones(2, 2))
      with self.assertRaisesRegex(RuntimeError, "Expected error"):
          then_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 21 for calling the TestFuture obj's underlying member method code with example usage: obj.test_interleaving_then_and_add_done_callback_propagates_error() without return types