code: def test_constraint_indicators(self):
      # nonnegative objective, one constraint
      samples = torch.randn(1)
      ind = compute_feasibility_indicator(
          constraints=[zeros_f], samples=samples
      )
      self.assertAllClose(ind, torch.ones_like(ind))
      self.assertEqual(ind.dtype, torch.bool)
  
      smoothed_ind = compute_smoothed_feasibility_indicator(
          constraints=[zeros_f], samples=samples, eta=1e-3
      )
      self.assertAllClose(smoothed_ind, ones_f(samples) / 2)
  
      # two constraints
      samples = torch.randn(1)
      smoothed_ind = compute_smoothed_feasibility_indicator(
          constraints=[zeros_f, zeros_f],
          samples=samples,
          eta=1e-3,
      )
      self.assertAllClose(smoothed_ind, ones_f(samples) * 0.5 * 0.5)
  
      # feasible
      samples = torch.randn(1)
      ind = compute_feasibility_indicator(
          constraints=[minus_one_f],
          samples=samples,
      )
      self.assertAllClose(ind, torch.ones_like(ind))
  
      smoothed_ind = compute_smoothed_feasibility_indicator(
          constraints=[minus_one_f], samples=samples, eta=1e-3
      )
      self.assertTrue((smoothed_ind > 3 / 4).all())
  
      with self.assertRaisesRegex(
          ValueError, "Number of provided constraints"
      ):
          compute_smoothed_feasibility_indicator(
              constraints=[zeros_f, zeros_f],
              samples=samples,
              eta=torch.tensor([0.1], device=self.device),
          )
  
      # test marginalize_dim
      samples = torch.randn(1, 2, 1, 1)
      ind = compute_feasibility_indicator(
          constraints=[zeros_f], samples=samples, marginalize_dim=-3
      )
      self.assertAllClose(ind, torch.ones_like(ind))
      self.assertTrue(ind.shape == torch.Size([1, 1]))
      self.assertEqual(ind.dtype, torch.bool)
  
imports: import torch
  from botorch.utils import apply_constraints, get_objective_weights_transform
  from botorch.utils.objective import compute_feasibility_indicator, compute_smoothed_feasibility_indicator, soft_eval_constraint
  from botorch.utils.testing import BotorchTestCase
  from torch import Tensor
label_desc: Use image node_id 4 for calling the TestApplyConstraints obj's underlying member method code with example usage: obj.test_constraint_indicators() without return types