code: def test_lc_2d(
      self, N, C, H, W, M, kernel, op_name, order, use_bias, gc, dc
  ):
      if H < kernel:
          kernel = H
      if W < kernel:
          kernel = W
  
      assume(C == kernel * N)
  
      op = core.CreateOperator(
          op_name,
          ["X", "W", "b"] if use_bias else ["X", "W"],
          ["Y"],
          kernels=[kernel, kernel],
          order=order,
          engine="",
      )
  
      Y_H = H - kernel + 1
      Y_W = W - kernel + 1
      if order == "NCHW":
          X = np.random.rand(N, C, H, W).astype(np.float32) - 0.5
          W = (
              np.random.rand(Y_H, Y_W, M, C, kernel, kernel).astype(
                  np.float32
              )
              - 0.5
          )
      else:
          X = np.random.rand(N, H, W, C).astype(np.float32) - 0.5
          W = (
              np.random.rand(Y_H, Y_W, M, kernel, kernel, C).astype(
                  np.float32
              )
              - 0.5
          )
      b = np.random.rand(Y_H, Y_W, M).astype(np.float32) - 0.5
      inputs = [X, W, b] if use_bias else [X, W]
  
      def lc_2d_nchw(X, W, b=None):
          N, C, XH, XW = X.shape
          YH, YW, M, _, KH, KW = W.shape
  
          def conv(n, m, yh, yw):
              sum = b[yh, yw, m] if b is not None else 0
              for c in range(C):
                  for kh in range(KH):
                      for kw in range(KW):
                          hh = yh + kh
                          ww = yw + kw
                          sum += (
                              X[n, c, hh, ww] * W[yh, yw, m, c, kh, kw]
                          )
              return sum
  
          output = np.zeros((N, M, YH, YW), dtype=np.float32)
          for n in range(N):
              for m in range(M):
                  for yh in range(YH):
                      for yw in range(YW):
                          output[n, m, yh, yw] = conv(n, m, yh, yw)
          return [output]
  
      def lc_2d_nhwc(X, W, b=None):
          XT = utils.NHWC2NCHW(X)
          WT = np.transpose(W, [0, 1, 2, 5, 3, 4])
          output = lc_2d_nchw(XT, WT, b)
          return [utils.NCHW2NHWC(output[0])]
  
      ref_op = lc_2d_nchw if order == "NCHW" else lc_2d_nhwc
  
      self.assertReferenceChecks(
          device_option=gc,
          op=op,
          inputs=inputs,
          reference=ref_op,
      )
      self.assertDeviceChecks(dc, op, inputs, [0])
      for i in range(len(inputs)):
          self.assertGradientChecks(gc, op, inputs, i, [0])
  
file_path: pytorch/caffe2/python/operator_test/locally_connected_op_test.py
imports: import numpy
  from hypothesis import given, settings, assume
  import hypothesis.strategies
  from caffe2.python import core, utils, workspace
  import caffe2.python.hypothesis_test_util
  import caffe2.python.serialized_test.serialized_test_util
label_desc: Use image node_id 1 for calling the TestLocallyConnectedOp obj's underlying member method code with example usage: obj.test_lc_2d(N, C, H, W, M, kernel, op_name, order, use_bias, gc, dc) and returns: list, list, sum