code: def test_hard_sigmoid(self, X, inplace, alpha, beta, engine, gc, dc):
      # Prevent alpha and beta from mutually being 0 to avoid a division
      # error when adjusting our inputs
      assume(alpha != 0.0 or beta != 0.0)
      op = core.CreateOperator(
          "HardSigmoid",
          ["X"],
          ["X"] if inplace else ["Y"],
          alpha=alpha,
          beta=beta,
          engine=engine,
      )
  
      def hard_sigmoid_ref(X):
          return [np.minimum(1.0, np.maximum(0.0, X * alpha + beta))]
  
      # Adjust inputs to avoid differentitating at inflection points
      if abs(alpha) > 0.001:
          Y = X * alpha + beta
          Y += 0.04 * np.sign(Y)
          Y[Y == 0.0] += 0.1
          Y[Y == 1.0] -= 0.1
          X = (Y - beta) / alpha
  
      self.assertReferenceChecks(
          device_option=gc,
          op=op,
          inputs=[X],
          reference=hard_sigmoid_ref,
          ensure_outputs_are_inferred=True,
      )
      self.assertDeviceChecks(dc, op, [X], [0])
      self.assertGradientChecks(
          gc,
          op,
          [X],
          0,
          [0],
          stepsize=1e-4,
          threshold=1e-2,
          ensure_outputs_are_inferred=True,
      )
  
imports: from caffe2.python import core, workspace
  from hypothesis import given, assume, settings
  import caffe2.python.hypothesis_test_util
  import hypothesis.strategies
  import numpy
  import unittest
label_desc: Use image node_id 20 for calling the TestElementwiseOps obj's underlying member method code with example usage: obj.test_hard_sigmoid(X, inplace, alpha, beta, engine, gc, dc) and returns: list