class_docstr: Test case for package-level functions for correctness.
class_docstr_tok: ["Test","case","for","package-level","functions","for","correctness","."]
docstr: Test reference and patched net forward equivalence.
  
  Test if, given rand fast weights, patched net and reference forwards
  match up given random inputs.
docstr_tok: ["Test","reference","and","patched","net","forward","equivalence",".","Test","if",",","given","rand","fast","weights",",","patched","net","and","reference","forwards","match","up","given","random","inputs","."]
code: def testRandomForwards(self):
      """Test reference and patched net forward equivalence.
  
      Test if, given rand fast weights, patched net and reference forwards
      match up given random inputs.
      """
      with higher.innerloop_ctx(self.target_net, self.opt) as (fnet, _):
          for i in range(10):
              fast_named_weights = OrderedDict(
                  (name, torch.rand(p.shape, requires_grad=True))
                  for name, p in self.reference_net.named_parameters()
              )
              fast_weights = [p for _, p in fast_named_weights.items()]
              inputs = torch.rand(
                  self.batch_size,
                  self.num_in_channels,
                  self.in_h,
                  self.in_w,
              )
              self.assertTrue(
                  torch.equal(
                      self.reference_net(
                          inputs, params=fast_named_weights
                      ),
                      fnet(inputs, params=fast_weights),
                  )
              )
  
imports: import unittest
  import copy
  from collections import OrderedDict
  import numpy
  import torch
  from torch import nn, optim
  from torch.nn import functional
  import higher
label_desc: Use image node_id 4 for calling the TestCorrectness obj's underlying member method code with example usage: obj.testRandomForwards() without return types