code: def test_get_monotonicity_constraints(self):
      for dtype in (torch.float, torch.double):
          tkwargs = {"dtype": dtype, "device": self.device}
          for d in (3, 17):
              with self.subTest(dtype=dtype, d=d):
                  A, b = get_monotonicity_constraints(d, **tkwargs)
                  self.assertEqual(A.shape, (d - 1, d))
                  self.assertEqual(A.dtype, dtype)
                  self.assertEqual(A.device.type, self.device.type)
  
                  self.assertEqual(b.shape, (d - 1, 1))
                  self.assertEqual(b.dtype, dtype)
                  self.assertEqual(b.device.type, self.device.type)
  
                  unique_vals = torch.tensor([-1, 0, 1], **tkwargs)
                  self.assertAllClose(A.unique(), unique_vals)
                  self.assertAllClose(b, torch.zeros_like(b))
                  self.assertTrue(
                      torch.equal(
                          A.sum(dim=-1), torch.zeros(d - 1, **tkwargs)
                      )
                  )
  
                  n_test = 3
                  X_test = torch.randn(d, n_test, **tkwargs)
  
                  X_diff_true = -X_test.diff(dim=0)  # x[i] - x[i+1] < 0
                  X_diff = A @ X_test
                  self.assertAllClose(X_diff, X_diff_true)
  
                  is_monotonic_true = (X_diff_true < 0).all(dim=0)
                  is_monotonic = (X_diff < b).all(dim=0)
                  self.assertAllClose(is_monotonic, is_monotonic_true)
  
                  Ad, bd = get_monotonicity_constraints(
                      d, descending=True, **tkwargs
                  )
                  self.assertAllClose(Ad, -A)
                  self.assertAllClose(bd, b)
  
file_path: botorch/test/utils/test_constraints.py
imports: import torch
  from botorch.utils import get_outcome_constraint_transforms
  from botorch.utils.constraints import get_monotonicity_constraints
  from botorch.utils.testing import BotorchTestCase
label_desc: Use image node_id 3 for calling the TestConstraintUtils obj's underlying member method code with example usage: obj.test_get_monotonicity_constraints() without return types