code: def compare_test(
      self, inputs, outputs, grad_ops, atol=1e-7, rtol=1e-7
  ):
      def parse_proto(x):
          proto = caffe2_pb2.OperatorDef()
          proto.ParseFromString(x)
          return proto
  
      source_dir = self.get_output_dir()
      test_name = self.get_output_filename()
      temp_dir = tempfile.mkdtemp()
      with ZipFile(os.path.join(source_dir, test_name + ".zip")) as z:
          z.extractall(temp_dir)
  
      op_path = os.path.join(temp_dir, "op.pb")
      inout_path = os.path.join(temp_dir, "inout.npz")
  
      # load serialized input and output
      loaded = np.load(inout_path, encoding="bytes", allow_pickle=True)
      loaded_inputs = loaded["inputs"].tolist()
      inputs_equal = True
      for x, y in zip(inputs, loaded_inputs):
          if not np.array_equal(x, y):
              inputs_equal = False
      loaded_outputs = loaded["outputs"].tolist()
  
      # if inputs are not the same, run serialized input through serialized op
      if not inputs_equal:
          # load operator
          with open(op_path, "rb") as f:
              loaded_op = f.read()
  
          op_proto = parse_proto(loaded_op)
          device_type = loaded["device_type"]
          device_option = caffe2_pb2.DeviceOption(
              device_type=int(device_type)
          )
  
          outputs = hu.runOpOnInput(
              device_option, op_proto, loaded_inputs
          )
          grad_ops = _getGradientOrNone(op_proto)
  
      # assert outputs are equal
      for x, y in zip(outputs, loaded_outputs):
          np.testing.assert_allclose(x, y, atol=atol, rtol=rtol)
  
      # assert gradient op is equal
      for i in range(len(grad_ops)):
          grad_path = os.path.join(temp_dir, "grad_{}.pb".format(i))
          with open(grad_path, "rb") as f:
              loaded_grad = f.read()
          grad_proto = parse_proto(loaded_grad)
          self._assertSameOps(grad_proto, grad_ops[i])
  
      shutil.rmtree(temp_dir)
  
imports: import inspect
  import os
  import shutil
  import sys
  import tempfile
  import threading
  from contextlib import contextmanager
  from zipfile import ZipFile
  import argparse
  import hypothesis
  import numpy
  import caffe2.python.hypothesis_test_util
  from caffe2.proto import caffe2_pb2
  from caffe2.python import gradient_checker
  from caffe2.python.serialized_test import coverage
label_desc: Use image node_id 4 for calling the SerializedTestCase obj's underlying member method code with example usage: obj.compare_test(inputs, outputs, grad_ops, atol, rtol) and returns: proto