code: def test_requires_grad_ctx(self):
      # Test temporary setting of requires_grad field
      with requires_grad_ctx(
          self.module, assignments={"a": False, "b": True}
      ):
          self.assertTrue(not self.module.a.requires_grad)
          self.assertTrue(self.module.b.requires_grad)
          self.assertTrue(self.module.c.requires_grad)
  
      # Test that requires_grad fields get restored
      self.assertTrue(self.module.a.requires_grad)
      self.assertTrue(not self.module.b.requires_grad)
      self.assertTrue(self.module.c.requires_grad)
  
file_path: botorch/test/utils/test_context_managers.py
imports: from __future__ import annotations
  from string import ascii_lowercase
  import torch
  from botorch.utils.context_managers import delattr_ctx, module_rollback_ctx, parameter_rollback_ctx, requires_grad_ctx, TensorCheckpoint, zero_grad_ctx
  from botorch.utils.testing import BotorchTestCase
  from torch.nn import Module, Parameter
label_desc: Use image node_id 3 for calling the TestContextManagers obj's underlying member method code with example usage: obj.test_requires_grad_ctx() without return types