code: def _testMiniAlexNet(self, order):
      # First, we get all the random initialization of parameters.
      model = self._MiniAlexNetNoDropout(order)
      workspace.ResetWorkspace()
      workspace.RunNetOnce(model.param_init_net)
      inputs = dict(
          [
              (str(name), workspace.FetchBlob(str(name)))
              for name in model.params
          ]
      )
      if order == "NCHW":
          inputs["data"] = np.random.rand(4, 3, 227, 227).astype(
              np.float32
          )
      else:
          inputs["data"] = np.random.rand(4, 227, 227, 3).astype(
              np.float32
          )
      inputs["label"] = np.array([1, 2, 3, 4]).astype(np.int32)
  
      cpu_device = caffe2_pb2.DeviceOption()
      cpu_device.device_type = caffe2_pb2.CPU
      gpu_device = caffe2_pb2.DeviceOption()
      gpu_device.device_type = workspace.GpuDeviceType
  
      checker = device_checker.DeviceChecker(
          0.05, [cpu_device, gpu_device]
      )
      ret = checker.CheckNet(
          model.net.Proto(),
          inputs,
          # The indices sometimes may be sensitive to small numerical
          # differences in the input, so we ignore checking them.
          ignore=["_pool1_idx", "_pool2_idx", "_pool5_idx"],
      )
      self.assertEqual(ret, True)
  
file_path: pytorch/caffe2/python/model_device_test.py
imports: import numpy
  import unittest
  from caffe2.proto import caffe2_pb2
  from caffe2.python import workspace, device_checker, test_util, model_helper, brew
label_desc: Use image node_id 2 for calling the TestMiniAlexNet obj's underlying member method code with example usage: obj._testMiniAlexNet(order) without return types