class_docstr: Test case for the patch module.
class_docstr_tok: ["Test","case","for","the","patch","module","."]
code: def testBackward(self, _, model_builder):
      model = model_builder(self)
      fmodel = higher.patch.monkeypatch(model)
      for _ in range(10):
          inputs = torch.rand(8, 4)
          ref_loss = model(inputs).sum().pow(2)
          loss = fmodel(inputs).sum().pow(2)
          ref_loss.backward()
          loss.backward()
          for true_param, got_param in zip(
              model.parameters(), fmodel.parameters()
          ):
              if true_param.grad is None:
                  self.assertIsNone(got_param.grad)
              else:
                  self.assertIsNotNone(got_param.grad)
                  torch.testing.assert_allclose(
                      true_param.grad, got_param.grad
                  )
      model.zero_grad()
  
imports: import unittest
  from parameterized import parameterized
  import torch
  from torch import nn
  import higher
label_desc: Use image node_id 5 for calling the TestPatch obj's underlying member method code with example usage: obj.testBackward(_, model_builder) without return types