code: def test_hsm_forward(self):
      cpu_device_option = caffe2_pb2.DeviceOption()
      grad_checker = gradient_checker.GradientChecker(
          0.01, 0.05, cpu_device_option, "default"
      )
      samples = 9
      dim_in = 5
      X = np.zeros((samples, dim_in)).astype(np.float32) + 1
      w = (
          np.zeros((hierarchy_proto.size, dim_in)).astype(np.float32)
          + 1
      )
      b = np.array([i for i in range(hierarchy_proto.size)]).astype(
          np.float32
      )
      labels = np.array([i for i in range(samples)]).astype(np.int32)
  
      workspace.GlobalInit(["caffe2"])
      workspace.FeedBlob("data", X)
      workspace.FeedBlob("weights", w)
      workspace.FeedBlob("bias", b)
      workspace.FeedBlob("labels", labels)
  
      op = core.CreateOperator(
          "HSoftmax",
          ["data", "weights", "bias", "labels"],
          ["output", "intermediate_output"],
          "HSoftmax",
          arg=[arg],
      )
      grad_ops, g_input = core.GradientRegistry.GetGradientForOp(
          op, [s + "_grad" for s in op.output]
      )
  
      loss, _ = grad_checker.GetLossAndGrad(
          op, grad_ops, [X, w, b, labels], op.input, 0, g_input[0], [0]
      )
      self.assertAlmostEqual(loss, 44.269, delta=0.001)
  
file_path: pytorch/caffe2/python/operator_test/hsm_test.py
imports: from hypothesis import given, settings
  import numpy
  import unittest
  from caffe2.proto import caffe2_pb2, hsm_pb2
  from caffe2.python import workspace, core, gradient_checker
  import caffe2.python.hypothesis_test_util
  import caffe2.python.hsm_util
label_desc: Use image node_id 3 for calling the TestHsm obj's underlying member method code with example usage: obj.test_hsm_forward() without return types