code: def _compare(self, model, forward_only):
      # Store list of blobs that exist in the beginning
      workspace.RunNetOnce(model.param_init_net)
      init_ws = {k: workspace.FetchBlob(k) for k in workspace.Blobs()}
  
      # Run with executor
      for enable_executor in [0, 1]:
          self.enable_rnn_executor(
              model.net, enable_executor, forward_only
          )
          workspace.ResetWorkspace()
  
          # Reset original state
          for k, v in init_ws.items():
              workspace.FeedBlob(k, v)
  
          np.random.seed(10022015)
          ws = {}
          for j in range(len(self.Tseq)):
              input_shape = [
                  self.Tseq[j],
                  self.batch_size,
                  self.input_dim,
              ]
              workspace.FeedBlob(
                  "input",
                  np.random.rand(*input_shape).astype(np.float32),
              )
              workspace.FeedBlob(
                  "target",
                  np.random.rand(
                      self.Tseq[j], self.batch_size, self.hidden_dim
                  ).astype(np.float32),
              )
              if j == 0:
                  workspace.CreateNet(model.net, overwrite=True)
  
              workspace.RunNet(model.net.Proto().name)
  
              # Store results for each iteration
              for k in workspace.Blobs():
                  ws[k + "." + str(j)] = workspace.FetchBlob(k)
  
          if enable_executor:
              rnn_exec_ws = ws
          else:
              non_exec_ws = ws
  
      # Test that all blobs are equal after running with executor
      # or without.
      self.assertEqual(
          list(non_exec_ws.keys()), list(rnn_exec_ws.keys())
      )
  
      mismatch = False
      for k in rnn_exec_ws.keys():
          non_exec_v = non_exec_ws[k]
          rnn_exec_v = rnn_exec_ws[k]
          if type(non_exec_v) is np.ndarray:
              if not np.allclose(non_exec_v, rnn_exec_v):
                  print("Mismatch: {}".format(k))
                  nv = non_exec_v.flatten()
                  rv = rnn_exec_v.flatten()
                  c = 0
                  for j in range(len(nv)):
                      if rv[j] != nv[j]:
                          print(j, rv[j], nv[j])
                          c += 1
                          if c == 10:
                              break
  
                  mismatch = True
  
      self.assertFalse(mismatch)
  
file_path: pytorch/caffe2/python/operator_test/recurrent_net_executor_test.py
imports: from caffe2.proto import caffe2_pb2
  from caffe2.python import model_helper, workspace, core, rnn_cell, test_util
  from caffe2.python.attention import AttentionType
  import numpy
  import unittest
  import caffe2.python.hypothesis_test_util
  import hypothesis.strategies
  from hypothesis import given, settings
label_desc: Use image node_id 6 for calling the TestRNNExecutor obj's underlying member method code with example usage: obj._compare(model, forward_only) without return types