code: def test_fc_with_axis(self, n, m, c, h, w, axis, gc, dc):
      X = np.random.rand(n, c, h, w).astype(np.float32) - 0.5
      k = reduce((lambda x, y: x * y), [n, c, h, w][axis - 4 :])
      nn = reduce((lambda x, y: x * y), [n, c, h, w][:axis])
      W = np.random.rand(m, k).astype(np.float32) - 0.5
      b = np.random.rand(m).astype(np.float32) - 0.5
      dY = np.random.rand(nn, m).astype(np.float32) - 0.5
  
      op0 = core.CreateOperator(
          "FC", ["X", "W", "b"], ["Y"], axis=axis, device_option=dc[0]
      )
  
      op0_bw = core.CreateOperator(
          "FCGradient",
          ["X", "W", "dY"],
          ["dW", "db"],
          axis=axis,
          device_option=dc[0],
      )
  
      workspace.ResetWorkspace()
      workspace.FeedBlob("X", X, dc[0])
      workspace.FeedBlob("W", W, dc[0])
      workspace.FeedBlob("b", b, dc[0])
      workspace.RunOperatorOnce(op0)
      Y0 = workspace.FetchBlob("Y")
  
      workspace.FeedBlob("dY", dY, dc[0])
      workspace.RunOperatorOnce(op0_bw)
      dW0 = workspace.FetchBlob("dW")
      db0 = workspace.FetchBlob("db")
  
      op1 = core.CreateOperator(
          "FC", ["X", "W", "b"], ["Y"], axis=axis, device_option=dc[1]
      )
  
      op1_bw = core.CreateOperator(
          "FCGradient",
          ["X", "W", "dY"],
          ["dW", "db"],
          axis=axis,
          device_option=dc[1],
      )
  
      workspace.SwitchWorkspace("_device_check_", True)
      workspace.FeedBlob("X", X, dc[1])
      workspace.FeedBlob("W", W, dc[1])
      workspace.FeedBlob("b", b, dc[1])
      workspace.RunOperatorOnce(op1)
      Y1 = workspace.FetchBlob("Y")
  
      workspace.FeedBlob("dY", dY, dc[1])
      workspace.RunOperatorOnce(op1_bw)
      dW1 = workspace.FetchBlob("dW")
      db1 = workspace.FetchBlob("db")
  
      Y0 = Y0.flatten()
      Y1 = Y1.flatten()
      if not np.allclose(Y0, Y1, atol=0.01, rtol=0.01):
          print(Y1)
          print(Y0)
          print(np.max(np.abs(Y1 - Y0)))
          self.assertTrue(False)
  
      dW0 = dW0.flatten()
      dW1 = dW1.flatten()
      if not np.allclose(dW0, dW1, atol=0.01, rtol=0.01):
          print(dW1)
          print(dW0)
          print(np.max(np.abs(dW1 - dW0)))
          self.assertTrue(False)
  
      db0 = db0.flatten()
      db1 = db1.flatten()
      if not np.allclose(db0, db1, atol=0.01, rtol=0.01):
          print(db1)
          print(db0)
          print(np.max(np.abs(db1 - db0)))
          self.assertTrue(False)
  
file_path: pytorch/caffe2/python/ideep/fc_op_test.py
imports: import unittest
  from functools import reduce
  import hypothesis.strategies
  from hypothesis import given, settings
  import numpy
  from caffe2.proto import caffe2_pb2
  from caffe2.python import core, workspace
  import caffe2.python.hypothesis_test_util
  import caffe2.python.ideep_test_util
label_desc: Use image node_id 2 for calling the FcTest obj's underlying member method code with example usage: obj.test_fc_with_axis(n, m, c, h, w, axis, gc, dc) without return types