code: def test_unshard_params_from_backward_raises(self):
      model = FSDP(nn.Linear(2, 1, device=self.device))
      output = model(torch.ones(2, device=self.device))
  
      def invalid_backward_hook(*args, **kwargs):
          with FSDP.summon_full_params(model):
              pass
  
      self.assertTrue(output.requires_grad)
      output.register_hook(invalid_backward_hook)
      with self.assertRaisesRegex(
          AssertionError,
          "Cannot manually unshard parameters during forward/backward",
      ):
          output.backward()
  
imports: import contextlib
  import itertools
  import math
  import sys
  from typing import Any, Dict, List, Optional, Union
  import torch
  import torch.distributed.fsdp._traversal_utils
  import torch.nn
  from torch import distributed
  from torch.distributed.fsdp import CPUOffload, FullyShardedDataParallel, MixedPrecision, ShardingStrategy
  from torch.distributed.fsdp._common_utils import clean_tensor_name
  from torch.distributed.fsdp._flat_param import FlatParameter
  from torch.nn.parallel.distributed import DistributedDataParallel
  from torch.testing._internal.common_distributed import skip_if_lt_x_gpu
  from torch.testing._internal.common_fsdp import CUDAInitMode, FSDPInitMode, FSDPTest, NestedWrappedModule, TransformerWithSharedParams
  from torch.testing._internal.common_utils import run_tests, TEST_WITH_DEV_DBG_ASAN
label_desc: Use image node_id 3 for calling the TestUnshardParamsErrors obj's underlying member method code with example usage: obj.test_unshard_params_from_backward_raises() without return types