code: def test_hsm_gradient(self, gc, dc):
      samples = 10
      dim_in = 5
      X = np.random.rand(samples, dim_in).astype(np.float32) - 0.5
      w = (
          np.random.rand(hierarchy_proto.size, dim_in).astype(
              np.float32
          )
          - 0.5
      )
      b = np.random.rand(hierarchy_proto.size).astype(np.float32) - 0.5
      labels = np.array(
          [np.random.randint(0, 8) 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],
      )
  
      self.assertDeviceChecks(dc, op, [X, w, b, labels], [0])
  
      for i in range(3):
          self.assertGradientChecks(gc, op, [X, w, b, labels], i, [0])
  
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 4 for calling the TestHsm obj's underlying member method code with example usage: obj.test_hsm_gradient(gc, dc) without return types